Definition variable for mean regression not working in WLS
Posted on

Attachment | Size |
---|---|
WLS_defitionvar_not_working.R | 960 bytes |
Forums
Hi,
The use of definition variable for regression in means model is not working for me when using WLS. Think it was supposed to work from version 2.12 and onwards, but I haven't gotten it to work. I haven't tried different platforms or software configs, so maybe it has something to do with these.
The use of definition variable for regression in means model is not working for me when using WLS. Think it was supposed to work from version 2.12 and onwards, but I haven't gotten it to work. I haven't tried different platforms or software configs, so maybe it has something to do with these.
Attached is an example where it fails (but the ML-fitfunction works fine).
Here's my sessionInfo():
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] OpenMx_2.13.2
loaded via a namespace (and not attached):
[1] MASS_7.3-50 compiler_3.4.1 Matrix_1.2-10 parallel_3.4.1 tools_3.4.1 Rcpp_0.12.17 grid_3.4.1 digest_0.6.12
[9] lattice_0.20-35
what is latent?
Log in or register to post comments
In reply to what is latent? by jpritikin
Aha!
This was not clear from the release comments, but makes perfect sense to me now!
Thanks for quick response.
Log in or register to post comments
In reply to what is latent? by jpritikin
Definition variable: Exactly where and how?
I cannot seem to understand exactly how I do get the definition variables to work in the LISREL model using WLS, do you have a working example? (RAM isn't flexible enough for the implementations I'm considering.)
The only info I can find is from the 2.12 release: " Third, the WLS fitfunction is now compatible with exogenous covariates. That is, you can now use WLS if your model contains definition variables, as long as those definition variables are only involved in the model for the endogenous variables' means. "
"Endogenuous variables' means", does that mean the mean the model for eta ('alpha' in the latent variable equation)? Or does it imply the indicators of eta ('tau_y' in the measurement equation for endogoneous variables)? I've tried including the definition variable to work on the mean in both those places (i.e., alpha or tau_y), but doesn't work for me (works fine using ML fit function).
Am I misunderstanding some central concept? Like, should definition variables not be intered as "data.variablename"? Or something about the dimnames I've entered?
Would be glad to get some feedback since definition variable adjustment (to be used for simple regressions for expected means/thresholds) in WLS would save me a lot of optimization time, especially now when the WLS is so quick (and ML often fails when many ordinal variables are included).
Here's some code where I tried to use definition variable, entered as "data.u", covariate for regression.
# Generate data
N <- 1000
u <- rbinom(N,1,.4)
y <- -.2*u + rnorm(N,0,1)+1
dat <- data.frame( y,u )
summary(lm(y~u,data=dat))
lismod <- mxModel( 'LISRELmodel' ,
# Definition variable and regression coefficient
mxMatrix('Full',1,1,free=T,values=-.02,name='BU' , dimnames=list('y',NA) ),
mxMatrix('Full',1,1,labels='data.u', name='U' , dimnames=list('y',NA) ),
# Manifest endogenuous variable
mxMatrix('Full',1,1,free=T,values=1, name='M' , dimnames=list('y',NA) ),
mxAlgebra( M, name='Tau_y' , dimnames=list('y','y') ),
#mxAlgebra( M+BU*U, name='Tau_y' ,
# dimnames=list(c('y'),NA) ), # IF definition variable used on manifest variable
# Endogenuous latent variable mean
mxMatrix('Full',1,1,free=F,values=0,labels='am',name='Alpha' ,
dimnames=list(c('Fa'),NA) ),
mxAlgebra( Alpha+BU*U, name='Alpha_M' , dimnames=list('Fa','u') ),
# Loading from latent engenuous to manifest
mxMatrix('Full',1,1,free=F,values=1,name='LambdaY' ,
dimnames=list(c('y'),c('Fa') ) ),
# Covariance of latent endogenuous
mxMatrix('Full',1,1,free=T,values=c(1),name='Psi',
dimnames=list(c('Fa'),c('Fa') ) ),
# Latent variable equation
mxMatrix('Full',1,1,free=F,values=c(0),name='Beta',
dimnames=list(c('Fa'),c('Fa') ) ),
# Residual Variance of manifest variable
mxMatrix('Full',1,1,free=F,values=0,name='ThetaEps'),
# Data
mxData( dat[, c('y','u') ], type='raw' ) ,
mxExpectationLISREL(LY='LambdaY', PS='Psi',TE='ThetaEps',TY = 'Tau_y', AL = 'Alpha_M', BE='Beta',
LX=NA,GA=NA, PH=NA, TD=NA, TH=NA,TX = NA, KA = NA ),
mxFitFunctionWLS( type='WLS' , allContinuousMethod='marginals' )
)
# Doesn't work:
lismodFit <- mxRun( lismod )
summary( lismodFit )
# Works fine:
lismod$fitfunction <- mxFitFunctionML()
lismodFit <- mxRun( lismod )
summary( lismodFit )
Log in or register to post comments
In reply to Definition variable: Exactly where and how? by iloo
not sure yet
Log in or register to post comments
In reply to Definition variable: Exactly where and how? by iloo
I'm sorry the release
Log in or register to post comments
In reply to Definition variable: Exactly where and how? by iloo
TY
Log in or register to post comments
In reply to TY by jpritikin
solved?
Log in or register to post comments