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, m, B = 99, inits, method = "Nelder-Mead",
control, model = TRUE, x = FALSE, ...)
rspf(formula, data, m, B = 99, link = "logit", inits,
method = "Nelder-Mead", control, model = TRUE, x = FALSE, ...)
rsf.fit(X, Y, m, 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.
m
argument describing the matching of use and available points.
All available points are used for each use points if m=0
(global availability). If m is a single value, e.g. m=5,
it is assumed that available data points are grouped in batches of 5,
e.g. with IDs c(1,2) for used point locations and
c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2) for available locations
(local availability, matched use-available design).
Similarly, a vector of matching IDs can also be provided, e.g.
c(1, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2) by combining the above two.
This potentially could allow for unbalanced matching and for easier
subsetting of the data, but comes with an increased computing time.
data
data.
B
number of bootstrap iterations to make.
link
character, type 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.
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).
Value
A list with class "rsf" or "rspf"
containing the following components:
call
the matched call.
y
vector from LHS of the formula.
coefficients
a named vector of coefficients.
std.error
a named vector of standard errors
for the coefficients
loglik
the maximized log-likelihood
results
optim results.
link
character, value of the link function used.
control
control parameters for optim.
inits
initial values used in optimization.
m
value of the m argument with possibly matched
use-available design.
np
number of active parameters.
fitted.values
vector of fitted values. These are relative
selection values for RSF models, and probability of selection for
RSPF models.
nobs
number of used locations.
bootstrap
component to store bootstrap results if B>0.
converged
logical, indicating convergence of the optimization.
formula
the formula supplied.
terms
the terms object used.
levels
a record of the levels of the factors used in fitting.
contrasts
the contrasts used.
model
if requested, the model frame.
x
if requested, the model matrix.
Author(s)
Subhash R. Lele, Jonah L. Keim, Peter Solymos
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
## 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 <- simulateUsedAvail(x, cfs, n.used, m, link="log")
m1 <- rsf(status ~ .-status, dat1, m=0, B=0)
summary(m1)
## fitting Logistic RSPF model
dat2 <- simulateUsedAvail(x, cfs, n.used, m, link="logit")
m2 <- rspf(status ~ .-status, dat2, m=0, B=0)
summary(m2)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ResourceSelection)
ResourceSelection 0.2-6 2016-02-15
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ResourceSelection/rsf.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rsf
> ### Title: Resource Selection (Probability) Functions for Use-Availability
> ### Data
> ### Aliases: rsf.fit rsf rspf
> ### Keywords: htest
>
> ### ** Examples
>
> ## 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 <- simulateUsedAvail(x, cfs, n.used, m, link="log")
> m1 <- rsf(status ~ .-status, dat1, m=0, B=0)
> summary(m1)
Call:
rsf(formula = status ~ . - status, data = dat1, m = 0, B = 0)
Resource Selection Function (Exponential RSF) model
Non-matched Used-Available design
Maximum Likelihood estimates
Fitted values:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.03486 0.68980 1.36000 2.39400 2.77200 40.60000
Coefficients (log link):
Estimate Std. Error z value Pr(>|z|)
x1 -1.00315 0.03238 -30.979 < 2e-16 ***
x2 0.46940 0.10936 4.292 1.77e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Log-likelihood: -8714
BIC = 1.744e+04
Hosmer and Lemeshow goodness of fit (GOF) test:
X-squared = 3.765, df = 8, p-value 0.8776
> ## fitting Logistic RSPF model
> dat2 <- simulateUsedAvail(x, cfs, n.used, m, link="logit")
> m2 <- rspf(status ~ .-status, dat2, m=0, B=0)
> summary(m2)
Call:
rspf(formula = status ~ . - status, data = dat2, m = 0, B = 0)
Resource Selection Probability Function (Logistic RSPF) model
Non-matched Used-Available design
Maximum Likelihood estimates
Fitted probabilities:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.1572 0.7945 0.8837 0.8474 0.9384 0.9962
Coefficients (logit link):
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.6406 0.7050 2.327 0.0200 *
x1 -1.0063 0.3983 -2.527 0.0115 *
x2 0.7426 0.8322 0.892 0.3722
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Log-likelihood: -9198
BIC = 1.842e+04
Hosmer and Lemeshow goodness of fit (GOF) test:
X-squared = 4.419, df = 8, p-value 0.8175
>
>
>
>
>
> dev.off()
null device
1
>