linearRegression: Run a linear regression with optional ridge regression

Description Usage Arguments Details Value Examples

View source: R/RcppExports.R

Description

Run a linear regression (with optional ridge regression)

Usage

1
linearRegression(matX, vecY, lambda = 0, intercept = TRUE)

Arguments

matX

A matrix of explanatory variables ('predictors') in standard R format (i.e. ‘tall and skinny'’ to be transposed internally to MLPACK format (i.e. '‘short and wide’).

vecY

A vector of dependent variables ('responses')

lambda

An optional ridge parameter, defaults to zero

intercept

An optional boolean switch about an intercept, default is true.

Details

This function performs a linear regression, and serves as a simple test case for accessing an MLPACK function.

Value

A vector with fitted values

Examples

1
2
3
4
5
6
7
8
9
suppressMessages(library(utils))
data("trees", package="datasets")
X <- with(trees, cbind(log(Girth), log(Height)))
y <- with(trees, log(Volume))
lmfit <- lm(y ~ X)
# summary(fitted(lmfit))
mlfit <- linearRegression(X, y)
# summary(mlfit)
all.equal(unname(fitted(lmfit)),  as.vector(mlfit))

eddelbuettel/rcppmlpack2 documentation built on Feb. 2, 2021, 1:51 a.m.