Learn R Programming

AICcmodavg (version 2.00)

extractLL: Extract Log-Likelihood of Model

Description

This function extracts the log-likelihood from an object of coxme, coxph, lmekin, maxlikeFit, vglm, or various unmarkedFit classes.

Usage

extractLL(mod, ...)

## S3 method for class 'coxme': extractLL(mod, type = "Integrated", \dots)

## S3 method for class 'coxph': extractLL(mod, \dots)

## S3 method for class 'lmekin': extractLL(mod, \dots)

## S3 method for class 'maxlikeFit': extractLL(mod, \dots)

## S3 method for class 'unmarkedFit': extractLL(mod, \dots)

## S3 method for class 'vglm': extractLL(mod, \dots)

Arguments

mod
an object of coxme, coxph, lmekin, maxlikeFit, vglm, or unmarkedFit class resulting from the fit of distsamp, gdistsamp, gmultmix, <
...
additional arguments passed to the function.
type
a character string indicating whether the integrated partial likelihood ("Integrated") or penalized likelihood ("Penalized") is to be used for a coxme object.

Value

  • These functions return the value of the log-likelihood of the model and associated degrees of freedom.

Details

This utility function extracts the information from a coxme, coxph, lmekin, maxlikeFit, vglm, or unmarkedFit object resulting from distsamp, gdistsamp, gmultmix, multinomPois, gpcount, occu, occuRN, colext, pcount, or pcountOpen.

See Also

AICc, aictab, coxme, coxph, lmekin, maxlike, distsamp, gdistsamp, occu, occuRN, colext, pcount, pcountOpen

Examples

Run this code
##single-season occupancy model example modified from ?occu
if(require(unmarked)) {
##single season
data(frogs)
pferUMF <- unmarkedFrameOccu(pfer.bin)
## add some fake covariates for illustration
siteCovs(pferUMF) <- data.frame(sitevar1 = rnorm(numSites(pferUMF)),
                                sitevar2 = rnorm(numSites(pferUMF))) 
     
## observation covariates are in site-major, observation-minor order
obsCovs(pferUMF) <- data.frame(obsvar1 = rnorm(numSites(pferUMF) *
                                 obsNum(pferUMF))) 

##run model set
fm1 <- occu(~ obsvar1 ~ sitevar1, pferUMF)

##extract log-likelihood
extractLL(fm1)
detach(package:unmarked)
}



##modified example of Cox regression from ?coxph
require(survival)
##Create a simple data set for a time-dependent model
test2 <- list(start=c(1, 2, 5, 2, 1, 7, 3, 4, 8, 8),
              stop =c(2, 3, 6, 7, 8, 9, 9, 9,14,17),
              event=c(1, 1, 1, 1, 1, 1, 1, 0, 0, 0),
              x    =c(1, 0, 0, 1, 0, 1, 1, 1, 0, 0) )
m.cox <- coxph(Surv(start, stop, event) ~ x, test2)
extractLL(m.cox)
detach(package:survival)

Run the code above in your browser using DataLab