From e194f5404ca8fbbe37c92c3b969fcd5b7404e924 Mon Sep 17 00:00:00 2001 From: Jim Thorson Date: Mon, 30 Dec 2024 12:05:08 -0800 Subject: [PATCH] fix merge --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/dsem.R | 5 +++++ man/dsem.Rd | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4c89021..df6ebfb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,7 +14,7 @@ Imports: Matrix, sem, igraph, - RTMB + RTMB, ggraph, grid, methods diff --git a/NEWS.md b/NEWS.md index a5fe77c..d5a4724 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,8 @@ option * Adding `convert_equations` to extend `sem::specifyEquations` and simplify specification for large models +* Adding argument `prior_negloglike` as interface to specify Bayesian priors + and/or likelihood penalties # dsem 1.3.0 diff --git a/R/dsem.R b/R/dsem.R index 00928eb..f6b7b8f 100644 --- a/R/dsem.R +++ b/R/dsem.R @@ -20,6 +20,11 @@ #' while covs=c("x1", "x2") specifies the variance of x1 and the variance of x2 but not their covariance. #' These same covariances can be added manually via argument `sem`, but using argument `covs` might #' save time for models with many variables. +#' @param prior_negloglike A user-provided function that takes as input the vector of fixed effects out$obj$par +#' returns the negative log-prior probability. For example +#' \code{prior_negloglike = function(par) -1 * dnorm( par[1], mean=0, sd=0.1, log=TRUE)} +#' specifies a normal prior probability +#' for the for the first fixed effect with mean of zero and logsd of 0.1 #' @param control Output from \code{\link{dsem_control}}, used to define user #' settings, and see documentation for that function for details. #' diff --git a/man/dsem.Rd b/man/dsem.Rd index 93d2cc1..8f084bf 100644 --- a/man/dsem.Rd +++ b/man/dsem.Rd @@ -9,6 +9,7 @@ dsem( tsdata, family = rep("fixed", ncol(tsdata)), estimate_delta0 = FALSE, + prior_negloglike = NULL, control = dsem_control(), covs = colnames(tsdata) ) @@ -29,6 +30,12 @@ Other options correspond to different specifications of measurement error.} as fixed effects, or alternatively to assume that dynamics start at some stochastic draw away from the stationary distribution} +\item{prior_negloglike}{A user-provided function that takes as input the vector of fixed effects out$obj$par +returns the negative log-prior probability. For example +\code{prior_negloglike = function(par) -1 * dnorm( par[1], mean=0, sd=0.1, log=TRUE)} +specifies a normal prior probability +for the for the first fixed effect with mean of zero and logsd of 0.1} + \item{control}{Output from \code{\link{dsem_control}}, used to define user settings, and see documentation for that function for details.}