checkConv: Check Convergence of Fitted Model

View source: R/checkConv.R

checkConvR Documentation

Check Convergence of Fitted Model

Description

This function checks the convergence information contained in models of various classes.

Usage

checkConv(mod, ...)

## S3 method for class 'betareg'
checkConv(mod, ...)

## S3 method for class 'clm'
checkConv(mod, ...)

## S3 method for class 'clmm'
checkConv(mod, ...)

## S3 method for class 'glm'
checkConv(mod, ...)

## S3 method for class 'glmmTMB'
checkConv(mod, ...)

## S3 method for class 'hurdle'
checkConv(mod, ...)

## S3 method for class 'lavaan'
checkConv(mod, ...)

## S3 method for class 'maxlikeFit'
checkConv(mod, ...)

## S3 method for class 'merMod'
checkConv(mod, ...)

## S3 method for class 'lmerModLmerTest'
checkConv(mod, ...)

## S3 method for class 'multinom'
checkConv(mod, ...)

## S3 method for class 'nls'
checkConv(mod, ...)

## S3 method for class 'polr'
checkConv(mod, ...)

## S3 method for class 'unmarkedFit'
checkConv(mod, ...)

## S3 method for class 'zeroinfl'
checkConv(mod, ...)

Arguments

mod

an object containing the output of a model of the classes mentioned above.

...

additional arguments passed to the function.

Details

This function checks the element of a model object that contains the convergence information from the optimization function. The function is currently implemented for models of classes betareg, clm, clmm, glm, glmmTMB, hurdle, lavaan, maxlikeFit, merMod, lmerModLmerTest, multinom, nls, polr, unmarkedFit, and zeroinfl. The function is particularly useful for functions with several groups of parameters, such as those of the unmarked package (Fiske and Chandler, 2011).

Value

checkConv returns a list with the following components:

converged

a logical value indicating whether the algorithm converged or not.

message

a string containing the message from the optimization function.

Author(s)

Marc J. Mazerolle

References

Fiske, I., Chandler, R. (2011) unmarked: An R Package for fitting hierarchical models of wildlife occurrence and abundance. Journal of Statistical Software 43, 1–23.

See Also

checkParms, covDiag, mb.gof.test, Nmix.gof.test

Examples

##example modified from ?pcount
## Not run: 
if(require(unmarked)){
##Simulate data
set.seed(3)
nSites <- 100
nVisits <- 3
##covariate
x <- rnorm(nSites)               
beta0 <- 0
beta1 <- 1
##expected counts
lambda <- exp(beta0 + beta1*x)   
N <- rpois(nSites, lambda)      
y <- matrix(NA, nSites, nVisits)
p <- c(0.3, 0.6, 0.8)           
for(j in 1:nVisits) {
  y[,j] <- rbinom(nSites, N, p[j])
}
## Organize data
visitMat <- matrix(as.character(1:nVisits),
                   nSites, nVisits, byrow=TRUE)
     
umf <- unmarkedFramePCount(y=y, siteCovs=data.frame(x=x),
                           obsCovs=list(visit=visitMat))
## Fit model
fm1 <- pcount(~ visit ~ 1, umf, K=50)
checkConv(fm1)
}

## End(Not run)

AICcmodavg documentation built on Nov. 17, 2023, 1:08 a.m.