Learn R Programming

spaMM (version 2.1.0)

simulate.HLfit: Simulate realizations of a fitted model.

Description

From an HLfit object, simulate.HLfit function generates new samples given the estimated fixed effects and dispersion parameters. Simulation may be conditional on the predicted values of random effects, or unconditional. Simulations may be run for the original values of fixed-effect predictor variables and of random effect levels (spatial locations for spatial random effects), or for new values of these. However, conditional simulation in mixed models with new such values is not yet handled.

Usage

# S3 method for HLfit
simulate(object, nsim = 1, seed = NULL, newdata=NULL,
                         conditional=FALSE, verbose=TRUE,
                         sizes = NULL, ...)
# S3 method for HLfitlist
simulate(object, nsim = 1, seed = NULL, 
                             newdata=object[[1]]$data, sizes=NULL, ...)

Arguments

object

The return object of HLfit or similar function.

nsim

number of response vectors to simulate. Defaults to '1'.

seed

A seed for set.seed. If such a value is provided, the initial state of the random number generator at a global level is restored on exit from simulate.

newdata

A data frame closely matching the original data, except that response values are not needed. May provide new values of fixed predictor variables, new spatial locations, or new individuals within a block.

conditional

Boolean; whether to run conditional or unconditional simulation.

verbose

Boolean; whether to print some information or not.

sizes

A vector of sample sizes to simulate in the case of a binomial fit. Defaults to the sizes in the original data.

further arguments passed to or from other methods.

Value

For the HLfitlist method (i.e., the result of a multinomial fit), a list of simulated responses. Otherwise, a vector (if nsim=1) or a matrix with nsim columns, each containing a simulated response.

Examples

Run this code
# NOT RUN {
data(Loaloa)
HLC <- HLCor(cbind(npos,ntot-npos)~Matern(1|longitude+latitude),
           data=Loaloa,family=binomial(),
           ranPars=list(lambda=1,nu=0.5,rho=1/0.7)) 
simulate(HLC,nsim=2)
# }

Run the code above in your browser using DataLab