uhcsimstrat: uhcsimstrat

Description Usage Arguments Details Value See Also Examples

Description

uhcsimstrat samples, randomly, locations from stratified test data.

Usage

1
uhcsimstrat(nsims, xmat, stratum, fit_ssf, z)

Arguments

nsims

The number of simulations (M) used to create the UHC plot.

xmat

A matrix of predictor variables in the test data.

stratum

The stratum identifiers associated with each point in xmat and z

fit_ssf

The fitted step-selection function object

z

A vector or matrix of (used & available) environmental characteristics in the test data set.

Details

This function samples, randomly, locations from stratified test data and returns an array of dimension nsims x nused_test x p (where p is the number of predictors to be validated)

Value

An array of dimensions nsims x nused_test x p.

See Also

Full archive of the data and code necessary to replicate the manuscript at http://doi.org/10.13020/D6T590.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Load example moose data
mdat <- moose12687

# Split into training and test datasets
mdat.train <- subset(mdat, year==2013)
mdat.test <- subset(mdat, year==2014)

# Fit step-selection function with all covariates (Full model)
ssf.train.full <- survival::clogit(presence ~ decid50 + mixed50 +
   conif50 + treedwet50 + step + strata(stratum),
   data = mdat.train)

# Fit step-selection function with only mixed50 (Reduced model)
ssf.train.reduc <- survival::clogit(presence ~ mixed50 +
   step + strata(stratum),
   data = mdat.train)

# Create design matrix from test data for Full model SSF
design.mat.full <- model.matrix(~decid50 + mixed50 +
  conif50 + treedwet50 + step -1,
  data = mdat.test)

# Create design matrix from test data for Reduced model SSF
design.mat.reduc <- model.matrix(~mixed50 + step -1, data = mdat.test)

# Create design matrix for covariates for z (matrix of used & available
# environmental characteristics in the test data set.)
z <- model.matrix(~decid50 + mixed50 + conif50 + treedwet50 + step -1,
   data = mdat.test)[,-5]

# Simulate data for Full model SSF
xhat.full <- uhcsimstrat(nsims = 1000,
  xmat = design.mat.full,
  stratum = mdat.test$stratum,
  fit_ssf = ssf.train.full,
  z = z)

# Simulate data for Reduced model SSF
xhat.reduc <- uhcsimstrat(nsims = 1000,
  xmat = design.mat.reduc,
  stratum = mdat.test$stratum,
  fit_ssf = ssf.train.reduc,
  z = z)

aaarchmiller/uhcplots documentation built on May 10, 2019, 2:05 a.m.