Hello-
My question is a short one. How can I specify a single point which
through the fitted linear model has to go through? To illustrate my
problem, the fit to following data must go through the point
(-37.25(effect), 50(prob)). Note: you can ignore the label column.
Effect Prob Label
1 -1143.75 7.142857 L
2 -572.75 21.428571 D
3 -223.75 35.714286 GL
4 123.25 50.000000 DG
5 359.75 64.285714 G
6 374.75 78.571429 DGL
7 821.75 92.857143 DL
Thanks in advance!
Seth Imhoff
lm help: using lm when one point is known (not y intercept)
3 messages · Seth Imhoff, John Fox, Martin Maechler
Dear Seth, You don't say which variable is the explanatory variable and which is the response, but assuming that prob is to be regressed on effect, you can fit lm(prob - 50 ~ I(effect + 37.25) - 1). That is you can shift the point through which the regression is to go to the origin and then force the regression through the origin. I hope this helps, John -------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox --------------------------------
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Seth Imhoff
Sent: Saturday, November 27, 2004 11:09 PM
To: r-help at stat.math.ethz.ch
Subject: [R] lm help: using lm when one point is known (not y
intercept)
Hello-
My question is a short one. How can I specify a single point
which through the fitted linear model has to go through? To
illustrate my problem, the fit to following data must go
through the point (-37.25(effect), 50(prob)). Note: you can
ignore the label column.
Effect Prob Label
1 -1143.75 7.142857 L
2 -572.75 21.428571 D
3 -223.75 35.714286 GL
4 123.25 50.000000 DG
5 359.75 64.285714 G
6 374.75 78.571429 DGL
7 821.75 92.857143 DL
Thanks in advance!
Seth Imhoff
1 day later
"JohnF" == John Fox <jfox at mcmaster.ca>
on Sat, 27 Nov 2004 23:49:08 -0500 writes:
JohnF> Dear Seth,
JohnF> You don't say which variable is the explanatory
JohnF> variable and which is the response, but assuming that
JohnF> prob is to be regressed on effect, you can fit
JohnF> lm(prob - 50 ~ I(effect + 37.25) - 1). That is you
JohnF> can shift the point through which the regression is
JohnF> to go to the origin and then force the regression
JohnF> through the origin.
JohnF> I hope this helps,
yes, nice!
Even a bit more useful {though slightly uglier} is to use offset():
mfit <- lm(prob ~ offset(50+ 0*effect) + I(effect + 37.25) - 1)
such that e.g. predict(mfit, ...) will still predict 'prob'
Note however that for both solutions, the regression abline()
will look wrong {and I hoped it would also be ok when using offset()},
plot(prob ~ effect) ; abline(mfit)
Martin
JohnF> John
JohnF> --------------------------------
JohnF> John Fox
JohnF> Department of Sociology
JohnF> McMaster University
JohnF> Hamilton, Ontario
JohnF> Canada L8S 4M4
JohnF> 905-525-9140x23604
JohnF> http://socserv.mcmaster.ca/jfox
JohnF> --------------------------------
>> -----Original Message-----
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] lm help: using lm when one point is known (not y intercept)
>>
>> Hello-
>>
>> My question is a short one. How can I specify a single point
>> which through the fitted linear model has to go through? To
>> illustrate my problem, the fit to following data must go
>> through the point (-37.25(effect), 50(prob)). Note: you can
>> ignore the label column.
>>
>> Effect Prob Label
>>
>> 1 -1143.75 7.142857 L
>> 2 -572.75 21.428571 D
>> 3 -223.75 35.714286 GL
>> 4 123.25 50.000000 DG
>> 5 359.75 64.285714 G
>> 6 374.75 78.571429 DGL
>> 7 821.75 92.857143 DL
>>
>> Thanks in advance!
>>
>> Seth Imhoff