Learn R Programming

nlraa (version 1.2)

simulate_nls: Simulate fitted values from an object of class nls

Description

Simulate values from an object of class nls.

Usage

simulate_nls(
  object,
  nsim = 1,
  psim = 1,
  resid.type = c("none", "resample", "normal", "wild"),
  value = c("matrix", "data.frame"),
  data = NULL,
  ...
)

Value

It returns a vector with simulated values with length equal to the number of rows in the original data

Arguments

object

object of class nls

nsim

number of simulations to perform

psim

parameter simulation level, 0: for fitted values, 1: for simulation from fixed parameters (assuming a fixed vcov matrix), 2: simulation from sampling both from the parameters and the residuals, 3: for simulation considering the uncertainty in the residual standard error only (sigma) and fixing the parameter estimates at their original value; this will result in simulations similar to the observed values.

resid.type

either ‘none’, “resample”, “normal” or “wild”.

value

either ‘matrix’ or ‘data.frame’

data

the data argument is needed when using this function inside user defined functions.

...

additional arguments (it is possible to supply a newdata this way)

Details

This function is based on predict.gnls function

It uses function mvrnorm to generate new values for the coefficients of the model using the Variance-Covariance matrix vcov. This variance-covariance matrix refers to the one for the parameters ‘beta’, not the one for the residuals.

See Also

predict.gnls, predict_nls

Examples

Run this code
# \donttest{
data(barley, package = "nlraa")

fit <- nls(yield ~ SSlinp(NF, a, b, xs), data = barley)

sim <- simulate_nls(fit, nsim = 100)
# }

Run the code above in your browser using DataLab