gofglca | R Documentation |
glca
ModelProvides AIC, BIC, entropy and deviance statitistic for goodness of fit test for the fitted model. Given object2
, the function computes the log-likelihood ratio (LRT) statisic for comparing the goodness of fit for two models. The bootstrap p-value can be obtained from the empirical distribution of LRT statistic by choosing test = "boot"
.
gofglca(
object,
...,
test = NULL,
nboot = 50,
criteria = c("AIC", "BIC", "entropy"),
maxiter = 500,
eps = 1e-04,
seed = NULL,
verbose = FALSE
)
object |
an object of " |
... |
an optional object of " |
test |
a character string indicating type of test (chi-square test or bootstrap) to obtain the p-value for goodness of fit test ( |
nboot |
number of bootstrap samples, only used when |
criteria |
a character vector indicating criteria to be printed. |
maxiter |
an integer for maximum number of iteration for bootstrap sample. |
eps |
positive convergence tolerance for bootstrap sample. |
seed |
As the same value for seed guarantees the same datasets to be generated, this argument can be used for reproducibility of bootstrap results. |
verbose |
an logical value for whether or not to print the result of a function's execution. |
gtable |
a matrix with model goodneess-of-fit criteria |
dtable |
a matrix with deviance statistic and bootstrap p-value |
boot |
a list of LRT statistics from each bootstrap sample |
gtable
, which is always included in output of this function, includes goodness-of-fit criteria which are indicated criteria
arguments for the object
(s). dtable
are contained when the object
s are competing models. (when used items of the models are identical) dtable
prints deviance and p-value. (bootstrap or chi-square) Lastly, when the boostrap sample is used, the G^2
-statistics for each bootstrap samples will be included in return object..
Akaike, H. (1974) A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19, 716–723. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/tac.1974.1100705")}
Schwarz, G. (1978) Estimating the dimensions of a model. The Annals of Statistics, 6, 461–464. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/aos/1176344136")}
Langeheine, R., Pannekoek, J., and van de Pol, F. (1996) Bootstrapping goodness-of-fit measures in categorical data analysis. Sociological Methods and Research. 24. 492-516. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1177/0049124196024004004")}
Ramaswamy, V., Desarbo, W., Reibstein, D., & Robinson, W. (1993). An Empirical Pooling Approach for Estimating Marketing Mix Elasticities with PIMS Data. Marketing Science, 12(1), 103-124. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1287/mksc.12.1.103")}
glca
gss08
nyts18
## Example 1.
## Model selection between two LCA models with different number of latent classes.
data(gss08)
class2 = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
data = gss08, nclass = 2, n.init = 1)
class3 = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
data = gss08, nclass = 3, n.init = 1)
class4 = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
data = gss08, nclass = 4, n.init = 1)
gofglca(class2, class3, class4)
## Not run: gofglca(class2, class3, class4, test = "boot")
## Example 2.
## Model selection between two MLCA models with different number of latent clusters.
cluster2 = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1,
group = SCH_ID, data = nyts18, nclass = 2, ncluster = 2, n.init = 1)
cluster3 = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1,
group = SCH_ID, data = nyts18, nclass = 2, ncluster = 3, n.init = 1)
gofglca(cluster2, cluster3)
## Not run: gofglca(cluster2, cluster3, test = "boot")
## Example 3.
## MGLCA model selection under the measurement (invariance) assumption across groups.
measInv = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
group = DEGREE, data = gss08, nclass = 3, n.init = 1)
measVar = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
group = DEGREE, data = gss08, nclass = 3, n.init = 1, measure.inv = FALSE)
gofglca(measInv, measVar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.