[R] Problem with regression line

Eik Vettorazzi E@Vettor@zz| @end|ng |rom uke@de
Wed Apr 18 16:24:30 CEST 2018


Hi Anne,
I would suggest to change the linear model to lm(BloodPressure~Age), as
this model makes more sense in biological means (you would assume that
age influences pressure, not vice versa) and also obeys the statistical
assumption of weak exogeneity, that age can be measured without error,
at least compared to error-prone bp measures.

Cheers

Am 18.04.2018 um 16:07 schrieb Gerrit Eichner:
> Hi, Anne,
> 
> assign Age and Bloodpressure in the correct order
> to the axes in your call to plot as in:
> 
> plot(y = Age, x = BloodPressure)
> abline(SimpleLinearReg1)
> 
> 
>  Hth  --  Gerrit
> 
> ---------------------------------------------------------------------
> Dr. Gerrit Eichner                   Mathematical Institute, Room 212
> gerrit.eichner using math.uni-giessen.de   Justus-Liebig-University Giessen
> Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
> http://www.uni-giessen.de/eichner
> ---------------------------------------------------------------------
> 
> 
> Am 18.04.2018 um 15:26 schrieb CHATTON Anne via R-help:
>> Hello,
>>
>> I am trying to graph a regression line using the followings:
>>
>> Age <- c(39, 47, 45, 47, 65, 46, 67, 42, 67, 56, 64, 56, 59, 34, 42,
>> 48, 45,
>> 17, 20, 19, 36, 50, 39, 21, 44, 53, 63, 29, 25, 69)
>> BloodPressure <- c(144, 220, 138, 145, 162, 142, 170, 124, 158, 154, 162,
>> 150, 140, 110, 128, 130, 135, 114, 116, 124, 136, 142, 120, 120, 160,
>> 158,
>> 144, 130, 125, 175)
>> SimpleLinearReg1=lm(Age ~ BloodPressure)
>> summary(SimpleLinearReg1)
>> eq = paste0("y = ", round(coeff[2],1), "*x ", round(coeff[1],1))
>> plot(Age, BloodPressure, pch = 16, cex = 1.3, col = "blue",
>> main = eq, xlab = "Age (Year)", ylab = "Blood Pressure (mmHg)")
>> abline(SimpleLinearReg1, col="red")
>> mean(Age)
>> mean(BloodPressure)
>> abline(h=142.53, col="green")
>> abline(v=45.13, col="green")
>>
>> But I cannot get the regression line. Can anybody tell me what's wrong
>> with the codes ? I would appreciate very much. Thanks for any help.
>>
>> Anne
>>
>>     [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 

-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistrasse 52
building W 34
20246 Hamburg

Phone: +49 (0) 40 7410 - 58243
Fax:   +49 (0) 40 7410 - 57790
Web: www.uke.de/imbe
--

_____________________________________________________________________

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Martina Saurin (komm.)
_____________________________________________________________________

SAVE PAPER - THINK BEFORE PRINTING


More information about the R-help mailing list