Learn R Programming

complexlm (version 1.1.2)

zmodel.matrix: Generate a Model Matrix (Design Matrix) Using Complex Variables

Description

A function that somewhat replicates model.matrix(), but accepts complex valued data. It will probably be slower and less efficient, but mostly functional. It cannot handle algebraic expressions in formula.

Usage

zmodel.matrix(trms, data, contrasts.arg = NULL)

Value

A model matrix, AKA a design matrix for a regression, containing the relevant information from data.

Arguments

trms

A "terms" object as generated by stats::terms().

data

A data frame containing the data referenced by the symbolic formula / model in trms.

contrasts.arg

a list, default is NULL. Not currently supported. See stats::model.matrix() for details.

See Also

Examples

Run this code
set.seed(4242)
slop <- complex(real = 4.23, imaginary = 2.323)
interc <- complex(real = 1.4, imaginary = 1.804)
tframe <- expand.grid(-3:3,-3:3)
Xt <- complex(real = tframe[[1]], imaginary = tframe[[2]])
tframe <- data.frame(Xt=Xt, Yt= Xt * slop + interc + complex(real=rnorm(length(Xt)),
 imaginary=rnorm(length(Xt))))
testterms <- terms(Yt ~ Xt)
zmodel.matrix(testterms, tframe)

Run the code above in your browser using DataLab