sim.popn.secrgam: Generate a population using any density formula

Description Usage Arguments Details Value Examples

Description

description...

Usage

1
2
sim.popn.secrgam(fit = NULL, N = NULL, Dmodel = NULL, Dpars = NULL,
  Dlink = "log", mask = NULL)

Arguments

fit

a fitted secrgam or secr model

N

average abundance (converts density surface to relative density)

Dmodel

density model formula

Dpars

associated parameters for the density model

Dlink

link function (default is "log")

mask

mask object (as used by secrgam.fit and secr.fit)

log

if TRUE the log link is used, if FALSE the identity link is used

Details

details...

Value

value...

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
data(Boland.leopards1)
data(Boland.fits1)

# use a fitted model
popn = sim.popn.secrgam(fit1.a3) ; head(popn) ; dim(popn)
plot(fit1.a3, type = "density", asp = 1)
points(popn, cex = 0.5, pch = 19)

# use an inflated density surface from a fitted model
popn = sim.popn.secrgam(fit1.a3, N = 1000) ; head(popn) ; dim(popn)
plot(fit1.a3, type = "density", asp = 1)
points(popn, cex = 0.5, pch = 19)

## Not run: 
# use an alternative model
# e.g. construct a tensor product model to represent a bivariate normal
require(mvtnorm)
D = dmvnorm(Boland.mask1, apply(Boland.mask, 2, mean), 10e7 * diag(2)) * 10e6
N = sum(D) * attributes(Boland.mask)$area ; N # expected sample size
data = cbind(z = D, Boland.mask)
prep4image(data, key = FALSE, col = topo.colors(10), asp = 1)
model = D ~ te(x, y, k = 3)
fit = gam(model, gaussian(link = "log"), data, fx = TRUE)
prep4image(data.frame(x = data$x, y = data$y, z = fitted(fit)), key = FALSE, asp = 1)
popn = sim.popn.secrgam(Dmodel = model, Dpars = coef(fit), mask = Boland.mask1) ; head(popn) ; dim(popn)
points(popn, cex = 0.5, pch = 19)

## End(Not run)

david-borchers/secrgam documentation built on May 14, 2019, 9:30 p.m.