Hi, in my research I started with a simple model without latent variables. I have put up a model that has a good fit (P-value = 0.696). But since I have knowledge of the measurement error, I wanted to put them in. I have defined each variable as a single- indicator that controls for measurement error – see code below. But the result is - no fit. I was expecting similar results, just distinguishing the measurement error from the structural error. Did I define the model correctly with regards to measurement error? If so, why is there such significant difference in the fit?
The code below contains connection to my data in google drive so you can replicate the issue.
### models with and without measurement error
# Load the data from a csv file I have put in google drive
id<-"1BQ0Q0QUYQdYRXNVxmfs92CIPWqCKlQ4S"# google file ID
dat<-read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download",id),stringsAsFactors=FALSE)
library(lavaan)
### model a: simple model, no measurement error
mod.a <- '
NH4toTN ~ Crane_Count + Temp + pH_Outlet
Chl ~ season + NH4toTN + pH_Outlet + Temp
TDP2TP ~ Crane_Count + Chl + Temp + Rain8d
'
# Fit model
mod.a.fit <- sem(mod.a, dat)
summary(mod.a.fit, rsq=TRUE, standardized=TRUE)
# Result: good fit. P-value = 0.696
### model b: same model but add measurement error
mod.b <- '
#latent variables
NH4toTN_L =~ NH4toTN
Crane_Count_L =~ Crane_Count
Temp_L =~ Temp
Chl_L =~ Chl
pH_Outlet_L =~ pH_Outlet
TDP2TP_L =~ TDP2TP
#Regrression
NH4toTN_L ~ Crane_Count_L + Temp_L + pH_Outlet_L
Chl_L ~ season + NH4toTN_L + pH_Outlet_L + Temp_L
TDP2TP_L ~ Crane_Count_L + Chl_L + Temp_L + Rain8d
#fix error variances
NH4toTN ~~ 0.507*NH4toTN
Crane_Count ~~ 0.146*Crane_Count
Temp ~~ 0.034*Temp
Chl ~~ 0.224*Chl
pH_Outlet ~~ 0.031*pH_Outlet
TDP2TP ~~ 0.399*TDP2TP
'
# Fit model
mod.b.fit <- sem(mod.b, dat)
summary(mod.b.fit, rsq=TRUE, standardized=TRUE)
# Result: no fit.