lmr: Linear regression models

View source: R/lmr.R

lmrR 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 functions: Training X-data (n, p). — For 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

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

...

Optional arguments. Not used.

Value

See the examples.

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)


mlesnoff/rchemo documentation built on April 15, 2023, 1:25 p.m.