Simulates some data suitable for use in sparta The user defines the parameters for the data generation At present it works with just one species and generates the list length probabalistically
Usage
simOccData(
nsites = 20,
nvisits = 100,
nTP = 10,
psi = 0.5,
trend = -0.01,
mu.lp = -1,
tau.lp = 10,
beta1 = 182,
beta2 = 20,
beta3 = 100,
dtype2.p = 3,
dtype3.p = 10,
JD_range = NULL
)
Arguments
- nsites
numeric, the number of sites from which the simulated data is sampled.
- nvisits
numeric, the number of visits from which the simulated data is sampled.
- nTP
numeric, the number of time periods from which the simulated data is sampled.
- psi
probability of a site being occupied in time period 1.
- trend
the proportion of sites that change state each time period. For decreasing trends the probability of persistence from one time period to the next is 1 + the trend value. Probability of colonisation is 0. For increasing trends the probability of an unoccupied site being colonised from one time period to the next is the trend value. Probability of persistence is 1.
- mu.lp
the mean value for the normal distribution for the year effect (alpha.p) on the observation model.
- tau.lp
the precision value for the normal distribution for the year effect (alpha.p) on the observation model.
- beta1
the mean value for the normal distribution for the effect of Julian day on observation model.This must be a valid Julian date
- beta2
the standard deviation for the normal distribution for the effect of Julian day on observation model.
- beta3
parameter on the logit scale governing the magnitude of the Julian date effect on the observation model.
- dtype2.p
parameter (logit scale) for list length 2-3 on the observation model.
- dtype3.p
parameter (logit scale) for list length 4 on the observation model.
- JD_range
range of Julian dates upon which visits can take place. If this is null Julian date ranges between 1 and 365.
Value
A list, the first two elements of which ('spp_vis' & 'occDetData') mimic the output of occDetFunc. The third element ('Z') is the presence-absence state variable and the fourth ('p') is the true probability of detection.
Examples
if (FALSE) {
# set the sparta options
sparta_options <- c('ranwalk', # prior on occupancy is set by last year's posterior
'jul_date', # use the Julian date as a covariate on the detection probability
'catlistlength', # categorises the visits into three sets of 'qualities'
'halfcauchy') # prior on the precisions
# simulate some data
mydata <- simOccData(nvisit=200, nsite=10, nTP=5, psi=0.5, beta1=182, beta2=20, beta3=100)
with(mydata, plot(occDetdata$Jul_date, p))
# run the occupancy model model
out <- occDetFunc('mysp', mydata$occDetdata, mydata$spp_vis, n_iter = 1e4,
modeltype = sparta_options, return_data=TRUE)
out$BUGSoutput
plot_DetectionPhenology(out)
qplot(data=melt(out$BUGSoutput$sims.array), geom='line',
x=Var1, col=factor(Var2), y=value) +
facet_wrap(~Var3, ncol=4, scales='free')
}