[R] Problem with regression line

CHATTON Anne Anne@Ch@tton @end|ng |rom hcuge@ch
Wed Apr 18 16:28:22 CEST 2018


Hi Gerrit!
Thank you so much! I mistakenly reversed the order of the variables of the regression. Actually what I meant to write was: lm(BloodPressure ~ Age).
Best,
Anne

-----Message d'origine-----
De : Gerrit Eichner [mailto:Gerrit.Eichner using math.uni-giessen.de] 
Envoyé : mercredi 18 avril 2018 16:08
À : CHATTON Anne; r-help using R-project.org
Objet : Re: [R] Problem with regression line

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.
> 


-- 

  Best regards  --  Gerrit
  Best regards  --  Gerrit Eichner
  Hth  --  Gerrit
  Viele Grüße  --  Gerrit
  Viele Grüße  --  Gerrit Eichner
  Viele Grüße  --  GE
  Freundliche Grüße  --  Gerrit Eichner
  Freundliche Grüße  --  GE
  Grüße  --  Gerrit
  Grüße  --  Gerrit Eichner
  Grüße  --  GE
  Gruß  --  G

---------------------------------------------------------------------
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
---------------------------------------------------------------------


More information about the R-help mailing list