Learn R Programming

glca (version 0.1.0)

glca.gof: Goodness of Fit Tests for Fitted glca Model

Description

Provides AIC, BIC, 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".

Usage

glca.gof(object, object2 = NULL, test = NULL, nboot = 25,
  random.seed = NULL, maxiter = 500, eps = 1e-05, verbose = TRUE)

Arguments

object

an object of "glca", usually, a result of a call to glca

object2

an optional object of "glca" to be compared with object

test

a character string indicating type of test (chi-square test or bootstrap) to obtain the p-value for goodness of fit test ("chisq" or "boot")

nboot

number of bootstrap samples, only used when test = "boot"

random.seed

random seed to have the equivalent solution for every bootstrap trials

maxiter

an integer for maximum number of iteration for bootstrap sample

eps

positive convergence tolerance for bootstrap sample

verbose

an logical value for whether or not to print the result of a function's execution

Value

criteria

a table with model fit criteria

dev.table

a table with deviance statistic and bootstrap p-value

boot

a list of LRT statistics from each bootstrap sample

References

Akaike, H. (1974) A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19, 716<U+2013>723. 10.1109/tac.1974.1100705

Schwarz, G. (1978) Estimating the dimensions of a model. The Annals of Statistics, 6, 461<U+2013>464. 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. 10.1177/0049124196024004004

See Also

glca gss

Examples

Run this code
# NOT RUN {
## Example 1.
## Model selection between two LCA models with different number of latent classes.
data(gss)
class2 = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
              data = gss, nclass = 2)
class3 = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
              data = gss, nclass = 3)

glca.gof(class2, class3)
# }
# NOT RUN {
glca.gof(class2, class3, test = "chisq")
# }
# NOT RUN {
glca.gof(class2, class3, test = "boot")
# }
# NOT RUN {
## Example 2.
## Model selection between two MLCA models with different number of latent clusters.
cluster2 = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
                group = REGION, data = gss, nclass = 3, ncluster = 2, na.rm = TRUE)
cluster3 = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
                group = REGION, data = gss, nclass = 3, ncluster = 3, na.rm = TRUE)

glca.gof(cluster2, cluster3)
# }
# NOT RUN {
glca.gof(cluster2, cluster3, test = "chisq")
# }
# NOT RUN {
glca.gof(cluster2, cluster3, test = "boot")
# }
# NOT RUN {
# }
# NOT RUN {
## Example 3.
## MGLCA model selection under the measurement (invariance) assumption across groups.
measInv = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
               group = SEX, data = gss, nclass = 3)
measVar = glca(item(ABDEFECT, ABHLTH, ABRAPE, ABPOOR, ABSINGLE) ~ 1,
               group = SEX, data = gss, nclass = 3, measure.inv = FALSE)

glca.gof(measInv, measVar)
glca.gof(measInv, measVar, test = "chisq")
glca.gof(measInv, measVar, test = "boot")
# }

Run the code above in your browser using DataLab