Dear all,
I am new to SEM and lavaan.
In my model, I have four exogenous variables and I would like to add correlation between some of them.
The script is below :
model5='
#latent variable
Health_L =~ health+ physical_health+ time_hosp+ night+ annuel_visi_cate
# Regression operator
Health_L ~ a*gender+n*marital_status+e*age+m*owners+i*nationality+k* income
#Meditor
marital_status ~ d*age+ g*nationality + b*gender
owners ~ c*gender+f*age+ h*nationality+ l*marital_status+ j*income
# covariance
health ~~ physical_health
physical_health ~~ time_hosp
physical_health ~~ night
health ~~ time_hosp
health ~~ night
time_hosp ~~ night
#delete correlation
income ~~ 0*nationality # No covariance between income and nationality
gender ~~ 0*nationality #No covariance between gender and nationality
age ~~ 0*gender #No covariance between gender and age
age ~~ 0*nationality
#Correlation
income~~ nationality
income~~ age
income~~ gender
#indirect effect:
# Marital_status:
bn:=b*n # Gender
dn:=d*n #Age
gn:=g*n #Nationality
#Owners:
cm:= c*m #gendre
fm:= f*m #Age
hm:= h*m #nationality
jm:= j*m #Income
#matial_status/owners:
blm:= b*l*m #gender
dlm:= d*l*m #Age
glm := g*l*m #nationality
#Total effect
total:= a+e+n+m+i+k+(b*n)+(d*n)+(g*n)+(c*m)+(f*m)+(h*m)+(j*m)+(b*l*m)+(d*l*m)+(g*l*m)
'
Warning messages:
1: In lav_data_full(data = data, group = group, cluster = cluster, :
lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate
2: In muthen1984(Data = X[[g]], ov.names = ov.names[[g]], ov.types = ov.types, :
lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
varTable(data_comp)
name idx nobs type exo user mean var nlev lnam
1 X 1 22351 numeric 0 0 272777.493 1.610155e+10 0
2 hid 2 22351 numeric 0 0 254213.133 3.321329e+10 0
3 pid 3 22351 numeric 0 0 2486966.875 3.435039e+12 0
4 pnr 4 22351 numeric 0 0 1.760 1.051000e+00 0
5 year_birth 5 22351 numeric 0 0 1954.827 2.993560e+02 0
6 gender 6 22351 numeric 0 0 1.520 2.500000e-01 0
7 nationality 7 22351 numeric 0 0 1.092 8.400000e-02 0
8 marital_status 8 22350 numeric 0 0 0.617 2.360000e-01 0
9 horse 9 22351 numeric 0 0 0.011 1.100000e-02 0
10 dog 10 22351 numeric 0 0 0.148 1.260000e-01 0
11 cat 11 22351 numeric 0 0 0.171 1.420000e-01 0
12 birds 12 22351 numeric 0 0 0.077 7.100000e-02 0
13 fish 13 22351 numeric 0 0 0.063 5.900000e-02 0
14 others 14 22351 numeric 0 0 0.090 8.200000e-02 0
15 none 15 22186 numeric 0 0 13.158 1.163490e+02 0
16 employement_status 16 22351 ordered 0 0 NA NA 5 1|2|3|4|5
17 income 17 21971 numeric 0 0 7.491 5.031000e+00 0
18 trainig_req 18 21986 numeric 0 0 0.206 4.270000e-01 0
19 health 19 22320 ordered 0 0 NA NA 5 1|2|3|4|5
20 physical_health 20 22277 ordered 0 0 NA NA 3 1|2|3
21 legally_handicap 21 22256 factor 0 0 NA NA 2 1|2
22 handicap_extend 22 22289 numeric 0 0 6.373 4.029230e+02 0
23 visit_doctor 23 22351 numeric 0 0 2.677 1.975800e+01 0
24 visit_hosp 24 22282 numeric 0 0 1.879 1.060000e-01 0
25 N_time_hosp 25 22313 numeric 0 0 0.162 2.950000e-01 0
26 N_night_hosp 26 22342 numeric 0 0 1.752 6.967400e+01 0
27 summation 27 22351 numeric 0 0 13.622 1.027970e+02 0
28 owners 28 22186 numeric 0 0 0.402 2.400000e-01 0
29 age 29 22351 numeric 0 0 46.173 2.993560e+02 0
30 handicap 30 22289 factor 0 0 NA NA 3 0|1|2
31 time_hosp 31 22309 ordered 0 0 NA NA 3 0|1|2
32 night 32 22341 ordered 0 0 NA NA 3 0|1|2
33 annuel_visit 33 22351 numeric 0 0 10.708 3.161330e+02 0
34 annuel_visi_cate 34 22351 numeric 0 0 1.037 6.640000e-01 0
35 age_cate 35 22351 ordered 0 0 NA NA 5 0|1|2|3|4
I don´t know how to fix it ?
Any suggestions are welcome
Thank you so much.
Best regards