Skip to content
Permalink
Browse files

Repair bug with RAM-regression factor scores.

The calculation of the latent-variable means did not cover the fully general case.
  • Loading branch information
RMKirkpatrick committed Jun 11, 2019
1 parent 20d986e commit 1e140484449172db22220b3e907433a8c4abed30
Showing with 3 additions and 1 deletion.
  1. +3 −1 R/MxFactorScores.R
@@ -217,6 +217,7 @@ RAMrfs <- function(model, res, minManifests) {
relevantDataCols <- c(manvars,defvars)
dat <- model@data@observed
I <- diag(length(manvars)+length(latvars))
Ilat <- diag(length(latvars))
while(i<=dim(res)[1]){
continublockflag <- ifelse(i<dim(res)[1],TRUE,FALSE)
manvars.curr <- manvars[ !is.na(dat[i,manvars]) ]
@@ -234,7 +235,8 @@ RAMrfs <- function(model, res, minManifests) {
unfilt <- solve(I-mxEvalByName("A",model,T,defvar.row=i))%*%mxEvalByName("S",model,T,defvar.row=i)%*%
t(solve(I-mxEvalByName("A",model,T,defvar.row=i)))
dimnames(unfilt) <- list(c(manvars,latvars),c(manvars,latvars)) #<--Necessary?
latmeans <- matrix(1,ncol=1,nrow=(j-i+1)) %x% matrix(mxEvalByName("M",model,T,defvar.row=i)[,latvars],nrow=1)
latmeans <- matrix(1,ncol=1,nrow=(j-i+1)) %x% t(solve(Ilat-mxEvalByName("A",model,T,defvar.row=i)[latvars,latvars]) %*%
matrix(mxEvalByName("M",model,T,defvar.row=i)[,latvars],ncol=1))
missing <- is.na(dat[i,manvars])
anyMissing <- any(missing)
if (anyMissing && is.na(minManifests)) requireMinManifests(i)

4 comments on commit 1e14048

@tbates

This comment has been minimized.

Copy link
Member

tbates replied Jun 12, 2019

Nice catch!. Does this fix apply to the LISREL expectation case as well? (Rd says that LISREL and RAM scoring is equivalent but distinct.. Just checking.

@jpritikin

This comment has been minimized.

Copy link
Member

jpritikin replied Jun 12, 2019

Hm, this sounds familiar. Wasn't this bug reported by somebody else too?

@RMKirkpatrick

This comment has been minimized.

Copy link
Contributor Author

RMKirkpatrick replied Jun 12, 2019

@tbates Nope.

@jpritikin Not that I recall...

@RMKirkpatrick

This comment has been minimized.

Copy link
Contributor Author

RMKirkpatrick replied Jun 12, 2019

FTR, this is the forums post of the user who found this bug: https://openmx.ssri.psu.edu/node/4510 .

Please sign in to comment.
You can’t perform that action at this time.