Skip to content

Commit d4808bd

Browse files
committed
ensure ptot exists for all multilevel models
1 parent 7e5d62b commit d4808bd

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: blavaan
22
Title: Bayesian Latent Variable Analysis
3-
Version: 0.5-9.1372
3+
Version: 0.5-9.1376
44
Authors@R: c(person(given = "Edgar", family = "Merkle",
55
role = c("aut", "cre"),
66
email = "merklee@missouri.edu",

R/lav_export_stanmarg.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,11 +1175,6 @@ lav2standata <- function(lavobject, dosam = FALSE) {
11751175
dat$Np <- dat$Ng
11761176
dat$Nobs <- array(nvar, dat$Np)
11771177
dat$Obsvar <- matrix(1:nvar, dat$Np, nvar, byrow=TRUE)
1178-
if (multilevel) {
1179-
ptot <- length(unique(c(Lp[[1]]$ov.idx[[1]]))) #, Lp$ov.idx[[2]])))
1180-
dat$Obsvar <- matrix(1:ptot, dat$Np, ptot, byrow=TRUE)
1181-
dat$Nobs <- array(ptot, dat$Np)
1182-
}
11831178
dat$Nx <- array(length(xidx), dat$Np)
11841179
dat$Nx_between <- array(length(xidxb), dat$Np)
11851180

@@ -1210,6 +1205,10 @@ lav2standata <- function(lavobject, dosam = FALSE) {
12101205
dat$grpnum <- array(dat$grpnum, length(dat$grpnum))
12111206

12121207
if (multilevel) {
1208+
ptot <- length(unique(c(Lp[[1]]$ov.idx[[1]]))) #, Lp$ov.idx[[2]])))
1209+
dat$Obsvar <- matrix(1:ptot, dat$Np, ptot, byrow=TRUE)
1210+
dat$Nobs <- array(ptot, dat$Np)
1211+
12131212
## NB: Lp has one list entry per group
12141213
dat$nclus <- array(t(sapply(Lp, function(x) unlist(x$nclusters))), dim = c(Ng, 2))
12151214
## these are in one vector to avoid ragged arrays in Stan. We need ncluster_sizes to decide

0 commit comments

Comments
 (0)