Learn R Programming

EMLI (version 0.3.0)

generate_data: generate_data

Description

Generates data according to the single-output cumulative structural equation model with an additive-noise output measurement equation and assumptions of normality and independence, with given model parameter values.

Usage

generate_data(n, L, sigma, mu)

Value

An (n + 1) x (m + 1) data frame of numeric elements (except for row 1, columns 1 to m that contain NA's) containing observed input (columns 1 to m) and output (column m + 1) data.

Arguments

n

The number of time moments to generate the data for (vector of length 1, finite positive integer).

L

Factor loadings ((m + 1) x k matrix of finite numeric elements: the first m rows correspond to the input measurement equation; the last row corresponds to the transition equation).

sigma

Standard deviations of the error/noise terms ((m + 2) x 1 matrix of finite non-negative numeric elements: the first m rows correspond to the input measurement equation; the row before the last one corresponds to the transition equation; the last row corresponds to the output measurement equation).

mu

Intercept terms ((m + 1) x 1 matrix of finite numeric elements: the first m rows correspond to the input measurement equation; the last row corresponds to the transition equation).

Examples

Run this code
set.seed(1)

m <- 4
k <- 2

L <- matrix(runif((m + 1) * k, min = -10, max = 10), nrow = m + 1)
sigma <- matrix(runif(m + 2, min = 0, max = 10), nrow = m + 2)
mu <- matrix(runif(m + 1, min = -10, max = 10), nrow = m + 1)
generate_data(10, L, sigma, mu)

Run the code above in your browser using DataLab