13 September 2014

Linear regression: Excel and R

(image from: en.wikipedia.org)

Dear friends,

Some of us think that point and click softwares are more efficient than their command line competitors. Here's a comparison.

Suppose you are going to make a linear regression between two variables, x and y, then make a plot out of it with regression line in the plot. 

In Ms Excel, you would do something like this:

1. Open the data:
  • Menu > 
  • Open > 
  • select the data
2. Making the plot: 

  • block the columns > 
  • insert chart > 
  • selecting chart type 
3. Making the regression line: 
  • selecting the points > 
  • insert > 
  • trend line > 
  • select linear regression > show equation
In R, you type the following lines:
  1. Open the data:
    • data <- read.csv="" yourdata.csv="">
  2. Making the model:
    • linear <- data="" li="" lm="" x="" y="">
    • summary(linear)
  3. Making the plot:
    • plot(data$y ~ data$x)
The point and click technique might be more efficient, but it is rather hard to be reproduced without having to screen capturing every step.
Post a Comment