Learn R Programming

slca (version 1.3.0)

gof: Goodness-of-Fit Test for Fitted slca Model

Description

Computes the AIC, BIC, and deviance statistic (G-squared) for assessing the goodness-of-fit of a fitted slca model. If the test argument is specified, absolute model fit can be evaluated using deviance statistics.

Usage

gof(object, ...)

# S3 method for slcafit gof( object, ..., test = c("none", "chisq", "boot"), nboot = 100, plot = FALSE, maxiter = 100, tol = 1e-6, verbose = FALSE )

# S3 method for slcafit gof( object, ..., test = c("none", "chisq", "boot"), nboot = 100, plot = FALSE, maxiter = 100, tol = 1e-06, verbose = FALSE )

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 performed (using test), the result includes the corresponding p-value.

Arguments

object

an object of class slcafit.

...

additional objects of class slcafit for comparison.

test

a character string specifying the type of test to be conducted. If "chisq", a chi-squared test is conducted. If "boot", a bootstrap test is conducted.

nboot

an integer specifying the number of bootstrap rounds to be performed.

plot

a logical value indicating whether to print histogram of G-squared statistics for boostrap samples, only for test = "boot". The default is FALSE.

maxiter

an integer specifying the maximum number of iterations allowed for the estimation process during each bootstrap iteration. The default is 100.

tol

a numeric value specifying the convergence tolerance for each bootstrap iteration. The default is 1e-6.

verbose

a logical value indicating whether to print progress updates on the number of bootstrapping rounds completed.

See Also

compare

Examples

Run this code
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")
# \donttest{
gof(stat2, stat3, stat4, test = "boot")
# }

compare(stat3, stat4)
compare(stat3, stat4, test = "chisq")
# \donttest{
compare(stat3, stat4, test = "boot")
# }

Run the code above in your browser using DataLab