Previous: Compatibility with sim() | Up: Compatibility with sim() | Next: Calculating Quantities of Interest |
Whether you choose to use the default method, or write a model-specific method for simulating parameters, these functions require the same three inputs:
There are two ways to simulate parameters:
coef.normal <- function(object) object$coefficients
vcov.normal <- function(object) object$variance
param.normal <- function(object, num = NULL, bootstrap = FALSE, terms = NULL) { if (!bootstrap) { par <- mvrnorm(num, mu = coef(object), Sigma = vcov(object)) Beta <- parse.par(par, terms = terms, eqn = "mu") sigma2 <- exp(parse.par(par, terms = terms, eqn = "sigma2")) res <- cbind(Beta, sigma2) } else { par <- coef(object) Beta <- parse.par(par, terms = terms, eqn = "mu") sigma2 <- exp(parse.par(par, terms = terms, eqn = "sigma2")) res <- c(coef, sigma2) } res }