Learn R Programming

activity (version 1.3)

fitact: Fit activity model to time-of-day data

Description

Fits kernel density to radian time-of-day data and estimates activity level from this distribution. Optionally: 1. bootstraps the distribution, in which case SEs and confidence limits are also stored for activity level and PDF; 2. weights the distribution; 3. truncates the distribution at given times.

Usage

fitact(dat, wt = NULL, reps = 999, bw = NULL, adj = 1,
  sample = c("none", "data", "model"), bounds = NULL, show = TRUE)

Arguments

dat

A numeric vector of radian time-of-day data.

wt

A numeric vector of weights for each dat value.

reps

Number of boostrap iterations to perform. Ignored if sample=="none".

bw

Numeric value for kernel bandwidth. If NULL, calculated internally.

adj

Numeric bandwidth adjustment multiplier.

sample

Character string defining sampling method for bootstrapping errors (see details).

bounds

A two-element vector defining radian bounds at which to truncate.

show

Logical whether or not to show a progress bar while bootstrapping.

Value

An object of type actmod

Details

When no bounds are given (default), a circular kernel distribution is fitted using dvmkern. Otherwise, a normal kernel distribution is used, truncated at the values of bounds, using density2.

The bandwidth adjustment multiplier adj is provided to allow exploration of the effect of adjusting the internally calculated bandwidth on accuracy of activity level estimates.

The alternative bootstrapping methods defined by sample are: none: no bootstrapping. data: sample from the data; model: sample from the fitted probability density distribution; Confidence interval coverage seems to be better at large sample size (greater than around 100) using "model", but better at small sample size when using "data".

Examples

Run this code
# NOT RUN {
#Fit without confidence limits
data(BCItime)
tm <- 2*pi*subset(BCItime, species=="brocket")$time
mod1 <- fitact(tm)
plot(mod1)

#Fit with confidence limits (limited reps to speed up)
mod2 <- fitact(tm, sample="data", reps=10)
plot(mod2)

#Fit weighted function to correct for detection radius 1.2 times higher
#by day than by night, assuming day between pi/2 (6 am) and pi*2/3 (6 pm)
weight <- 1/ifelse(tm>pi/2 & tm<pi*3/2, 1.2, 1)
mod3 <- fitact(tm, wt=weight)
plot(mod3)
#Overplot unweighted version for comparison
plot(mod1, add=TRUE, tline=list(col=2))

#Fit truncated function to consider only night time records,
#assuming night between pi*3/2 (6 pm) and pi/3 (6 am)
mod4 <- fitact(tm, bounds=c(pi*3/2, pi/2))
plot(mod4, centre="night")
# }

Run the code above in your browser using DataLab