Skip to content

lavaan: how to analyse residuals of a latent variable

6 messages · Hans Ekbrand, yrosseel

#
Hi r-help,

I use lavaan:sem() for structural equation modelling with latent
variables. Below is a reproducible example (the code requires a
working installation of lavaan) where the latent variable criminality
is in focus. Besides criminality in general, I am specifically
interested one of the manifest variables that make up the latent
variable criminality, namely fire.setting.

My question is: how can I analyse the part of the variation in
fire.setting that is not included in the latent variable criminality?
Ideally I would want a new variable that captures just this. Then I
could model regressions with this variable as the dependent variable.

As far as I understand the output of the summary() - of which I have
reproduced a few lines - about half (0.499) of the variation in
fire.setting is included in the latent variable criminality.

                   Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all
Latent variables:
  criminality =~
    fire.setting      0.324    0.007   48.223    0.000    0.189    0.499


I would like to analyse the "other half" of fire.setting, so to speak.


my.model <- "
## Measurement model (definitions of the latent variables)
priviledged.parents =~ nr.parents.employed + parental.housing

school.adaption =~ enjoying.school + good.teachers +
                   good.grades.important

school.grades =~ grade.language + grade.english + grade.craft +
                 grade.math + grade.chemistry + grade.arts +
                 grade.sports

criminality =~ vandalism + illegal.grafitti + shop.lifting +
               theft.from.automat + theft.from.school +
               theft.of.bicycle + theft.of.moped + theft.of.car +
               theft.from.car + theft.pick.pocket + burglary +
               buying.stolen.goods + selling.stolen.goods +
               wearing.knife + robbery + fire.setting +
               abuse.unknown.persons + abuse.family.members +
               used.knife + drugs.cannabis + drugs.other +
               drugs.thinner + drugs.steroids + selling.drugs.cannabis
               + selling.drugs.other

## Regressions
priviledged.parents ~ parental.migration + parental.class

school.adaption ~ parental.migration + parental.class + sex.girl +
		  priviledged.parents

school.grades ~ parental.migration + parental.class + sex.girl +
	      	priviledged.parents

criminality ~ parental.migration + parental.class + sex.girl +
	      priviledged.parents + school.adaption + school.grades "

library(lavaan)
con <- url("http://code.cjb.net/temp/lavaan.temp.RData")
print(load(con))
close(con)
my.fit <- sem(my.model, data = my.crim.set)
summary(my.fit, fit.measures = T, standardized = T)
#
You can add a regression line to your model syntax with 'fire.setting' 
as the dependent variable:

fire.setting ~ x1 + x2 + x3

were x1-x3 are additional predictors that might influence the variable 
'fire.setting'.

Yves Rosseel
http://lavaan.org
#
On Tue, Aug 09, 2011 at 01:49:13PM +0200, yrosseel wrote:
Can I include criminality among those and thereby get the common part
of criminality and fire.setting "out of the way"?

I tried adding the following regression formula:

fire.setting ~ parental.migration + parental.class + sex.girl + 
	       priviledged.parents + school.adaption + school.grades +
               criminality

but I got:

Error in solve.default(E) :
Lapack routine dgesv: system is exactly singular 
 
[lavaan message:] could not compute standard errors! 
 
 You can still request a summary of the fit to inspect 
 the current estimates of the parameters.

However, the fit-object has regression estimates were criminality
seems to have about the same size as I would have thought, given the
covariation of fire.setting and criminality.

                   Estimate  Std.err  Z-value  P(>|z|)   Std.lv  Std.all

  fire.setting ~
    parental.migr     0.001                               0.001    0.003
    parental.clas    -0.000                              -0.000   -0.000
    sex.girl         -0.015                              -0.015   -0.019
    priviledged.p     0.066                               0.015    0.039
    school.adapti     0.004                               0.002    0.005
    school.grades    -0.012                              -0.010   -0.026
    criminality       0.327                               0.191    0.505

Are the other estimates reasonable estimates of the part of variation
in fire-setting that does not co-variate with criminality?


--
Hans Ekbrand
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110809/82718ffa/attachment.bin>
#
No. You already regress fire.setting on criminality since it is an 
indicator in the measurement model of criminality. In other words, the 
'criminality' part is already regressed out.

Yves Rosseel
http://lavaan.org
#
On Tue, Aug 09, 2011 at 03:30:17PM +0200, yrosseel wrote:
So, I get just what I want by simply regressing on fire.setting, that
is awesome!

Maybe this kind of usage of lavaan is not very common, but in order to
help others in my situation, is this documented somewhere? My
understanding of latent variable analysis is indeed limited, but I did
not understand that lavaan worked liked this when I read the
documentation.

Kind regards,

Hans Ekbrand
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110809/c64d41ef/attachment.bin>
#
This is not specific to lavaan; the same strategy would work in other 
(commercial) software as well.

But of course, lavaan needs better documentation. If only there was more 
time...

Yves Rosseel
http://lavaan.org