Skip to content

Commit

Permalink
fix blavPredict when newdata is supplied with type="ov" or "ypred"
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmerkle committed Jun 23, 2024
1 parent e61ffa6 commit b420569
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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-5.1289
Version: 0.5-5.1290
Authors@R: c(person(given = "Edgar", family = "Merkle",
role = c("aut", "cre"),
email = "[email protected]",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

* Bugs from 0.5-4 are fixed.

## Bugs/glitches discovered after the release:
* On some systems, blavaan installation fails with a "parser failed badly" message from rstan (reported by Larry Hunsicker).

* blavPredict(, type="ov"/"ypred") can fail when the sample size of newdata differs from the sample size of the original data (reported by Niels Skovgaard-Olsen).

# Version 0.5-4
## New features
* New function sampleData() for generating data from a blavaan object.
Expand Down
5 changes: 5 additions & 0 deletions R/blav_predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ blavPredict <- function(object, newdata = NULL, type = "lv", level = 1L) {
if(!stantarget) stop("blavaan ERROR: newdata is currently only available for target='stan'")
if(lavInspect(object, "categorical")) stop("blavaan ERROR: newdata is not yet available for ordinal data.")
object <- blav_fill_newdata(object, newdata)

blavsamplestats <- object@SampleStats
blavdata <- object@Data
standata <- object@external$mcmcdata
}


Expand Down Expand Up @@ -138,6 +142,7 @@ blav_fill_newdata <- function(object, newdat, lvs = TRUE) {
ov.names.x = olddata@ov.names.x,
ordered = OV$names[ OV$type == "ordered" ],
lavoptions = object@Options, allow.single.case = TRUE)
object@SampleStats@ntotal <- NROW(newdat)

## Stan-formatted newdata
l2s <- lav2stanmarg(object, dp = blavInspect(object, 'options')$dp,
Expand Down

0 comments on commit b420569

Please sign in to comment.