| To: | <s-news@wubios.wustl.edu>, <r-help@r-project.org> |
|---|---|
| Subject: | Constrained regression |
| From: | "Carlos Alzola" <calzola@cox.net> |
| Date: | Wed, 5 Mar 2008 08:36:46 -0500 |
| Thread-index: | Ach+Ne9702RnvvyaReiVAvPWKaA7lg== |
|
I would like to acknowledge the answers I received from Tom Filloon, Mike Cheung and Berwyn Turlach.
Berwyn's response is below G'day Carlos, On Mon, Mar 3, 2008 at 11:52 AM
> I am trying to get information on how to fit a linear regression with
A suggestion: > library(MASS) ## to access the Boston data
The solution seems to contain values that are, for all practical purposes, actually zero: > res$solution
So perhaps better: > zapsmall(res$solution)
So the estimates seem to follow the constraints. And the unconstrained solution is: > res$unconstrainted.solution
which seems to coincide with what lm() thinks it should be: > coef(lm(medv~., Boston))
So there seem to be no numeric problems. Otherwise we could have done something else (e.g calculate the QR factorization of the design matrix, say X, and give the R factor to solve.QP, instead of calculating X'X and giving that one to solve.QP). If the intercept is not supposed to be included in the set of constrained estimates, then something like the following can be done: > Amat[1,] <- 0
Of course, since after the first command in that last block the second column of Amat contains only zeros
Note, the Boston data set was only used to illustrate how to fit such models, I do not want to imply that these models are sensible for these data. :-) Hope this helps. Cheers, Berwin Carlos Alzola
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE Removing levels from a factor, gerald . jean |
|---|---|
| Next by Date: | Re: Removing levels from a factor, Terry Therneau |
| Previous by Thread: | Constrained regression, Carlos Alzola |
| Next by Thread: | Quintiles, Olanrewaju Sanni |
| Indexes: | [Date] [Thread] [Top] [All Lists] |