simulate.mlm: Simulate Responses from a Multivariate Linear Model

simulate.mlmR Documentation

Simulate Responses from a Multivariate Linear Model

Description

Simulate one or more sets of responses from a Multivariate Linear Model (mlm) object.

Usage

## S3 method for class 'mlm'
simulate(object, nsim = 1, seed = NULL, ...)

Arguments

object

a mlm object, typically the result of calling lm where the response is a matrix.

nsim

number of replicate datasets to simulate. If nsim is greater than 1, the output is arranged in a 3D array.

seed

an object specifying if and how the random number generator should be initialized (‘seeded’). Either NULL or an integer that will be used in a call to set.seed before simulating the response vectors. If set, the value is saved as the "seed" attribute of the returned value. The default, NULL will not change the random generator state, and return .Random.seed as the "seed" attribute, see ‘Value’

...

additional optional arguments.

Details

A simulate function for mlm objects, which simulates one or more sets of responses from a Multivariate Linear Model (mlm) object. If multiple sets of responses are requested, they are returned in a 3D array, with simulation number along the third dimension.

The weights argument is currently ignored – a constant variance-covariance matrix assumed for mlm.

Value

A matrix of simulated values for the response (or an array, for nsim greater than 1)

Author(s)

David Warton <david.warton@unsw.edu.au>

See Also

lm, simulate

Examples

# fit a mlm to iris data:
data(iris)
iris.mlm=lm(cbind(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width)~Species,data=iris)
# simulate new responses:
simulate(iris.mlm)


ecostats documentation built on Aug. 24, 2022, 9:07 a.m.

Related to simulate.mlm in ecostats...