Skip to content

Commit

Permalink
lv sampling: use eeta argument only for multilevel
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmerkle committed Aug 27, 2023
1 parent 9e7a2da commit 7375a1d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 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.4-9.1156
Version: 0.4-9.1157
Authors@R: c(person(given = "Edgar", family = "Merkle",
role = c("aut", "cre"),
email = "merklee@missouri.edu",
Expand Down
8 changes: 4 additions & 4 deletions R/blavaan.R
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,13 @@ blavaan <- function(..., # default lavaan arguments
}
## lvs now in R instead of Stan
if(save.lvs & target == "stan"){
## this handles dummy lvs so that we use the appropriate alpha:
lav_eeta <- getFromNamespace("computeEETA", "lavaan")
eeta <- lav_eeta(lavmodel = lavmodel, lavsamplestats = lavsamplestats)
if(lavoptions$.multilevel){
## this handles dummy lvs so that we use the appropriate alpha:
lav_eeta <- getFromNamespace("computeEETA", "lavaan")
eeta <- lav_eeta(lavmodel = lavmodel, lavsamplestats = lavsamplestats)
stanlvs <- samp_lvs_2lev(res, lavmodel, lavsamplestats, lavdata, parests$lavpartable, jagtrans$data, eeta)
} else {
stanlvs <- list(samp_lvs(res, lavmodel, parests$lavpartable, jagtrans$data, eeta, lavInspect(LAV, "categorical")))
stanlvs <- list(samp_lvs(res, lavmodel, parests$lavpartable, jagtrans$data, eeta = NULL, lavInspect(LAV, "categorical")))
}

for(j in 1:(1 + lavoptions$.multilevel)){
Expand Down
8 changes: 7 additions & 1 deletion R/lvgqs.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lvgqs <- function(modmats, standata, eeta = NULL, getlvs = TRUE) {

## new matrices
ovmean <- lvimpmean <- vector("list", Ng)
for (g in 1:Ng){
for (g in 1:Ng) {
if ("nu" %in% names(modmats[[g]])){
ovmean[[g]] <- modmats[[g]]$nu
} else {
Expand All @@ -46,7 +46,13 @@ lvgqs <- function(modmats, standata, eeta = NULL, getlvs = TRUE) {
ovmean[[g]][1:p] <- ovmean[[g]][1:p,] + modmats[[g]]$lambda %*% lvimpmean[[g]]
}
}
}

if (is.null(eeta)) {
eeta <- vector("list", Ng)
for (g in 1:Ng) {
eeta[[g]] <- rep(0, standata$m)
}
}

if ((w9use + w9no) > 0 | !getlvs) {
Expand Down

0 comments on commit 7375a1d

Please sign in to comment.