Skip to content
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
3 changes: 3 additions & 0 deletions R/poLCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ function(formula,data,nclass=2,maxiter=1000,graphs=FALSE,tol=1e-10,
}
ret$predcell <- data.frame(datacell,observed=freq,expected=round(fit,3)) # Table that gives observed vs. predicted cell counts
ret$Gsq <- 2 * sum(freq*log(freq/fit)) # Likelihood ratio/deviance statistic
ret$df <- max(K.j) ^ J - ret$npar - 1 # Degrees of freedom
ret$Gsq.pvalue <- 1 - pchisq(ret$Gsq, ret$df)
ret$Chisq.pvalue <- 1 - pchisq(ret$Chisq, ret$df)
}
y[y==0] <- NA
ret$y <- data.frame(y) # outcome variables
Expand Down
4 changes: 2 additions & 2 deletions R/print.poLCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function(x, ...) {
cat("maximum log-likelihood:", x$llik, "\n \n")
cat("AIC(",R,"): ",x$aic,"\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="")
if (S==1) cat("G^2(",R,"): ",x$Gsq," (", x$Gsq.pvalue, ")"," (Likelihood ratio/deviance statistic) \n",sep="")
cat("X^2(",R,"): ",x$Chisq," (", x$Chisq.pvalue, ")"," (Chi-square goodness of fit) \n \n",sep="")
if (x$numiter==x$maxiter) cat("ALERT: iterations finished, MAXIMUM LIKELIHOOD NOT FOUND \n \n")
if (!x$probs.start.ok) cat("ALERT: error in user-specified starting values; new start values generated \n \n")
if (x$npar>x$N) cat("ALERT: number of parameters estimated (",x$npar,") exceeds number of observations (",x$N,") \n \n")
Expand Down
4 changes: 3 additions & 1 deletion man/poLCA.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Model specification: Latent class models have more than one manifest variable, s
\item{aic}{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.}
\item{Gsq.pvalue}{Likelihood ratio/deviance statistic.}
\item{Chisq}{Pearson Chi-square goodness of fit statistic for fitted vs. observed multiway tables p-value.}
\item{Chisq.pvalue}{Pearson Chi-square goodness of fit statistic for fitted vs. observed multiway tables p-value.}
\item{time}{length of time it took to run the model.}
\item{npar}{number of degrees of freedom used by the model (estimated parameters).}
\item{resid.df}{number of residual degrees of freedom.}
Expand Down