Contains fitted model information which can be manipulated or extracted using the methods described below.

Slots

fitType:

Object of class "character"

call:

Object of class "call"

formula:

Object of class "formula"

data:

Object of class "unmarkedFrame"

sitesRemoved:

Object of class "numeric"

estimates:

Object of class "unmarkedEstimateList"

AIC:

Object of class "numeric"

opt:

Object of class "list" containing results from optim

negLogLike:

Object of class "numeric"

nllFun:

Object of class "function"

knownOcc:

unmarkedFitOccu only: sites known to be occupied

K:

unmarkedFitPCount only: upper bound used in integration

mixture:

unmarkedFitPCount only: Mixing distribution

keyfun:

unmarkedFitDS only: detection function used by distsamp

unitsOut:

unmarkedFitDS only: density units

Methods

[

signature(x = "unmarkedFit", i = "ANY", j = "ANY", drop = "ANY"): extract one of names(obj), eg 'state' or 'det'

backTransform

signature(obj = "unmarkedFit"): back-transform parameters to original scale when no covariate effects are modeled

coef

signature(object = "unmarkedFit"): returns parameter estimates. type can be one of names(obj), eg 'state' or 'det'. If altNames=TRUE estimate names are more specific.

confint

signature(object = "unmarkedFit"): Returns confidence intervals. Must specify type and method (either "normal" or "profile")

fitted

signature(object = "unmarkedFit"): returns expected values of Y

getData

signature(object = "unmarkedFit"): extracts data

getP

signature(object = "unmarkedFit"): calculates and extracts expected detection probabilities

getFP

signature(object = "unmarkedFit"): calculates and extracts expected false positive detection probabilities

getB

signature(object = "unmarkedFit"): calculates and extracts expected probabilities a true positive detection was classified as certain

hessian

signature(object = "unmarkedFit"): Returns hessian matrix

linearComb

signature(obj = "unmarkedFit", coefficients = "matrixOrVector"): Returns estimate and SE on original scale when covariates are present

mle

signature(object = "unmarkedFit"): Same as coef(fit)?

names

signature(x = "unmarkedFit"): Names of parameter levels

nllFun

signature(object = "unmarkedFit"): returns negative log-likelihood used to estimate parameters

parboot

signature(object = "unmarkedFit"): Parametric bootstrapping method to assess goodness-of-fit

plot

signature(x = "unmarkedFit", y = "missing"): Plots expected vs. observed values

predict

signature(object = "unmarkedFit"): Returns predictions and standard errors for original data or for covariates in a new data.frame

profile

signature(fitted = "unmarkedFit"): used by confint method='profile'

residuals

signature(object = "unmarkedFit"): returns residuals

sampleSize

signature(object = "unmarkedFit"): returns number of sites in sample

SE

signature(obj = "unmarkedFit"): returns standard errors

show

signature(object = "unmarkedFit"): concise results

summary

signature(object = "unmarkedFit"): results with more details

update

signature(object = "unmarkedFit"): refit model with changes to one or more arguments

vcov

signature(object = "unmarkedFit"): returns variance-covariance matrix

smoothed

signature(object="unmarkedFitColExt"): Returns the smoothed trajectory from a colonization-extinction model fit. Takes additional logical argument mean which specifies whether or not to return the average over sites.

projected

signature(object="unmarkedFitColExt"): Returns the projected trajectory from a colonization-extinction model fit. Takes additional logical argument mean which specifies whether or not to return the average over sites.

logLik

signature(object="unmarkedFit"): Returns the log-likelihood.

LRT

signature(m1="unmarkedFit", m2="unmarkedFit"): Returns the chi-squared statistic, degrees-of-freedom, and p-value from a Likelihood Ratio Test.

Note

This is a superclass with child classes for each fit type

Examples

showClass("unmarkedFit")
#> Class "unmarkedFit" [package "unmarked"]
#> 
#> Slots:
#>                                                                      
#> Name:               fitType                 call              formula
#> Class:            character                 call              formula
#>                                                                      
#> Name:                  data         sitesRemoved            estimates
#> Class:        unmarkedFrame              numeric unmarkedEstimateList
#>                                                                      
#> Name:                   AIC                  opt           negLogLike
#> Class:              numeric                 list              numeric
#>                                                                      
#> Name:                nllFun     bootstrapSamples             covMatBS
#> Class:             function         optionalList       optionalMatrix
#>                            
#> Name:                   TMB
#> Class:         optionalList
#> 
#> Known Subclasses: 
#> Class "unmarkedFitDS", directly
#> Class "unmarkedFitPCount", directly
#> Class "unmarkedFitDailMadsen", directly
#> Class "unmarkedFitOccu", directly
#> Class "unmarkedFitOccuPEN", directly
#> Class "unmarkedFitOccuPEN_CV", directly
#> Class "unmarkedFitOccuFP", directly
#> Class "unmarkedFitOccuMulti", directly
#> Class "unmarkedFitOccuMS", directly
#> Class "unmarkedFitOccuTTD", directly
#> Class "unmarkedFitNmixTTD", directly
#> Class "unmarkedFitMPois", directly
#> Class "unmarkedFitOccuRN", directly
#> Class "unmarkedFitMNmix", directly
#> Class "unmarkedFitColExt", directly
#> Class "unmarkedFitGMM", directly
#> Class "unmarkedFitIDS", directly
#> Class "unmarkedFitGOccu", directly
#> Class "unmarkedFitOccuCOP", directly
#> Class "unmarkedFitPCO", by class "unmarkedFitDailMadsen", distance 2
#> Class "unmarkedFitMMO", by class "unmarkedFitDailMadsen", distance 2
#> Class "unmarkedFitDSO", by class "unmarkedFitDailMadsen", distance 2
#> Class "unmarkedFitGDS", by class "unmarkedFitGMM", distance 2
#> Class "unmarkedFitGPC", by class "unmarkedFitGMM", distance 2
#> Class "unmarkedFitGDR", by class "unmarkedFitGMM", distance 3

# Format removal data for multinomPois
data(ovendata)
ovenFrame <- unmarkedFrameMPois(y = ovendata.list$data,
  siteCovs = as.data.frame(scale(ovendata.list$covariates[,-1])),
  type = "removal")

# Fit a couple of models
(fm1 <- multinomPois(~ 1 ~ ufc + trba, ovenFrame))
#> 
#> Call:
#> multinomPois(formula = ~1 ~ ufc + trba, data = ovenFrame)
#> 
#> Abundance:
#>             Estimate    SE      z P(>|z|)
#> (Intercept)    0.102 0.119  0.864   0.388
#> ufc            0.100 0.126  0.794   0.427
#> trba          -0.171 0.135 -1.262   0.207
#> 
#> Detection:
#>  Estimate    SE    z P(>|z|)
#>     0.288 0.233 1.24   0.217
#> 
#> AIC: 326.1387 
summary(fm1)
#> 
#> Call:
#> multinomPois(formula = ~1 ~ ufc + trba, data = ovenFrame)
#> 
#> Abundance (log-scale):
#>             Estimate    SE      z P(>|z|)
#> (Intercept)    0.102 0.119  0.864   0.388
#> ufc            0.100 0.126  0.794   0.427
#> trba          -0.171 0.135 -1.262   0.207
#> 
#> Detection (logit-scale):
#>  Estimate    SE    z P(>|z|)
#>     0.288 0.233 1.24   0.217
#> 
#> AIC: 326.1387 
#> Number of sites: 70
#> optim convergence code: 0
#> optim iterations: 30 
#> Bootstrap iterations: 0 
#> 

# Apply a bunch of methods to the fitted model

# Look at the different parameter types
names(fm1)
#> [1] "state" "det"  
fm1['state']
#> Abundance:
#>             Estimate    SE      z P(>|z|)
#> (Intercept)    0.102 0.119  0.864   0.388
#> ufc            0.100 0.126  0.794   0.427
#> trba          -0.171 0.135 -1.262   0.207
fm1['det']
#> Detection:
#>  Estimate    SE    z P(>|z|)
#>     0.288 0.233 1.24   0.217

# Coefficients from abundance part of the model
coef(fm1, type='state')
#>  lambda(Int)  lambda(ufc) lambda(trba) 
#>    0.1023681    0.1002939   -0.1708609 

# Variance-covariance matrix
vcov(fm1, type='state')
#>               lambda(Int)  lambda(ufc) lambda(trba)
#> lambda(Int)   0.014052472 -0.001228179  0.002364962
#> lambda(ufc)  -0.001228179  0.015941971  0.008057614
#> lambda(trba)  0.002364962  0.008057614  0.018318119

# Confidence intervals using profiled likelihood
confint(fm1, type='state', method='profile')
#> Profiling parameter 1 of 3 ... done.
#> Profiling parameter 2 of 3 ... done.
#> Profiling parameter 3 of 3 ... done.
#>                   0.025      0.975
#> lambda(Int)  -0.1390786 0.32676614
#> lambda(ufc)  -0.1477724 0.34811770
#> lambda(trba) -0.4368444 0.09469605

# Expected values
fitted(fm1)
#>            [,1]      [,2]       [,3]       [,4]
#>  [1,] 0.8960021 0.3840242 0.16459179 0.07054362
#>  [2,] 0.7870851 0.3373426 0.14458420 0.06196842
#>  [3,] 0.8518174 0.3650868 0.15647527 0.06706490
#>  [4,] 0.9330928 0.3999212 0.17140521 0.07346383
#>  [5,] 0.6193105 0.2654349 0.11376473 0.04875927
#>  [6,] 0.6709329 0.2875601 0.12324754 0.05282358
#>  [7,] 0.4425821 0.1896896 0.08130047 0.03484517
#>  [8,] 0.6406227 0.2745692 0.11767968 0.05043721
#>  [9,] 0.5722107 0.2452480 0.10511269 0.04505103
#> [10,] 0.7758598 0.3325315 0.14252217 0.06108464
#> [11,] 0.6696637 0.2870162 0.12301439 0.05272365
#> [12,] 0.7332182 0.3142555 0.13468909 0.05772740
#>  [ reached getOption("max.print") -- omitted 58 rows ]

# Original data
getData(fm1)
#> Data frame representation of unmarkedFrame object.
#>   y.1 y.2 y.3 y.4         ufc       trba
#> 1   0   0   0   0  0.84177975 -1.5395877
#> 2   1   0   0   0  0.03022367 -1.2574150
#> 3   0   0   0   0  2.10015927 -0.5049547
#> 4   0   0   0   0  1.08597395 -1.6336452
#> 5   0   0   0   0  1.00492226  0.7177934
#> 6   0   0   0   0  0.84177975  0.1534482
#> 7   0   0   0   0 -0.90290994  1.5643114
#> 8   0   0   0   0 -0.74080655 -0.5049547
#>  [ reached 'max' / getOption("max.print") -- omitted 62 rows ]

# Detection probabilities
getP(fm1)
#>            [,1]      [,2]      [,3]      [,4]
#>  [1,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [2,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [3,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [4,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [5,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [6,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [7,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [8,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [9,] 0.5714025 0.2449017 0.1049642 0.0449874
#> [10,] 0.5714025 0.2449017 0.1049642 0.0449874
#> [11,] 0.5714025 0.2449017 0.1049642 0.0449874
#> [12,] 0.5714025 0.2449017 0.1049642 0.0449874
#>  [ reached getOption("max.print") -- omitted 58 rows ]

# log-likelihood
logLik(fm1)
#> [1] -159.0694

# Back-transform detection probability to original scale
# backTransform only works on models with no covariates or
#     in conjunction with linearComb (next example)
backTransform(fm1, type ='det')
#> Backtransformed linear combination(s) of Detection estimate(s)
#> 
#>  Estimate    SE LinComb (Intercept)
#>     0.571 0.057   0.288           1
#> 
#> Transformation: logistic 

# Predicted abundance at specified covariate values
(lc <- linearComb(fm1, c(Int = 1, ufc = 0, trba = 0), type='state'))
#> Linear combination(s) of Abundance estimate(s)
#> 
#>  Estimate    SE (Intercept) ufc trba
#>     0.102 0.119           1   0    0
#> 
backTransform(lc)
#> Backtransformed linear combination(s) of Abundance estimate(s)
#> 
#>  Estimate    SE LinComb (Intercept) ufc trba
#>      1.11 0.131   0.102           1   0    0
#> 
#> Transformation: exp 

# Assess goodness-of-fit
parboot(fm1)
#> 
  |                                                  | 0 % ~calculating  
  |+++++                                             | 10% ~00s          
  |++++++++++                                        | 20% ~00s          
  |+++++++++++++++                                   | 30% ~00s          
  |++++++++++++++++++++                              | 40% ~00s          
  |+++++++++++++++++++++++++                         | 50% ~00s          
  |++++++++++++++++++++++++++++++                    | 60% ~00s          
  |+++++++++++++++++++++++++++++++++++               | 70% ~00s          
  |++++++++++++++++++++++++++++++++++++++++          | 80% ~00s          
  |+++++++++++++++++++++++++++++++++++++++++++++     | 90% ~00s          
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s  
#> 
#> Call: parboot(object = fm1)
#> 
#> Parametric Bootstrap Statistics:
#>       t0 mean(t0 - t_B) StdDev(t0 - t_B) Pr(t_B > t0)
#> SSE 72.2          -6.09             11.9        0.636
#> 
#> t_B quantiles:
#>      0% 2.5% 25% 50% 75% 97.5% 100%
#> [1,] 56   57  72  83  85    92   93
#> 
#> t0 = Original statistic computed from data
#> t_B = Vector of bootstrap samples
#> 
plot(fm1)


# Predict abundance at specified covariate values.
newdat <- data.frame(ufc = 0, trba = seq(-1, 1, length=10))
predict(fm1, type='state', newdata=newdat)
#>    Predicted        SE     lower    upper
#> 1  1.3142011 0.2184923 0.9487362 1.820448
#> 2  1.2652375 0.1853259 0.9494939 1.685978
#> 3  1.2180982 0.1591867 0.9428516 1.573698
#> 4  1.1727152 0.1412680 0.9260934 1.485013
#> 5  1.1290230 0.1324045 0.8971796 1.420778
#> 6  1.0869586 0.1322528 0.8563382 1.379688
#> 7  1.0464615 0.1390828 0.8064770 1.357858
#> 8  1.0074732 0.1505623 0.7516666 1.350336
#> 9  0.9699374 0.1646399 0.6954379 1.352786
#> 10 0.9338002 0.1798639 0.6401766 1.362097

# Number of sites in the sample
sampleSize(fm1)
#> [1] 70

# Fit a new model without covariates
(fmNull <- update(fm1, formula = ~1 ~1))
#> 
#> Call:
#> multinomPois(formula = ~1 ~ 1, data = ovenFrame)
#> 
#> Abundance:
#>  Estimate    SE    z P(>|z|)
#>      0.13 0.115 1.12   0.262
#> 
#> Detection:
#>  Estimate    SE    z P(>|z|)
#>     0.288 0.233 1.24   0.217
#> 
#> AIC: 326.2803 

# Likelihood ratio test
LRT(fm1, fmNull)
#>      Chisq DF Pr(>Chisq)
#> 1 4.141604  2  0.1260846