Skip to content

Commit

Permalink
get dsemRTMB working as package
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson committed Jan 2, 2025
1 parent 9c4598d commit 2ac8291
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 9 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(cAIC)
export(classify_variables)
export(convert_equations)
export(dsem)
export(dsemRTMB)
export(dsem_control)
export(list_parameters)
export(loo_residuals)
Expand Down Expand Up @@ -59,3 +60,6 @@ importFrom(stats,simulate)
importFrom(stats,time)
importFrom(stats,vcov)
useDynLib(dsem, .registration = TRUE)

# Edited by hand
import("RTMB")
3 changes: 0 additions & 3 deletions R/compute_nll.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ function( parlist,
# Hadamard squared LU-decomposition
# See: https://eigen.tuxfamily.org/dox/group__QuickRefPage.html
squared_invIminusRho_kk = invIminusRho_kk
#print(class(squared_invIminusRho_kk))
#print(invIminusRho_kk)
#REPORT( invIminusRho_kk )
squared_invIminusRho_kk@x = squared_invIminusRho_kk@x^2

if( options[2] == 1 ){
Expand Down
22 changes: 20 additions & 2 deletions R/dsemRTMB.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@


#' @title Fit dynamic structural equation model
#'
#' @description Fits a dynamic structural equation model
#'
#' @inheritParams dsem
#'
#' @param log_prior A user-provided function that takes as input the list of
#' parameters \code{out$obj$env$parList()} where \code{out} is the output from
#' \code{dsemRTMB()}, and returns the log-prior probability. For example
#' \code{log_prior = function(p) dnorm( p$beta_z[1], mean=0, sd=0.1, log=TRUE)}
#' specifies a normal prior probability for the first path coefficient
#' with mean of zero and sd of 0.1
#'
#' @details
#' See \code{\link{dsem}} for details
#'
#' @return
#' An object (list) of class `dsem`, fitted using RTMB
#'
#' @export
dsemRTMB <-
function( sem,
tsdata,
Expand Down
5 changes: 1 addition & 4 deletions R/read_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
#' @param quiet Boolean indicating whether to print messages to terminal
#'
#' @details
#' \strong{RAM specification using arrow-and-lag notation}
#'
#'
#' @export
#' See \code{\link{make_dsem_ram.R}} for details
read_model <-
function( sem,
times,
Expand Down
59 changes: 59 additions & 0 deletions man/dsemRTMB.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions man/read_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ac8291

Please sign in to comment.