Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m frustrated

Missing explanation in HF Data Analysis

HF Data Analysis: I am missing the information how to create the regression line on pages 297-298. Also, how to create the two regression lines on page 348 and the red areas on page 346. I found out how to create the simple regression line but not how to do the others...
1 person has
this question
+1
Reply
  • Hi Tom,

    The R functions you want to use are abline() to create the regression line and polygon() to create the red bars.

    abline() is pretty simple -- in this case it just takes a slope and intercept, which are part of the linear model (lm) object you create when you do a regression in R.

    As far as the two regression lines on p. 348 go, that's just two lines drawn with two linear models, each only covering the dependent variable range I wanted.

    Those red bar polygons are a little more complex, though. I'm pretty sure that when I created the bottom graphic on p. 346 I have a separate polygon drawn for each interval.

    I'd send you the code I used, but I don't think I have it any more. One of the creative challenges I had in writing those chapters was to show the cool stuff that R can do to get you enthusiastic about it while giving you enough implementation details to both have you using R and not forget about the more important regression learning that was the point of the chapter to begin with. In order to teach how to create the graphics you're wondering about, I'd have had to talk about so many details about how R works that you'd likely forget you were in a chapter about regression.

    If you are interested in learning more about R (which you should be!) I'd recommend checking out the video we launched last week (http://oreilly.com/catalog/0636920000891) or O'Reilly's book R in a Nutshell.

    Thanks for the question!

    Michael Milton
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly