lmr {rchemo}R Documentation

Linear regression models

Description

Linear regression models (uses function lm).

Usage


lmr(X, Y, weights = NULL)

## S3 method for class 'Lmr'
coef(object, ...) 

## S3 method for class 'Lmr'
predict(object, X, ...)  

Arguments

X

For the main function: Training X-data (n, p). — For the auxiliary functions: New X-data (m, p) to consider.

Y

Training Y-data (n, q).

weights

Weights (n, 1) to apply to the training observations. Internally, weights are "normalized" to sum to 1. Default to NULL (weights are set to 1 / n).

object

For the auxiliary functions:A fitted model, output of a call to the main functions.

...

For the auxiliary functions: Optional arguments. Not used.

Value

For lmr:

coefficients

coefficient matrix.

residuals

residual matrix.

effects

component relating to the linear fit, for use by extractor functions.

rank

the numeric rank of the fitted linear model.

fitted.values

the fitted mean values.

assign

component relating to the linear fit, for use by extractor functions.

qr

component relating to the linear fit, for use by extractor functions.

df.residual

the residual degrees of freedom.

xlevels

(only where relevant) a record of the levels of the factors used in fitting.

call

the matched call.

terms

the terms object used.

model

the model frame used.

For coef.Lmr:

int

matrix (1,nlv) with the intercepts

B

matrix (n,nlv) with the coefficients

For predict.Lmr:

pred

A list of matrices (m, q) with the Y predicted values for the new X-data

Examples


n <- 8 ; p <- 3
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
y <- rnorm(n)
Y <- cbind(y, rnorm(n))
Xtrain <- X[1:6, ] ; Ytrain <- Y[1:6, ]
Xtest <- X[7:8, ] ; Ytest <- Y[7:8, ]

fm <- lmr(Xtrain, Ytrain)
coef(fm)

predict(fm, Xtest)

pred <- predict(fm, Xtest)$pred
msep(pred, Ytest)


[Package rchemo version 0.1-2 Index]