Learn R Programming

ResourceSelection (version 0.1-3)

rsf: Resource Selection (Probability) Functions for Use-Availability Data

Description

Resource Selection (Probability) Functions for use-availability wildlife data as described in Lele and Keim (2006) and Lele (2009).

Usage

rsf(formula, data, B = 99, inits, method = "Nelder-Mead", 
control, model = TRUE, x = FALSE, ...)

rspf(formula, data, B = 99, link = "logit", inits, 
method = "Nelder-Mead", control, model = TRUE, x = FALSE, ...)

rsf.fit(X, Y, link = "logit", B = 99, 
inits, method = "Nelder-Mead", control, ...)

Arguments

formula
two sided model formula of the form y ~ x, where y is a vector of observations, x is the set of covariates.
data
data.
B
number of bootstrap iterations to make.
link
character, lype of link function to be used.
inits
initial values, optional.
method
method to be used in optim for numerical optimization.
control
control options for optim.
model
a logical value indicating whether model frame should be included as a component of the returned value
x
logical values indicating whether the model matrix used in the fitting process should be returned as components of the returned value.
Y
vector of observations.
X
covariate matrix.
...
other arguments passed to the functions.

Value

  • A list with class "rsf" or "rspf" containing the following components:
  • callthe matched call.
  • yvector from LHS of the formula.
  • coefficientsa named vector of coefficients.
  • std.errora named vector of standard errors for the coefficients
  • loglikthe maximized log-likelihood
  • resultsoptim results.
  • linkcharacter, value of the link function used.
  • controlcontrol parameters for optim.
  • initsinitial values used in optimization.
  • mcomponent for future developmen, currently it takes value 0.
  • npnumber of active parameters.
  • fitted.valuesvector of fitted values. These are relative selection values for RSF models, and probability of selection for RSPF models.
  • nobsnumber of used locations.
  • bootstrapcomponent to store bootstrap results if B>0.
  • convergedlogical, indicating convergence of the optimization.
  • formulathe formula supplied.
  • termsthe terms object used.
  • levelsa record of the levels of the factors used in fitting.
  • contraststhe contrasts used.
  • modelif requested, the model frame.
  • xif requested, the model matrix.

Details

The rsf function fits the Exponential Resource Selection Function (RSF) model to presence only data. The rspf function fits the Resource Selection Probability Function (RSPF) model to presence only data Link function "logit", "cloglog", and "probit" can be specified via the link argument. The rsf.fit is the workhorse behind the two functions. link="log" leads to Exponential RSF. LHS of the formula data must be binary, ones indicating used locations, while zeros indicating available location. For model description and estimation details, see Lele and Keim (2006) and Lele (2009).

References

Lele, S.R. (2009) A new method for estimation of resource selection probability function. Journal of Wildlife Management 73, 122--127. Lele, S. R. & Keim, J. L. (2006) Weighted distributions and estimation of resource selection probability functions. Ecology 87, 3021--3028.

Examples

Run this code
fun <- function(n.used, parms, data, m, link="logit") {
    X <- model.matrix(~., data)
    n.sites <- nrow(X)
    n.avail <- n.used * m
    linkinvfun <- binomial(link=make.link(link))$linkinv
    p <- drop(linkinvfun(X %*% parms))
    id1 <- sample.int(n.sites, n.used, replace = TRUE, prob = p)
    id2 = sample(n.sites, n.avail, replace = TRUE)
    data.frame(status=c(rep(1, n.used), rep(0, n.avail)), data[c(id1, id2),])
}
## settings
n.used <- 1000
m <- 10
n <- n.used * m
set.seed(1234)
x <- data.frame(x1=rnorm(n), x2=runif(n))
cfs <- c(1.5,-1,0.5)
## fitting Exponential RSF model
dat1 <- fun(n.used, cfs, x, m=m, link="log")
m1 <- rsf(status ~ .-status, dat1, B=0)
summary(m1)
## fitting Logistic RSPF model
dat2 <- fun(n.used, cfs, x, m=m, link="logit")
m2 <- rspf(status ~ .-status, dat2, B=0)
summary(m2)

Run the code above in your browser using DataLab