How to compute Scalar Measurement Invariance in Pythons semopy.multigroup() - Stack Overflow

I'm conducting an CFA on a pooled Dataset with 21 item-variables and a group-variable 'wave&#

I'm conducting an CFA on a pooled Dataset with 21 item-variables and a group-variable 'wave' which assigns the rows to 15 different waves of survey-inquiries (biweekly). My CFA model over the pooled Data fits well but I want to check the (longitudinal) measurement invariance over the different waves. I'm using Python and semopy and I've got no problems including the metric invariance (factorloadings are set equal) due to the fact that this is the standard option in the semopy.multigroup()-function.

But how do I get the scalar invariance (intercepts and factor loadings set equal) within semopy? I already tried to modify the model_dict and to find an option within the multigroup()-function but these solvings didn't lead me anywhere. I appreciate any help

Here is a code snippet with randomly generated data.

import pandas as pd
from scipy import stats
import semopy
from semopy.multigroup import multigroup

# Generate dataset
np.random.seed(42)
num_wave = 15
n_per_wave = 100
items = [
    "F1A5_2", "F1A10_2r", "F3A18_1", "F1A10_1", "F1A16_1r", "F1A17_1",  
    "F5A5_1", "F1A9_1", "F1A15_1", "F3A7_1", "F3A8_1", "F3A34_1",  
    "F1A17_2", "F5eA3_1", "F5eA4_1", "F5cA3_1", "F1A16_2", "F5A11_1r",  
    "F2A11", "F2A12", "F3A10_1r"
]

df_pool = pd.DataFrame({
    "wave": np.repeat(np.arange(1, num_wave + 1), n_per_wave)
})
for item in items:
    df_pool[item] = np.random.normal(3, 1, len(df_pool))


# CFA Model with Second-Order-Factors 
model_dict = """
    F1_effic =~ F1A5_2 + F1A10_2r + F3A18_1
    F21_resent =~ F1A10_1 + F1A16_1r + F1A17_1 + F5A5_1
    F22_affec =~ F1A9_1 + F1A15_1
    F4_cosmo  =~ F3A7_1 + F3A8_1 + F3A34_1
    F5_consp  =~ F1A17_2 + F5eA3_1 + F5eA4_1 + F5cA3_1 + F1A16_2 + F5A11_1r
    F6_envir =~ F2A11 + F2A12 + F3A10_1r
       
    F2_rebel =~ F21_resent + F22_affec
"""

model_multi = multigroup(model_dict, df_pool, group='wave')
print(model_multi.stats)
```

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745123828a4612574.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信