Description Usage Arguments Details Value Examples
View source: R/2DLTfunctions.r
Simulates n sighting locations (x,y) given a perp.dist distribution model and detection hazard model
1 2 |
n |
sample size |
ymin |
smallest forward distance |
b |
vector of detection hazard function parameters |
pi.x |
perpendicular distance distribution function |
logphi |
vector with log of pi.x parameters |
fix.n |
if TRUE sample size of exactly n is generated, else sample is generated from model with expected sample size n |
intscale |
amount by which to multiply detection location pdf f(x,y)
in order to get required sample size. Either an object of class
"ppscale" output by |
nbuffer |
amount by which to multiply the expected n by (given all model
parameters and intscale) to reduce probability that generated n is less
that n on first call to NHPP generating funciton rpoispp. If NULL,
it is set to 1.25 inside |
ymax |
largest forward distance |
W |
perpendicular truncation distance |
hfun |
detection hazard function |
Uses the spatstat
function rpoispp
to
generate detections from a NHPP, with intensity parameter such that the
expected (if fix.n is FALSE) or actual (if fix.n is TRUE) sample size is n.
a list object with element 1 a data.frame of simulated x
and y
sightings locations; element 2 spatstat
object of class "ppp" with x- and y-coordinates
of detections and element 2 simulation settings, comprising of n
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
# simulate with fixed n:
n=100;ymin=0.01;ymax=5;W=2
b=log(c(0.75,1));logphi=c(0.5,log(0.3))
dat=sim.n(n,ymin,ymax,W,h2,b,pi.norm,logphi)
dat$locs$n
plot(density(dat))
contour(density(dat),add=TRUE)
plot(dat,pch="+",cex=0.75,add=TRUE)
hist(abs(dat$y),xlab="Perpendicular distance",main="")
hist(dat$x,xlab="Forward distance",main="")
# do same with random n:
dat=sim.n(n,ymin,ymax,W,h2,b,pi.norm,logphi,fix.n=FALSE)
# compare time taken if calculate intscale on the run vs pass it:
# first calculate each time:
system.time(for(i in 1:20) dat<-sim.n(n,ymin,ymax,W,h2,b,pi.norm,logphi))
# then calculate once and pass:
intscale=calc.lpars(n,ymin,ymax,W,h2,b,pi.norm,logphi)
system.time(for(i in 1:20) dat<-sim.n(n,ymin,ymax,W,h2,b,pi.norm,logphi,intscale=intscale))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.