linear_model {OptimModel}R Documentation

Linear model, gradient, and starting values

Description

Linear model, gradient, and starting values.

Usage

 
        linear_model(theta, x)

Arguments

theta

Vector of model parameters intercept and slope. See details.

x

Matrix, possibly from model.matrix().

Details

The linear model is given by:

y = x * \theta \text{, where}

x is a matrix, possibly generated from model.matrix() \theta is a vector of linear parameters

Value

Let N = nrow(x). Then

Author(s)

Steven Novick

See Also

optim_fit, rout_fitter

Examples

set.seed(123)
d = data.frame( Group=factor(rep(LETTERS[1:3], each=5)), age=rnorm(15, mean=20, sd=3) )
d$y = c(80, 100, 120)[unclass(d$Group)] - 3*d$age + rnorm(nrow(d), mean=0, sd=5)

X = model.matrix(~Group+age, data=d)  ## This is the "x" in linear.model()
theta = c(80, 20, 40, -3)   ## Intercept, effect for B, effect for C, slope for age
linear_model(theta, x=X)
attr(linear_model, "gradient")(theta, x=X)
attr(linear_model, "start")(x=X, y=d$y)


[Package OptimModel version 2.0-1 Index]