[R] fix sign of a coefficient in formula
Peter Schmidtke
pschmidtke at mmb.pcb.ub.es
Thu Jan 20 10:21:17 CET 2011
Dear R users & experts,
I'd like to create a model using lm (or glm) under some constraints of
how coefficients for each component could look like (sort of a range of
coefficients that should be allowed).
So let's go for an example :
model=lm(age ~ eyecolor + height, data=inputdata)
So let's suppose that R pops out a model with positive estimates for the
coefficients eyecolor and height, I have to use them as is. But however,
if I'd like to produce a model that follows that behaviour :
age = A*eyecolor - B*height
having A>0 and B>0
how can I achieve that? I read about offsets, but I just know the range
of the coefficient, but not the exact value and doing something like
that offset(seq(-1,0,0.01)*height) doesn't seem to work in lm.
Thanks in advance for any hint!
Best regards.
--
Peter Schmidtke
PhD Student
Dept. Physical Chemistry
Faculty of Pharmacy
University of Barcelona
More information about the R-help
mailing list