Provides 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
)

Arguments

object

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

...

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".

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.

Value

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 objects 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..

References

Akaike, H. (1974) A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19, 716–723. doi:10.1109/tac.1974.1100705

Schwarz, G. (1978) Estimating the dimensions of a model. The Annals of Statistics, 6, 461–464. 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. 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. doi:10.1287/mksc.12.1.103

See also

Examples

## 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)
#> Manifest items :
#>  DEFECT HLTH RAPE POOR SINGLE NOMORE 
#> 
#> Deleted observation(s) : 
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Latent class analysis Fitting...
#> 
#>  52 iteration 
#> 
#> Converged at 52 iteration (loglik :-740.1018)
class3 = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
              data = gss08, nclass = 3,  n.init = 1)
#> Manifest items :
#>  DEFECT HLTH RAPE POOR SINGLE NOMORE 
#> 
#> Deleted observation(s) : 
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Latent class analysis Fitting...
#> 
#>  81 iteration 
#> 
#> Converged at 81 iteration (loglik :-687.4486)
class4 = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
              data = gss08, nclass = 4,  n.init = 1)
#> Manifest items :
#>  DEFECT HLTH RAPE POOR SINGLE NOMORE 
#> 
#> Deleted observation(s) : 
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Latent class analysis Fitting...
#> 
#> ... 374 iteration 
#> 
#> Converged at 374 iteration (loglik :-684.7354)

gofglca(class2, class3, class4)
#> Model 1: item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1
#>          nclass: 2
#> Model 2: item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1
#>          nclass: 3
#> Model 3: item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1
#>          nclass: 4
#> 
#> Goodness of Fit Table :
#>    loglik     AIC     BIC entropy df    Gsq
#> 1 -740.10 1506.20 1556.43    0.95 50 135.13
#> 2 -687.45 1414.90 1492.17    0.88 43  29.83
#> 3 -684.74 1423.47 1527.79    0.87 36  24.40
#> 
#> Analysis of Deviance Table :
#>   npar  loglik Df Deviance
#> 1   13 -740.10            
#> 2   20 -687.45  7   105.31
#> 3   27 -684.74  7     5.43
if (FALSE) gofglca(class2, class3, class4, test = "boot") # \dontrun{}

## 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)
#> Manifest items :
#>  ECIGT ECIGAR ESLT EELCIGT EHOOKAH 
#> Grouping variable : SCH_ID 
#> 
#> Deleted observation(s) : 
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Nonparametric multilevel latent class analysis Fitting...
#> 
#>  49 iteration 
#> 
#> Converged at 49 iteration (loglik :-2017.808)
cluster3 = glca(item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1,
                group = SCH_ID, data = nyts18, nclass = 2, ncluster = 3, n.init = 1)
#> Manifest items :
#>  ECIGT ECIGAR ESLT EELCIGT EHOOKAH 
#> Grouping variable : SCH_ID 
#> 
#> Deleted observation(s) : 
#> 0 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Nonparametric multilevel latent class analysis Fitting...
#> 
#>  81 iteration 
#> 
#> Converged at 81 iteration (loglik :-2008.164)

gofglca(cluster2, cluster3)
#> Model 1: item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1
#>          Group: SCH_ID, nclass: 2, ncluster: 2
#> Model 2: item(ECIGT, ECIGAR, ESLT, EELCIGT, EHOOKAH) ~ 1
#>          Group: SCH_ID, nclass: 2, ncluster: 3
#> 
#> Goodness of Fit Table :
#>     loglik     AIC     BIC entropy   df    Gsq
#> 1 -2017.81 4061.62 4132.57    0.91 1426 893.15
#> 2 -2008.16 4046.33 4128.20    0.90 1424 873.86
#> 
#> Analysis of Deviance Table :
#>   npar   loglik Df Deviance
#> 1   13 -2017.81            
#> 2   15 -2008.16  2    19.29
if (FALSE) gofglca(cluster2, cluster3, test = "boot") # \dontrun{}

## 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)
#> Manifest items :
#>  DEFECT HLTH RAPE POOR SINGLE NOMORE 
#> Grouping variable : DEGREE 
#> 
#> Deleted observation(s) : 
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Multiple-group latent class analysis Fitting...
#> 
#>  87 iteration 
#> 
#> Converged at 87 iteration (loglik :-672.4138)
measVar = glca(item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1,
               group = DEGREE, data = gss08, nclass = 3, n.init = 1, measure.inv = FALSE)
#> Manifest items :
#>  DEFECT HLTH RAPE POOR SINGLE NOMORE 
#> Grouping variable : DEGREE 
#> 
#> Deleted observation(s) : 
#> 3 observation(s) for missing all manifest items
#> 0 observation(s) for missing at least 1 covariates
#> 
#> Multiple-group latent class analysis Fitting...
#> 
#> . 194 iteration 
#> 
#> Converged at 194 iteration (loglik :-650.2821)

gofglca(measInv, measVar)
#> Model 1: item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1
#>          Group: DEGREE, nclass: 3, measure.inv: TRUE
#> Model 2: item(DEFECT, HLTH, RAPE, POOR, SINGLE, NOMORE) ~ 1
#>          Group: DEGREE, nclass: 3, measure.inv: FALSE
#> 
#> Goodness of Fit Table :
#>    loglik     AIC     BIC entropy  df   Gsq
#> 1 -672.41 1396.83 1497.28    0.88 229 87.85
#> 2 -650.28 1460.56 1769.65    0.89 175 43.59
#> 
#> Analysis of Deviance Table :
#>   npar  loglik Df Deviance
#> 1   26 -672.41            
#> 2   80 -650.28 54    44.26