clm: Fitting linear models under constraints

View source: R/clm.R

clmR Documentation

Fitting linear models under constraints

Description

clm (constrained linear model) is used to fit linear models under constraints on the coefficients. It uses quadratic programming to run a regression on data with a specified formula, subject to the constraint that the coefficients of the regression sum to 1 (in the future could support arbitrary constraints on the coefficients).

Usage

clm(formula, data, ...)

Arguments

formula

An object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

A data frame (or object coercible by as.data.frame to a data frame) containing the variables in the model.

...

Further arguments passed to or from other methods.

Value

clm returns an object of class "clm". An object of class "clm" is a list containing at least the following components:

solution a vector of coefficients for the constrained solution
unconstrined.solution a vector of coefficients for the unconstrained solution
formula the formula passed clm

See Also

lm, solve.QP

Examples

## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
df <- data.frame(weight = c(ctl, trt), group = c(rep(0, 10), rep(1, 10)))
lm.D9 <- clm(weight ~ group, df)

langcog/langcog-package documentation built on March 28, 2024, 9:52 a.m.