Op dit moment is er alleen code om de resultaten van 1 hypothese vs zijn complement te bepalen en niet voor een set van hypotheses. Toen ik het deed voor meer dan een hypothese, dan geeft het wel output. Op zich geeft het de output met de unconstrained, alleen is er geen melding dat dit gebeurd en daarnaast staat er in de output ook dat het de complement is...
Kan je een foutmelding inbouwen. Als je daarnaast ook de resultaten wilt geven met de unconstrained dan moet de hypothese daar aangepast worden (niet Hc en ook niet de omschrijving - zie hieronder).
Hieronder vind je code en output.
Load the gorica and lavaan libraries.
if (!require("gorica")) install.packages("gorica") # install this package first (once)
if (!require("lavaan")) install.packages("lavaan") # install this package first (once)
library(gorica)
library(lavaan)
Specify the latent regression model
model2 <- '
A =~ Ab + Al + Af + An + Ar + Ac
B =~ Bb + Bl + Bf + Bn + Br + Bc
A ~ B + age + peabody
'
Fit the latent regression model using the lavaan sem function
fit2 <- sem(model2, data = sesamesim, std.lv = TRUE)
Op dit moment is er alleen code om de resultaten van 1 hypothese vs zijn complement te bepalen en niet voor een set van hypotheses. Toen ik het deed voor meer dan een hypothese, dan geeft het wel output. Op zich geeft het de output met de unconstrained, alleen is er geen melding dat dit gebeurd en daarnaast staat er in de output ook dat het de complement is... Kan je een foutmelding inbouwen. Als je daarnaast ook de resultaten wilt geven met de unconstrained dan moet de hypothese daar aangepast worden (niet Hc en ook niet de omschrijving - zie hieronder).
Hieronder vind je code en output.
Load the gorica and lavaan libraries.
if (!require("gorica")) install.packages("gorica") # install this package first (once) if (!require("lavaan")) install.packages("lavaan") # install this package first (once) library(gorica) library(lavaan)
Specify the latent regression model
model2 <- ' A =~ Ab + Al + Af + An + Ar + Ac B =~ Bb + Bl + Bf + Bn + Br + Bc A ~ B + age + peabody '
Fit the latent regression model using the lavaan sem function
fit2 <- sem(model2, data = sesamesim, std.lv = TRUE)
Formulate hypotheses
hypotheses2 <- " A~B > A~peabody = A~age = 0; A~B > A~peabody > A~age = 0; A~B > A~peabody > A~age > 0 "
Call gorica
Note: because more than 1 hypothesis, we cannot use: comparison = "complement"
set.seed(100) out2_c <- gorica(fit2, hypotheses2, comparison = "complement", standardize=TRUE) out2_c
OUTPUT:
Informative hypothesis test for an object of class lavaan:
loglik penalty gorica gorica_weights H1 6.836 0.504 -12.663 0.370
H2 6.836 0.691 -12.290 0.307
H3 6.836 0.823 -12.026 0.269
Hc 6.894 2.496 -8.798 0.054
Hypotheses: H1: A~B>A~peabody=A~age=0 H2: A~B>A~peabody>A~age=0 H3: A~B>A~peabody>A~age>0 Hc: Complement of the hypothesis