Description Usage Arguments Details Value Note Author(s) References Examples
Y = X beta with x0 beta = y0 constraint.
1 | lmconst( y,x,x0,y0)
|
y |
length n vector: response Variablei |
x |
n by p matrix: corresponding Variables |
x0 |
p by l matrix: constraint beta coef |
y0 |
length l vector: value to constraints |
Use quadratic programming.
coef |
Constraint LSE/MLE(Normal assumption ). |
The function will only output the coefficients.
Yifan Yang
Richard Brent, Algorithms for minimization without derivatives, Prentice-Hall (1973), republished by Dover in paperback (2002), ISBN 0-486-41998-3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Example 1: dim =1
x=seq( 0,10,0.1)
y = matrix( 6*x+7+runif( 101,min=-1,max=1) ,ncol=1)
x=matrix( x,ncol=1)
re = lmconst( y,x,2,19)
re
re[ 1] +2*re[ 2]
# Example 2: multi dim
# R CMD check will skipp %...
#x = matrix(runif(100),ncol=2)
#y = x %*% c(6,2) +1 + rnorm( 50)
#re = lmconst(y=y,x=x,x0=c(2,1),y0=15)
#re
#re[1] +2*re[2] +re[ 3]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.