sim2fit
adds observation error to a simulated TVVAR process and
converts it to a form suitable for fitting with tvvarss
.
sim2fit(obj, n_sims, sd = 0.1, new_real = TRUE)
obj | A fitted |
---|---|
n_sims | The number of realizations of the TVVAR process. |
sd | The standard deviation of the Gaussian observation errors. Can be set to 0 for no observation error. |
new_real | If n_sims > 1, logical indicator of whether to base the new observations on a new realization of the TVVAR process. |
An array with dimensions c(n_sim, TT, n_spp)
.
This is a helper function that takes a fitted simTVVAR
object and
simulates multiple realizations of the process before adding Gaussian
obsveration errors.
set.seed(123) ## number of time steps TT <- 30 ## number of spp/guilds nn <- 4 ## CASE 1: linear food chain topo <- matrix(list(0), nn, nn) for (i in 1:(nn - 1)) { topo[i, i + 1] <- "td" topo[i + 1, i] <- "bu" } ## simulate process lfc <- simTVVAR(Bt = NULL, topo = topo, TT = 30, var_QX = rev(seq(1, 4) / 40), cov_QX = 0, var_QB = 0.05, cov_QB = 0) ## create data array with 3 realizations of the process dat <- sim2fit(lfc, 3)#> Error in simTVVAR(Bt = NULL, topo = topo, TT = 30, var_QX = rev(seq(1, 4)/40), cov_QX = 0, var_QB = 0.05, cov_QB = 0): object 'topo' not found