clse: Constrained Least-Squares Estimates

Description Usage Arguments Value References Examples

View source: R/clse.R

Description

This function computes the constrained least-squares estimates when a subset of or all of the regression coefficients are constrained to be non-negative, as described in Fraser and Massam (1989).

Usage

1
clse(dat.obj)

Arguments

dat.obj

A list with the following format, list(y, mat, lam). Here y is the response vector, mat is the design matrix for the regression, and lam is a vector with the length that matches the number of columns in mat. The values of lam is either 0 or 1, with 0 means unconstrained and 1 means the corresponding regression coefficient is constrained to be non-negative.

Value

The returned value is a list with format, list(dat.obj, beta.vec, yhat). Here dat.obj is the input of the function, beta.vec gives the estimated regression coefficient, and yhat is the vector for the fitted response values.

References

Fraser, D. A. S. and H. Massam (1989). A mixed primal-dual bases algorithm for regression under inequality constraints. Application to concave regression. Scandinavian Journal of Statistics 16, 65-74.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#generate a dataset for illustration.
x=seq(1,10,,100)
y=x^2+rnorm(length(x))
#generate spline bases.
tmp=MIC.splines.basis.fast(x=x, df = 10, knots = NULL, boundary.knots=NULL,
type="Is",degree = 3,delta=0.001,eq.alloc=FALSE)
#plot the spline bases.
plot(tmp)
#generate the data object for the clse function.
dat.obj=list(y=y, mat=cbind(1, tmp$mat), lam=c(0, rep(1, ncol(tmp$mat))))
#fit clse.
fit=clse(dat.obj=dat.obj)
#visualize fitted results.
plot(x, y, pch=16)
lines(x, fit$yhat, lwd=3, col=2)

MICsplines documentation built on Sept. 7, 2021, 5:09 p.m.