Simulate posum data {posum} | R Documentation |
population.data
simulates stage structured population data from the
model specified by rec
and pcdr
. Stages are really age classes, with the (lower) age
boundaries specified in sim.age.bound
.
population.data(t=(0:20)*5,ns=11,sc=1,fam="n",adult=FALSE) sim.age.bound(stage,t)
t |
The array of sample times at which simulated data are required (population.data )
or the array of times at which stage age boundaries are required (sim.age.bound ). |
ns |
The number of stages. |
sc |
The scale parameter for the noise to be added to the data. |
fam |
Specifies the noise family as one of "n" , "p" , or "g" ,
for normal, Poisson or gamma distributions. |
adult |
TRUE to simulate an adult final stage (i.e. indeterminate duration),
FALSE otherwise. |
stage |
which stage the lower age boundary is required for. |
Stage populations are obtained by integrating the populaiton surface model given by
population
(and based on pcdr
and rec
) between the age limits specified in
sim.age.bound
. Noise is added according to the specified distribution and scale parameter.
Integration is performed numerically using the trapezoidal rule.
sim.age.bound
returns an array of stage lower age boundaries.
population.data
returns a list object suitable for input to posum
. The items in
this list are:
y |
array of simulated stage populations. |
a0,a1 |
lower and upper age boundaries corresponding to the data in y . |
t |
sample times corresponding to data in y . |
stage |
stage index corresponding to data in y . |
Simon N. Wood snw@st-and.ac.uk
http://www.ruwpa.st-and.ac.uk/simon.html
death.surface
,
pcdr
,
population
,
population.surface
,
rec
,
survival
,
data<-population.data(fam="p",adult=TRUE) #simulate data b<-posum(data,fam="p") op<-par(mfrow=c(2,2)) posum.plot(b) plot(fitted(b),residuals(b)) plot(data$y,fitted(b)) par(mfrow=c(3,4)) posum.stage.plot(b) posum.stage(b,lo=1,hi=4) rm(data,b) par(op)