unmarkedFramePCount.Rd
Organizes repeated count data along with the covariates.
This S4 class is required by the data argument of pcount
unmarkedFramePCount(y, siteCovs=NULL, obsCovs=NULL, mapInfo)
An RxJ matrix of the repeated count data, where R is the number of sites, J is the maximum number of sampling periods per site.
A data.frame
of covariates that vary at the
site level. This should have R rows and one column per covariate
Either a named list of data.frame
s of
covariates that vary within sites, or a data.frame
with
RxJ rows in site-major order.
Currently ignored
unmarkedFramePCount is the S4 class that holds data to be passed
to the pcount
model-fitting function.
an object of class unmarkedFramePCount
# Fake data
R <- 4 # number of sites
J <- 3 # number of visits
y <- matrix(c(
1,2,0,
0,0,0,
1,1,1,
2,2,1), nrow=R, ncol=J, byrow=TRUE)
y
#> [,1] [,2] [,3]
#> [1,] 1 2 0
#> [2,] 0 0 0
#> [3,] 1 1 1
#> [4,] 2 2 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 <- unmarkedFramePCount(y=y, siteCovs=site.covs,
obsCovs=obs.covs) # organize data
#> Warning: obsCovs contains characters. Converting them to factors.
umf # take a l
#> 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 2 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 2 2 1 4 B 0 0 0 a b a
summary(umf) # summarize data
#> 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 2
#> 4 5 3
#>
#> 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 <- pcount(~1 ~1, umf, K=10) # fit a model