Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

cls

Constrained least squares


Description

Constrained least squares.

Usage

cls(y, x, R, ca)

Arguments

y

The response variables, a numerical vector with observations.

x

A matrix with independent variables, the design matrix.

R

The R vector that contains the values that will multiply the beta coefficients. See details and examples.

ca

The value of the constraint, R^T β = c. See details and examples.

Details

This is described in Chapter 8.2 of Hansen (2019). The idea is to inimise the sum of squares of the residuals under the constraint R^T β = c. As mentioned above, be careful with the input you give in the x matrix and the R vector.

Value

A list including:

bols

The OLS (Ordinary Least Squares) beta coefficients.

bcls

The CLS (Constrained Least Squares) beta coefficients.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr

References

See Also

Examples

x <- as.matrix( iris[1:50, 1:4] )
y <- rnorm(50)
R <- c(1, 1, 1, 1)
cls(y, x, R, 1)

Rfast2

A Collection of Efficient and Extremely Fast R Functions II

v0.0.9
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Stefanos Fafalios and Marios Dimitriadis.
Initial release
2021-03-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.