Organizes detection, non-detection data along with the covariates. This S4 class is required by the data argument of occu and occuRN

unmarkedFrameOccu(y, siteCovs=NULL, obsCovs=NULL, mapInfo)

Arguments

y

An RxJ matrix of the detection, non-detection data, where R is the number of sites, J is the maximum number of sampling periods per site.

siteCovs

A data.frame of covariates that vary at the site level. This should have M rows and one column per covariate

obsCovs

Either a named list of data.frames of covariates that vary within sites, or a data.frame with RxJ rows in site-major order.

mapInfo

Currently ignored

Details

unmarkedFrameOccu is the S4 class that holds data to be passed to the occu and occuRN model-fitting function.

Value

an object of class unmarkedFrameOccu

Examples


# Fake data
R <- 4 # number of sites
J <- 3 # number of visits
y <- matrix(c(
   1,1,0,
   0,0,0,
   1,1,1,
   1,0,1), nrow=R, ncol=J, byrow=TRUE)
y
#>      [,1] [,2] [,3]
#> [1,]    1    1    0
#> [2,]    0    0    0
#> [3,]    1    1    1
#> [4,]    1    0    1

site.covs <- data.frame(x1=1:4, x2=factor(c('A','B','A','B')))
site.covs
#>   x1 x2
#> 1  1  A
#> 2  2  B
#> 3  3  A
#> 4  4  B

obs.covs <- list(
   x3 = matrix(c(
      -1,0,1,
      -2,0,0,
      -3,1,0,
      0,0,0), nrow=R, ncol=J, byrow=TRUE),
   x4 = matrix(c(
      'a','b','c',
      'd','b','a',
      'a','a','c',
      'a','b','a'), nrow=R, ncol=J, byrow=TRUE))
obs.covs
#> $x3
#>      [,1] [,2] [,3]
#> [1,]   -1    0    1
#> [2,]   -2    0    0
#> [3,]   -3    1    0
#> [4,]    0    0    0
#> 
#> $x4
#>      [,1] [,2] [,3]
#> [1,] "a"  "b"  "c" 
#> [2,] "d"  "b"  "a" 
#> [3,] "a"  "a"  "c" 
#> [4,] "a"  "b"  "a" 
#> 

umf <- unmarkedFrameOccu(y=y, siteCovs=site.covs, 
    obsCovs=obs.covs)   # organize data
#> Warning: obsCovs contains characters. Converting them to factors.
umf                     # look at data
#> Data frame representation of unmarkedFrame object.
#>   y.1 y.2 y.3 x1 x2 x3.1 x3.2 x3.3 x4.1 x4.2 x4.3
#> 1   1   1   0  1  A   -1    0    1    a    b    c
#> 2   0   0   0  2  B   -2    0    0    d    b    a
#> 3   1   1   1  3  A   -3    1    0    a    a    c
#> 4   1   0   1  4  B    0    0    0    a    b    a
summary(umf)            # summarize      
#> unmarkedFrame Object
#> 
#> 4 sites
#> Maximum number of observations per site: 3 
#> Mean number of observations per site: 3 
#> Sites with at least one detection: 3 
#> 
#> Tabulation of y observations:
#> 0 1 
#> 5 7 
#> 
#> Site-level covariates:
#>        x1       x2   
#>  Min.   :1.00   A:2  
#>  1st Qu.:1.75   B:2  
#>  Median :2.50        
#>  Mean   :2.50        
#>  3rd Qu.:3.25        
#>  Max.   :4.00        
#> 
#> Observation-level covariates:
#>        x3          x4   
#>  Min.   :-3.0000   a:6  
#>  1st Qu.:-0.2500   b:3  
#>  Median : 0.0000   c:2  
#>  Mean   :-0.3333   d:1  
#>  3rd Qu.: 0.0000        
#>  Max.   : 1.0000        
fm <- occu(~1 ~1, umf)  # fit a model