Skip to content

Commit

Permalink
another fix for codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson committed Jan 19, 2024
1 parent 7a6715b commit a59811d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions R/dsem.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ function( sem,
if( isTRUE(control$getsd) ){
if( isTRUE(control$verbose) ) message("Running sdreport")
Hess_fixed = optimHess( par=out$opt$par, fn=obj$fn, gr=obj$gr )
out$sdrep = sdreport( obj, hessian.fixed=Hess_fixed )
out$sdrep = sdreport( obj,
hessian.fixed = Hess_fixed,
getJointPrecision = control$getJointPrecision )
}else{
out$sdrep = NULL
}
Expand Down Expand Up @@ -273,6 +275,8 @@ function( sem,
#' by hand (only helpful for advanced users to change starting values or restart at intended values)
#' @param map list of fixed and mirrored parameters, constructed by \code{dsem} by default but available
#' to override this default and then pass to \code{\link[TMB]{MakeADFun}}
#' @param getJointPrecision whether to get the joint precision matrix. Passed
#' to \code{\link[TMB]{sdreport}}.
#'
#' @return
#' An S3 object of class "dsem_control" that specifies detailed model settings,
Expand All @@ -290,7 +294,8 @@ function( nlminb_loops = 1,
run_model = TRUE,
use_REML = TRUE,
parameters = NULL,
map = NULL ){
map = NULL,
getJointPrecision = FALSE ){

# Return
structure( list(
Expand All @@ -304,7 +309,8 @@ function( nlminb_loops = 1,
run_model = run_model,
use_REML = use_REML,
parameters = parameters,
map = map
map = map,
getJointPrecision = getJointPrecision
), class = "dsem_control" )
}

Expand Down Expand Up @@ -521,7 +527,7 @@ function( object,
control = control )
out[[r]] = newfit$obj$simulate()$y_tj
}else{
out[[r]] = obj$simulate( par_zr[,r] )
out[[r]] = obj$simulate( par_zr[,r] )$y_tj
}
colnames(out[[r]]) = colnames(tsdata)
tsp(out[[r]]) = attr(tsdata,"tsp")
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-platform.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ test_that("dsem example is working ", {
Z = ts( cbind(Data, "neg_Gov_wage"=-1*Data[,'Gov_wage']) )

# Fit model
fit = dsem( sem=sem, tsdata=Z )
fit = dsem( sem=sem,
tsdata=Z,
control = dsem_control(getJointPrecision=TRUE) )
# Check objective function
expect_equal( as.numeric(fit$opt$obj), 587.4755, tolerance=1e-2 )

Expand Down

0 comments on commit a59811d

Please sign in to comment.