lavaan ERROR: unknown ov.types:haven_labelled

339 views
Skip to first unread message

kiki ekiawan

unread,
Oct 2, 2023, 9:53:29 AM10/2/23
to lavaan
Hi everyone, 

I have a problem encountered while running SEM in R. I saw a previous thread about it, but the problem cause a little bit different. in my case, I was able to run my model successfully when I treated my variables with numerical data, however, some of my variables were categorical (ordinal and nominal) and it's resulted error as follows: 

Error in lav_samplestats_step1(Y = Data, wt = wt, ov.names = ov.names,  :
  lavaan ERROR: unknown ov.types:haven_labelled
In addition: Warning message:
In lav_data_full(data = data, group = group, cluster = cluster,  :
  lavaan WARNING: exogenous variable(s) declared as ordered in data: Age_group Female_male Income Education

I did try to erase my value label from spss dataset and imported back, and I also use: sapply(diss_data, haven::zap_labels)  and sapply(diss_data, haven::as_factor). But still they are not successful to run.

This is my syntax: 

testmodel2DatasetOCT_SES<- '
# measurement model
RegulatingESy1=~ be_air_quality_lik + be_water_quality_erosion_lik+
  be_temperature_reduction_lik+ be_space_for_plants_animals_lik+
  be_noise_reduction_lik+ be_carbon_storage_climate_lik+
  be_natural_hazards_lik
ProvisioningESy2=~ be_other_products_lik+be_wood_lik+be_fuel_lik+be_hunting_lik
CulturalESy3 =~ be_human_health_wellbeing_lik+be_education_lik+be_cultural_emotional_spiritual_lik+
  be_jobs_economy_lik+ be_recreation_sport_lik+be_beauty_lik

#regression
RegulatingESy1~ Age_group+Female_male+Income+Education+Rurality+UN_geoscheme
ProvisioningESy2 ~ Age_group+Female_male+Income+Education +Rurality+UN_geoscheme
CulturalESy3 ~ Age_group+Female_male+Income+Education +Rurality+UN_geoscheme '

fitModeltest2SES_FES<- sem(testmodel2DatasetOCT_SES, data = DatasetCH_K2_exported_OCT23)


I hope to gain insight from the advanced people here. 

Thanks so much, 
Eki

Yago Luksevicius de Moraes

unread,
Oct 3, 2023, 11:22:39 AM10/3/23
to lavaan

Hi, Eki,

lavaan cannot use the thresholds of uncorrelated ordinal variables.
The easiest way to solve this problem is to make these variables correlate with something. For instance, add the line

Age_group~~Female_male+Income+Education

in your model may solve the problem.

Best regards,
Yago

Reply all
Reply to author
Forward
0 new messages