# How do I compare group means on latent factors?

146 views

### Brandon Bretl

May 13, 2019, 8:15:43 PM5/13/19
to lavaan
After confirming metric and scalar invariance, I want to compare groups based on their factor means, i.e., I want to get factor means for each group. How do I do this in lavaan?

I think I need to set the latent factor mean to 0 in one group and allow it to vary in the other(s), but I'm not sure how to do this.

### Christopher David Desjardins

May 13, 2019, 8:49:07 PM5/13/19
to lavaan
Hi Brandon,

There are several ways you could do this with lavaan. But I would recommend using effects coding as described here: http://www.agencylab.ku.edu/~agencylab/manuscripts/(Little,%20Slegers,%20Card,%202006).pdf

That does the effects coding in that paper (go to line 221). That way you will estimate the means for each group.

You could also do a simple contrast, as you've described, which is the default way lavaan does this (I believe), by setting one group as the reference group.

Chris

On Mon, May 13, 2019 at 7:15 PM Brandon Bretl <bre...@gmail.com> wrote:
After confirming metric and scalar invariance, I want to compare groups based on their factor means, i.e., I want to get factor means for each group. How do I do this in lavaan?

I think I need to set the latent factor mean to 0 in one group and allow it to vary in the other(s), but I'm not sure how to do this.

--
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.

### Brandon Bretl

May 13, 2019, 9:23:18 PM5/13/19
to lavaan
Thanks, Chris! This is all very useful, but I wonder if there is a simpler way.... I'm wondering how I can manipulate the factor mean in one group but not the others... ideally using the cfa function and group = "" command...

Brandon

On Monday, May 13, 2019 at 7:49:07 PM UTC-5, Christopher David Desjardins wrote:
Hi Brandon,

There are several ways you could do this with lavaan. But I would recommend using effects coding as described here: http://www.agencylab.ku.edu/~agencylab/manuscripts/(Little,%20Slegers,%20Card,%202006).pdf

That does the effects coding in that paper (go to line 221). That way you will estimate the means for each group.

You could also do a simple contrast, as you've described, which is the default way lavaan does this (I believe), by setting one group as the reference group.

Chris

On Mon, May 13, 2019 at 7:15 PM Brandon Bretl <bre...@gmail.com> wrote:
After confirming metric and scalar invariance, I want to compare groups based on their factor means, i.e., I want to get factor means for each group. How do I do this in lavaan?

I think I need to set the latent factor mean to 0 in one group and allow it to vary in the other(s), but I'm not sure how to do this.

--
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 lav...@googlegroups.com.

### Christopher David Desjardins

May 13, 2019, 10:28:17 PM5/13/19
to lavaan

Doesn’t this do what you want?

``````HS.model <- '  visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9 '
fit <- cfa(HS.model,
data = HolzingerSwineford1939,
group = "school")
summary(fit)
``````

You’ll notice Pasteur is the reference group and Grant-White is the focal group and that Pastuer’s means are zeroes on the factors, while Grant-White’s means are estimated and correspond to the difference between the two schools (i.e., Grant is higher on textual, lower on speed, and there is no difference on visual if you use a cutoff of .05).

Chris

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.

### Brandon Bretl

May 13, 2019, 10:49:57 PM5/13/19
to lavaan
YES! I think that's it. So now I'm looking at the intercepts as the means. So there is significant difference between groups in all my factor means except "lib" (liberty). Thanks!

Brandon

`Intercepts:                                              Estimate      Std.Err        z-value        P(>|z|)         Std.lv          Std.all      cpa               0.346    0.042    8.245    0.000    0.717    0.717    cph               0.436    0.058    7.545    0.000    0.682    0.682    ce                0.125    0.023    5.349    0.000    0.365    0.365    just              0.148    0.040    3.698    0.000    0.273    0.273    lib               0.023    0.040    0.587    0.557    0.039    0.039    auth              0.212    0.033    6.391    0.000    0.415    0.415    loya              0.090    0.031    2.912    0.004    0.195    0.195    sanc              0.209    0.047    4.470    0.000    0.380    0.380`

Brandon

### Christopher David Desjardins

May 13, 2019, 10:57:31 PM5/13/19
to lavaan
On Mon, May 13, 2019 at 9:50 PM Brandon Bretl <bre...@gmail.com> wrote:
YES! I think that's it. So now I'm looking at the intercepts as the means. So there is significant difference between groups in all my factor means except "lib" (liberty). Thanks!

That's right.  Whatever the focal group is is higher on these factors than the reference group except for lib.

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.

### Terrence Jorgensen

May 14, 2019, 10:26:41 AM5/14/19
to lavaan
I need to set the latent factor mean to 0 in one group and allow it to vary in the other(s), but I'm not sure how to do this.

When the argument group.equal includes "intercepts", latent means will be free in all but the first group by default.  If you restrict intercepts to equality by giving them the same labels, then you need to free the latent means in your syntax;

`x1 ~ c(int1, int1)*1 # restrict indicator intercepts across groupsx2 ~ c(int2, int2)*1...factor ~ c(0, NA)*1 # free second group's latent mean`

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam