compare {slca} | R Documentation |
Compare Two Fitted slca
Models
Description
Conducts a relative model fit test between two fitted SLCM models using the deviance statistic.
Usage
compare(
model1,
model2,
test = c("none", "chisq", "boot"),
nboot = 50,
method = c("hybrid", "em", "nlm"),
plot = FALSE,
maxiter = 1000,
tol = 1e-08,
verbose = FALSE
)
Arguments
model1 |
an object of class |
model2 |
another object of class |
test |
a character string specifying the type of test to be conducted. If |
nboot |
an integer specifying the number of bootstrap iterations to perform (used only when |
method |
a character string specifying the estimation method for bootstrapping. |
plot |
a logical value indicating whether to display a histogram of G-squared statistics for the bootstrap samples (applicable only for |
maxiter |
an integer specifying the maximum number of iterations allowed during each bootstrap estimation round. The default is 100. |
tol |
numeric value setting the convergence tolerance for each bootstrap iteration. The default is |
verbose |
a logical value indicating whether to print progress updates on completed bootstrap iterations. The default is |
Value
A data.frame
containing the number of parameters (Df), loglikelihood, AIC, BIC, G-squared statistics, and the residual degree of freedom for each object.
If a statistical test is conducted (via test
), the resulting p-value for the comparison is also included.
See Also
Examples
library(magrittr)
data <- gss7677[gss7677$COHORT == "YOUNG", ]
stat2 <- slca(status(2) ~ PAPRES + PADEG + MADEG) %>%
estimate(data = data, control = list(verbose = FALSE))
stat3 <- slca(status(3) ~ PAPRES + PADEG + MADEG) %>%
estimate(data = data, control = list(verbose = FALSE))
stat4 <- slca(status(4) ~ PAPRES + PADEG + MADEG) %>%
estimate(data = data, control = list(verbose = FALSE))
gof(stat2, stat3, stat4)
gof(stat2, stat3, stat4, test = "chisq")
gof(stat2, stat3, stat4, test = "boot")
compare(stat3, stat4)
compare(stat3, stat4, test = "chisq")
compare(stat3, stat4, test = "boot")