In this video, I show how to use R to fit a linear regression model using the lm() command. I also introduce how to plot the regression line and the overall arithmetic mean of the response variable, and I briefly explain the use of diagnostic plots to inspect the residuals. Basic features of the R interface (script window, console window) are introduced.

The R code used in this video is:

data(airquality)

names(airquality)

#[1] “Ozone” “Solar.R” “Wind” “Temp” “Month” “Day”

plot(Ozone~Solar.R,data=airquality)

#calculate mean ozone concentration (na´s removed)

mean.Ozone=mean(airquality$Ozone,na.rm=T)

abline(h=mean.Ozone)

#use lm to fit a regression line through these data:

model1=lm(Ozone~Solar.R,data=airquality)

model1

abline(model1,col=”red”)

plot(model1)

termplot(model1)

summary(model1)

Thanks a ton, ur awesome

Thank you very much, everything works pretty well, now I understand at least some stuff in R.

thank you

Hello, please come back and make more vidoes on R we really need you Sir.

Thank you Christoph! Excellent introduction to R. Simiplicity is most effective for learning.

This is great!! Now I have a much better idea of what I’m doing in R. Thank you very much!!

Sir, Please post the tutorial for user defined function for Simple Linear Regression in R without using any R packages or library.

great

Does anyone have any experience with Version 3.3.0? I am having trouble with the “control R” part and calling data…

Very nice! Good job..

Many thanks Mr Scherber.

A very helpful video for me! Thanks a lot Mr. Scherber. Please would you mind helping me with K-Fold Cross-validation (k = 10) or LOOCV or Validation Set Approach? How to use them to perform regression models, specifically the -kFold CV?

.

perfect for beginners.. i appreciate your work

Thank you!

Awesome, thank’s a lot. Very helpful

I don’t have the data sets

After writing data which button u press to pops up data set range plz help me???????

Thanks a lot, this is really easy to follow.

woow! what an incredible tutorial. This the best, I really appreciate your work Christoph

Super Video, vielen Dank aus Bayern!

thank you..you have really been of great help to me

Very helpful tutorial. Any tips on sourcing data directly from an excel spreadsheet(s) to run regressions in R?

Easy and good starting point on R

SUPERefficient!!

I am sure this is a great tutorial but in my case when I use the plot command, it keeps on saying object ‘Ozone’ not found (Please help, if possible):

My editor: data(airquality)

names(airquality)

#Ozone” “Solar.R” “Wind” “Temp” “Month” “Day”

plot(Ozone,Solar.R, data=airquality)

My R Console

> data(airquality)

> names(airquality)

[1] “Ozone” “Solar.R” “Wind” “Temp” “Month”

[6] “Day”

> plot(Ozone,Solar.R)

Error in plot(Ozone, Solar.R) : object ‘Ozone’ not found

> plot(Ozone,Solar.R, data=airquality)

Error in plot(Ozone, Solar.R, data = airquality) :

object ‘Ozone’ not found

>

This video is extremely helpful! Thanks a lot! Can I have anther question for you? Assume I have 3 columns. Id,price and date. I want to run regression model between price and date, but under the condition that they have the same id. In another word, I want to see all the regression result that are grouped by different id. What codes should I put there? Wish you could help me! Thanks a lot!

Great lesson ….thank you very much

AAUERRR

Truly informative, thank you, you explain so well

Thanks so much!

Very very helpful in explaining linear regression. Thank you.