Skip to contents

Generates simulated data from a MARSS model with specified parameter estimates. This is a base function in the MARSS-package.

Usage

MARSSsimulate(object, tSteps = NULL, nsim = 1, silent = TRUE, 
    miss.loc = NULL)

Arguments

object

A fitted marssMLE object, as output by MARSS().

tSteps

Number of time steps in each simulation. If left off, it is taken to be consistent with MLEobj.

nsim

Number of simulated data sets to generate.

silent

Suppresses progress bar.

miss.loc

Optional matrix specifying where to put missing values. See Details.

Details

Optional argument miss.loc is an array of dimensions n x tSteps x nsim, specifying where to put missing values in the simulated data. If missing, this would be constructed using MLEobj$marss$data. If the locations of the missing values are the same for all simulations, miss.loc can be a matrix of dim=c(n, tSteps) (the original data for example). The default, if miss.loc is left off, is that there are no missing values even if MLEobj$marss$data has missing values.

Value

sim.states

Array (dim m x tSteps x nsim) of state processes simulated from parameter estimates. m is the number of states (rows in X).

sim.data

Array (dim n x tSteps x nsim) of data simulated from parameter estimates. n is the number of rows of data (Y).

MLEobj

The marssMLE object from which the data were simulated.

miss.loc

Matrix identifying where missing values were placed. It should be exactly the same dimensions as the data matrix. The location of NAs in the miss.loc matrix indicate where the missing values are.

tSteps

Number of time steps in each simulation.

nsim

Number of simulated data sets generated.

Author

Eli Holmes and Eric Ward, NOAA, Seattle, USA.

Examples

d <- harborSeal[, c(2, 11)]
dat <- t(d)
fit <- MARSS(dat)
#> Success! abstol and log-log tests passed at 26 iterations.
#> Alert: conv.test.slope.tol is 0.5.
#> Test with smaller values (<0.1) to ensure convergence.
#> 
#> MARSS fit is
#> Estimation method: kem 
#> Convergence test: conv.test.slope.tol = 0.5, abstol = 0.001
#> Estimation converged in 26 iterations. 
#> Log-likelihood: 11.74016 
#> AIC: -9.480311   AICc: -6.3692   
#>  
#>                                           Estimate
#> R.diag                                      0.0115
#> U.X.CoastalEstuaries                        0.0613
#> U.X.OR.NorthCoast                           0.0510
#> Q.(X.CoastalEstuaries,X.CoastalEstuaries)   0.0147
#> Q.(X.OR.NorthCoast,X.OR.NorthCoast)         0.0122
#> x0.X.CoastalEstuaries                       7.3823
#> x0.X.OR.NorthCoast                          6.2707
#> Initial states (x0) defined at t=0
#> 
#> Standard errors have not been calculated. 
#> Use MARSSparamCIs to compute CIs and bias estimates.
#> 

# simulate data that are the
# same length as original data and no missing data
sim.obj <- MARSSsimulate(fit, tSteps = dim(d)[1], nsim = 5)

# simulate data that are the
# same length as original data and have missing data in the same location
sim.obj <- MARSSsimulate(fit, tSteps = dim(d)[1], nsim = 5, miss.loc = dat)