uhcsim: uhcsim

Description Usage Arguments Details Value See Also Examples

Description

uhcsim samples, randomly, locations from non-stratified test data.

Usage

1
uhcsim(nsims, nused_test, xmat, fit_rsf, z)

Arguments

nsims

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

nused_test

The number of used locations in the test data set.

xmat

A matrix of predictor variables in the test data.

fit_rsf

The fitted logistic regression model object

z

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

Details

This function samples, randomly, locations from non-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
# Simulate training data for the non-linear example
nonlinear.train <- uhcdatasimulator(nused = 100,
   navail = 10000,
   betas = c(2,-1),
   ntemp = 1000000,
   example = "non-linear")

# Simulate test data for the non-linear example
nonlinear.test <- uhcdatasimulator(nused = 100,
   navail = 10000,
   betas = c(2,-1),
   ntemp = 1000000,
   example = "non-linear")

# Fit GLM with quadratic relationship
train.correct <- glm(y~temp + I(temp^2),
   family = binomial,
   data = nonlinear.train)

# Fit GLM with linear (misspecified) relationship
train.misspec <- glm(y~temp,
   family = binomial,
   data = nonlinear.train)

# Simulate data for quadratic model
xhat.correct <- uhcsim(nsims = 1000,
   nused_test = 100,
   xmat = model.matrix(y~temp + I(temp^2), data = nonlinear.test)[,-1],
   fit_rsf = train.correct,
   z = as.matrix(nonlinear.test[,"temp"]))

# Simulate data for linear (misspecified) model
xhat.misspec <- uhcsim(nsims = 1000,
   nused_test = 100,
   xmat = as.matrix(model.matrix(y~temp, data = nonlinear.test)[,2]),
   fit_rsf = train.misspec,
   z = as.matrix(nonlinear.test[,"temp"]))

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