Description Usage Arguments Details Value Author(s) References See Also Examples
Simulate an object of class 'CMRCTData' suitable for a call to 'CMRFit'.
1 | CMRSimData(simvars, surv, capt, theta)
|
simvars |
an object of class 'CMRCTSimVars'. See '?CMRSimVars' for details. |
surv |
an object of class 'formula': a symbolic description of the true survival model to be used for simulating the data. |
capt |
an object of class 'formula': a symbolic description of the true capture model to be used for simulating the data. |
theta |
a vector (numeric) containing respectively the survival and capture parameters values. |
The variables names 'T' (time defined as factor), 't' (time defined as numeric) are reserved and should not be present in 'simvars'. They will be automatically generated when calling 'CMRSimData'.
An object of class 'CMRCTData'.
Hugues Santin-Janin (hugues_sj@yahoo.fr) and David Fouchet (david.fouchet@univ-lyon1.fr)
Fouchet D., Santin-Janin H., Sauvage F., Yoccoz N.-G. & Pontier D. (submitted) An R package for analyzing survival using continuous-time open capture-recapture models: an example with feral cats on sub-Antarctic islands.
CMRSimVars, CMRFit
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 | ## Not run:
##An example with simulated data
##Let define some arguments
start <- as.POSIXct(strptime("01/01/2000", "%d/%m/%Y"))
factind <- list(sex=c("M", "F"))
##numind <- list(weight=c(0.5, 4))
numtps <- list(rain=c(0, 100))
##Simulate the set of covariables
set.seed(123)
simvars <- CMRSimVars(n=15 , npop=4, start=start, step="6 months",
nstep=12, factind=factind, numtps=numtps, length="5 weeks",
clage=c(2), minage=0.1, maxage=20)
##Plot the simulated capture occasions
plot(simvars)
##True model
surv <- as.formula(~pop + age)
capt <- as.formula(~t)
##True model parameters values
#Survival parameters: Intercept, pop2, pop3, pop4, age1
surv.pars <- c(-2, 1.5, -0.1, -0.5, 0.3)
#Capture parameters: Intercept, t
capt.pars <- c(-1, 0.24)
theta <- c(surv.pars, capt.pars)
##Simulating a dataset
set.seed(456)
simdata <- CMRSimData(simvars=simvars, surv=surv, capt=capt, theta=theta)
##Plot the simulated capture occasions and capture histories
plot(simdata)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.