Skip to content

Commit

Permalink
two-level models, handle lv sampling when lvs only exist at level 1 o…
Browse files Browse the repository at this point in the history
…r at level 2
  • Loading branch information
ecmerkle committed Apr 6, 2024
1 parent 94522bf commit dbc5a11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: blavaan
Title: Bayesian Latent Variable Analysis
Version: 0.5-3.1256
Version: 0.5-3.1261
Authors@R: c(person(given = "Edgar", family = "Merkle",
role = c("aut", "cre"),
email = "[email protected]",
Expand Down
8 changes: 6 additions & 2 deletions R/lvgqs.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ samp_lvs_2lev <- function(mcobj, lavmodel, lavsamplestats, lavdata, lavpartable,
standata$Ntot <- sum(standata$nclus[,2])
standata$Nobs <- with(standata, rep(N_between + N_both, Np))
standata$Obsvar <- with(standata, matrix(1:standata$Nobs[1], Np, N_between + N_both, byrow = TRUE))
tmpmat2[j,,] <- lvgqs(modmat2, standata, eeta[2*(1:standata$Ng)])
if (standata$m > 0) {
tmpmat2[j,,] <- lvgqs(modmat2, standata, eeta[2*(1:standata$Ng)])
}

## now level 1
standata <- stanorig
Expand All @@ -331,7 +333,9 @@ samp_lvs_2lev <- function(mcobj, lavmodel, lavsamplestats, lavdata, lavpartable,
if(!("beta" %in% names(modmat1[[g]]))) modmat1[[g]]$beta <- matrix(0, standata$m, standata$m)
}

tmpmat[j,,] <- lvgqs(modmat1, standata, eeta[2 * (1:standata$Ng) - 1])
if (standata$m > 0) {
tmpmat[j,,] <- lvgqs(modmat1, standata, eeta[2 * (1:standata$Ng) - 1])
}
}
list(tmpmat, tmpmat2)})
if(!debug) {
Expand Down

0 comments on commit dbc5a11

Please sign in to comment.