Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add caic #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/poLCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function(formula,data,nclass=2,maxiter=1000,graphs=FALSE,tol=1e-10,
ret$npar <- (R*sum(K.j-1)) + (R-1) # number of degrees of freedom used by the model (number of estimated parameters)
if (S>1) { ret$npar <- ret$npar + (S*(R-1)) - (R-1) }
ret$aic <- (-2 * ret$llik) + (2 * ret$npar) # Akaike Information Criterion
ret$caic <- (-2 * ret$llik) + ret$npar(log(N) + 1)
ret$bic <- (-2 * ret$llik) + (log(N) * ret$npar) # Schwarz-Bayesian Information Criterion
ret$Nobs <- sum(rowSums(y==0)==0) # number of fully observed cases (if na.rm=F)
if (all(rowSums(y==0)>0)) { # if no rows are fully observed
Expand Down
1 change: 1 addition & 0 deletions R/print.poLCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function(x, ...) {
cat("residual degrees of freedom:", x$resid.df, "\n")
cat("maximum log-likelihood:", x$llik, "\n \n")
cat("AIC(",R,"): ",x$aic,"\n",sep="")
cat("CAIC(",R,"): ",x$caic,"\n",sep="")
cat("BIC(",R,"): ",x$bic,"\n",sep="")
if (S==1) cat("G^2(",R,"): ",x$Gsq," (Likelihood ratio/deviance statistic) \n",sep="")
cat("X^2(",R,"): ",x$Chisq," (Chi-square goodness of fit) \n \n",sep="")
Expand Down
1 change: 1 addition & 0 deletions man/poLCA.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Model specification: Latent class models have more than one manifest variable, s
\item{coeff.se}{standard errors of coefficient estimates on covariates (when estimated), in the same format as \code{coeff}.}
\item{coeff.V}{covariance matrix of coefficient estimates on covariates (when estimated).}
\item{aic}{Akaike Information Criterion.}
\item{caic}{Consistent Akaike Information Criterion.}
\item{bic}{Bayesian Information Criterion.}
\item{Gsq}{Likelihood ratio/deviance statistic.}
\item{Chisq}{Pearson Chi-square goodness of fit statistic for fitted vs. observed multiway tables.}
Expand Down