phantom variables

360 views
Skip to first unread message

ya

unread,
Jun 27, 2015, 8:45:45 AM6/27/15
to lav...@googlegroups.com
Dear list,

I am trying to add phantom variables to the weak invariance model with categorical indicators. With or without phantom variables, the models worked fine, however, the model with phantom variables had 6 more df. Could you give me some suggestions on what I missed please? Thank you very much. Please see my code below:

Without phatom variables:

crossmod="
#measurement model
bul1=~bul1_1+bul2_1+bul3_1+bul4_1+bul5_1+bul6_1
bul2=~bul1_2+bul2_2+bul3_2+bul4_2+bul5_2+bul6_2
bul3=~bul1_3+bul2_3+bul3_3+bul4_3+bul5_3+bul6_3
"
fitweakinvar=sem(crossmod,data=grades1to9,missing="pairwise",group="Boy",group.equal=c("loadings"),
ordered=c("bul1_1","bul2_1","bul3_1","bul4_1","bul5_1","bul6_1",
          "bul1_2","bul2_2","bul3_2","bul4_2","bul5_2","bul6_2",
          "bul1_3","bul2_3","bul3_3","bul4_3","bul5_3","bul6_3")
                )
summary(fitweakinvar,fit.measures=T,standardized=T)

lavaan (0.5-18) converged normally after  32 iterations
 
                                                  Used       Total
  Number of observations per group
  0                                              15666       17627
  1                                              15395       18007
 
  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic             2576.839    2668.714
  Degrees of freedom                               279         279
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  1.004
  Shift parameter for each group:
    0                                                       51.777
    1                                                       50.881
    for simple second-order correction (Mplus variant)


With phantom variables:

> crossmodphan="#when latent var is not equal across groups
+ #measurement model
+ bul1=~bul1_1+bul2_1+bul3_1+bul4_1+bul5_1+bul6_1
+ bul2=~bul1_2+bul2_2+bul3_2+bul4_2+bul5_2+bul6_2
+ bul3=~bul1_3+bul2_3+bul3_3+bul4_3+bul5_3+bul6_3
+ #structure model
+ bul1ph=~bul1;bul2ph=~bul2;bul3ph=~bul3;
+ bul1~~0*bul1;bul2~~0*bul2;bul3~~0*bul3;
+ bul1ph~~1*bul1ph;bul2ph~~1*bul2ph;bul3ph~~1*bul3ph;
+ bul1~~0*bul2;bul1~~0*bul3;bul2~~0*bul3;
+ bul1~~0*bul1ph;bul1~~0*bul2ph;bul1~~0*bul3ph;bul2~~0*bul1ph;bul2~~0*bul2ph;bul2~~0*bul3ph;bul3~~0*bul1ph;bul3~~0*bul2ph;bul3~~0*bul3ph;
+ bul1ph~~bul2ph;bul1ph~~bul3ph;bul2ph~~bul3ph;
+ bul1~0*1;bul2~0*1;bul3~0*1;bul1ph~0*1;bul2ph~0*1;bul3ph~0*1;
+ "
> fitlatentcovinvarphan=sem(crossmodphan,data=grades1to9,missing="pairwise",group="Boy",group.equal=c("loadings"),
+ ordered=c("bul1_1","bul2_1","bul3_1","bul4_1","bul5_1","bul6_1",
+           "bul1_2","bul2_2","bul3_2","bul4_2","bul5_2","bul6_2",
+           "bul1_3","bul2_3","bul3_3","bul4_3","bul5_3","bul6_3")
+                 )

lavaan (0.5-18) converged normally after  14 iterations

                                                  Used       Total
  Number of observations per group         
  0                                              15666       17627
  1                                              15395       18007

  Estimator                                       DWLS      Robust
  Minimum Function Test Statistic             7701.290    5856.872
  Degrees of freedom                               285         285
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  1.345
  Shift parameter for each group:
    0                                                       66.157
    1                                                       65.013
    for simple second-order correction (Mplus variant)





ya

Edward Rigdon

unread,
Jun 27, 2015, 9:57:53 AM6/27/15
to lav...@googlegroups.com
In the phantom variable (pv) code, the variances of your 3 factors are fixed, but in the no-pv code they are free.  In the pv code, intercepts of the 3 factors are set to 0, while in the no-pv code, they are not constrained.  You are using the Sem function, so you could say that auto-constraints are really responsible for the 3+3 = 6 additional free parameters.
--Ed Rigdon

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

ya

unread,
Jun 27, 2015, 10:37:53 AM6/27/15
to lav...@googlegroups.com
Dear Ed,

Thank you very much for the response. I have checked the output of both models, the intercept of the three factors were fixed at 0 in both models. The variances for the factors were fixed at 0 and for the phantom variables at 1 as intended so that the latent covariance can be standardized(if I understand right). So maybe there are some other reasons about these 6 df? 

I noticed that the varianceS of the first indicator of each factor were fixed at 0 in all groups in the phantom variable model, whereas they were freely estimated in the non-phantom variable model. Which seems like 3*2=6?

Best regards,


ya

Terrence Jorgensen

unread,
Jun 29, 2015, 8:49:44 AM6/29/15
to lav...@googlegroups.com
I noticed that the varianceS of the first indicator of each factor were fixed at 0 in all groups in the phantom variable model, whereas they were freely estimated in the non-phantom variable model. Which seems like 3*2=6?

In the PhantomVar code, the residual variances of the first indicators are fixed to zero?  I don't think that should happen, so that sounds like the discrepancy in df.  If that's what you meant, try manually freeing them in the syntax, because they should not be constrained.

Terry

ya

unread,
Jun 29, 2015, 9:19:09 AM6/29/15
to lavaan
Dear Terry,

Thank you very much for the response. 

I manually freed the residual variances of the first indicators in the phantom variable model, but they are still 0 in both groups. Besides, the residual variances were somehow constrained to be equal across groups although I only asked for weak invariance. It seems something is wrong in the model. Please see the code and the residual variance part of the output below:

crossmodphan="#when latent var is not equal across groups
#measurement model
bul1=~bul1_1+bul2_1+bul3_1+bul4_1+bul5_1+bul6_1
bul2=~bul1_2+bul2_2+bul3_2+bul4_2+bul5_2+bul6_2
bul3=~bul1_3+bul2_3+bul3_3+bul4_3+bul5_3+bul6_3
#structure model
bul1ph=~bul1;bul2ph=~bul2;bul3ph=~bul3;
bul1~~0*bul1;bul2~~0*bul2;bul3~~0*bul3;
bul1ph~~1*bul1ph;bul2ph~~1*bul2ph;bul3ph~~1*bul3ph;
bul1~~0*bul2;bul1~~0*bul3;bul2~~0*bul3;
bul1~~0*bul1ph;bul1~~0*bul2ph;bul1~~0*bul3ph;bul2~~0*bul1ph;bul2~~0*bul2ph;bul2~~0*bul3ph;bul3~~0*bul1ph;bul3~~0*bul2ph;bul3~~0*bul3ph;
bul1ph~~bul2ph;bul1ph~~bul3ph;bul2ph~~bul3ph;
bul1~0*1;bul2~0*1;bul3~0*1;bul1ph~0*1;bul2ph~0*1;bul3ph~0*1;
bul1_1~~bul1_1;bul1_2~~bul1_2;bul1_3~~bul1_3 # freely estimate the residual variance

"
fitlatentcovinvarphan=sem(crossmodphan,data=grades1to9,missing="pairwise",group="Boy",group.equal=c("loadings"),
ordered=c("bul1_1","bul2_1","bul3_1","bul4_1","bul5_1","bul6_1",
"bul1_2","bul2_2","bul3_2","bul4_2","bul5_2","bul6_2",
"bul1_3","bul2_3","bul3_3","bul4_3","bul5_3","bul6_3")
)
summary(fitlatentcovinvarphan,fit.measures=T,standardized=T)

Group 1 [0]:
Variances:
    bul1              0.000                               0.000    0.000
    bul2              0.000                               0.000    0.000
    bul3              0.000                               0.000    0.000
    bul1ph            1.000                               1.000    1.000
    bul2ph            1.000                               1.000    1.000
    bul3ph            1.000                               1.000    1.000
    bul1_1            0.000                               0.000    0.000
    bul1_2            0.000                               0.000    0.000
    bul1_3            0.000                               0.000    0.000
    bul2_1            0.598                               0.598    0.598
    bul3_1            0.438                               0.438    0.438
    bul4_1            0.409                               0.409    0.409
    bul5_1            0.292                               0.292    0.292
    bul6_1            0.305                               0.305    0.305
    bul2_2            0.476                               0.476    0.476
    bul3_2            0.372                               0.372    0.372
    bul4_2            0.308                               0.308    0.308
    bul5_2            0.277                               0.277    0.277
    bul6_2            0.228                               0.228    0.228
    bul2_3            0.398                               0.398    0.398
    bul3_3            0.305                               0.305    0.305
    bul4_3            0.222                               0.222    0.222
    bul5_3            0.128                               0.128    0.128
    bul6_3            0.172                               0.172    0.172


Group 2 [1]:
Variances:
    bul1              0.000                               0.000    0.000
    bul2              0.000                               0.000    0.000
    bul3              0.000                               0.000    0.000
    bul1ph            1.000                               1.000    1.000
    bul2ph            1.000                               1.000    1.000
    bul3ph            1.000                               1.000    1.000
    bul1_1            0.000                               0.000    0.000
    bul1_2            0.000                               0.000    0.000
    bul1_3            0.000                               0.000    0.000
    bul2_1            0.598                               0.598    0.598
    bul3_1            0.438                               0.438    0.438
    bul4_1            0.409                               0.409    0.409
    bul5_1            0.292                               0.292    0.292
    bul6_1            0.305                               0.305    0.305
    bul2_2            0.476                               0.476    0.476
    bul3_2            0.372                               0.372    0.372
    bul4_2            0.308                               0.308    0.308
    bul5_2            0.277                               0.277    0.277
    bul6_2            0.228                               0.228    0.228
    bul2_3            0.398                               0.398    0.398
    bul3_3            0.305                               0.305    0.305
    bul4_3            0.222                               0.222    0.222
    bul5_3            0.128                               0.128    0.128
    bul6_3            0.172                               0.172    0.172



ya

Yves Rosseel

unread,
Jul 16, 2015, 5:44:40 AM7/16/15
to lav...@googlegroups.com
Two general comments:

1) study the parameter table of both models. There you should be able to
spot any discrepancies.

2) when using phantom variables, I would prefer to use the lavaan() function

Yves.

ya

unread,
Jul 17, 2015, 1:47:27 PM7/17/15
to lavaan
Dear Yves,

Thank you very much for the suggestions. Now I have three follow up questions:

1. I have located the problem using parTable(). The loading of the three latent variables on the phantom variables were fixed at 1 by default. I think this is for the identification purpose as the latent variable was the only "indicator" for the phantom variable, right?

2. I tried to free the loadings by:

bul1ph=~NA*bul1;bul2ph=~NA*bul2;bul3ph=~NA*bul3;

although the loadings were freely estimated, they were still constrained to be equal across groups. Is it because I asked for the weak invariance (group.equal=c(loadings))?

3. How could the loadings of the latent variables on the phantom variables be freely estimated and not constrained to be equal across groups? I have 3 phantom variables, I think this is why there were 6 more DF in the phantom model than in the weak invariance model. 3 loadings * 2 groups = 6.

Please find my code below and give me some suggestions (with this code, there were only 3 more DF):

crossmodphan="#when latent var is not equal across groups
#measurement model
bul1=~bul1_1+bul2_1+bul3_1+bul4_1+bul5_1+bul6_1
bul2=~bul1_2+bul2_2+bul3_2+bul4_2+bul5_2+bul6_2
bul3=~bul1_3+bul2_3+bul3_3+bul4_3+bul5_3+bul6_3
#structure model
bul1ph=~NA*bul1;bul2ph=~NA*bul2;bul3ph=~NA*bul3;

bul1~~0*bul1;bul2~~0*bul2;bul3~~0*bul3;
bul1ph~~1*bul1ph;bul2ph~~1*bul2ph;bul3ph~~1*bul3ph;
bul1~~0*bul2;bul1~~0*bul3;bul2~~0*bul3;
bul1~~0*bul1ph;bul1~~0*bul2ph;bul1~~0*bul3ph;bul2~~0*bul1ph;bul2~~0*bul2ph;bul2~~0*bul3ph;bul3~~0*bul1ph;bul3~~0*bul2ph;bul3~~0*bul3ph;
bul1ph~~bul2ph;bul1ph~~bul3ph;bul2ph~~bul3ph;
bul1~0*1;bul2~0*1;bul3~0*1;bul1ph~0*1;bul2ph~0*1;bul3ph~0*1;#no need for means in weak invariance model
"
fitlatentcovinvarphan=sem(crossmodphan,data=grades1to9,missing="pairwise",group="Boy",group.equal=c("loadings"),
ordered=c("bul1_1","bul2_1","bul3_1","bul4_1","bul5_1","bul6_1",
          "bul1_2","bul2_2","bul3_2","bul4_2","bul5_2","bul6_2",
          "bul1_3","bul2_3","bul3_3","bul4_3","bul5_3","bul6_3")
                )

Best regards,



ya

Terrence Jorgensen

unread,
Jul 18, 2015, 6:51:04 AM7/18/15
to lav...@googlegroups.com
1. I have located the problem using parTable(). The loading of the three latent variables on the phantom variables were fixed at 1 by default. I think this is for the identification purpose as the latent variable was the only "indicator" for the phantom variable, right?

They won't be fixed by default if you use the lavaan() function instead of the sem() function, as Yves suggested you should do.

2. I tried to free the loadings by:

bul1ph=~NA*bul1;bul2ph=~NA*bul2;bul3ph=~NA*bul3;

although the loadings were freely estimated, they were still constrained to be equal across groups. Is it because I asked for the weak invariance (group.equal=c(loadings))?

There are two groups, so specify NA for both groups:

bul1ph =~ c(NA, NA)*bul1

Again, use the lavaan() function, so you can specify all fixed/free parameters (and equality constraints) using the model syntax instead of the "group.equal" argument.  That way, you'll know exactly what model you are fitting.

Terry

ya

unread,
Jul 18, 2015, 7:12:47 AM7/18/15
to lavaan
Dear Terry,

Thank you very much for the response.

I tried this 

bul1ph=~c(NA,NA)*bul1;bul2ph=~c(NA,NA)*bul2;bul3ph=~c(NA,NA)*bul3;

Got an error:

Error in getModifier(rhs[[2L]]) :
  lavaan ERROR: can not parse modifier:cNANA




ya
 
Date: 2015-07-18 13:51
To: lavaan
Subject: Re: Re: phantom variables
1. I have located the problem using parTable(). The loading of the three latent variables on the phantom variables were fixed at 1 by default. I think this is for the identification purpose as the latent variable was the only "indicator" for the phantom variable, right?

Yves Rosseel

unread,
Jul 20, 2015, 8:04:33 AM7/20/15
to lav...@googlegroups.com
On 07/18/2015 01:12 PM, ya wrote:
> Dear Terry,
>
> Thank you very much for the response.
>
> I tried this
>
> bul1ph=~c(NA,NA)*bul1;bul2ph=~c(NA,NA)*bul2;bul3ph=~c(NA,NA)*bul3;
>
> Got an error:
>
> Error in getModifier(rhs[[2L]]) :
> lavaan ERROR: can not parse modifier:cNANA

Yes. That is a bug in the parser of 0.5-18 (actually due to change in
R). This is already fixed in dev 0.5-19.

But if you are using the lavaan() function, you can just write

bul1ph =~ bul1; bul2ph =~ bul2; bul3ph =~ bul3

and the means/intercepts will be free in all groups.

Yves.

ya

unread,
Jul 20, 2015, 9:55:57 AM7/20/15
to lavaan
Dear Yves and Teery,

Thank you very much for all the suggestions.

The reason I did not use lavaan() is because I am not quite sure about myself on all the parameters I should specify. I still need more practice to get deeper understanding about the whole SEM modeling. For now, I am worred I may get the DF more wrong by using lavaan().  However, I actually found a way to solve the problem by using NA* multiplication in combination with the group.partial arguement. So now I have got the correct DF for both of my models. Thank you very much for all the help.

Best regards,


ya
 
Date: 2015-07-20 15:04
To: lavaan
Subject: Re: phantom variables
Reply all
Reply to author
Forward
0 new messages