Statistics with R (1) - Linear regression
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)
Comments
-
Easy and good starting point on R
-
@Christoph Scherber, thank you for video, it is really helpful. quick question, how do i run a regression plot that has labels for two specific points on the plot. in other words, how do i label specific points on the plot?
-
Thanks a ton, ur awesome
-
Thank you Christoph! Excellent introduction to R. Simiplicity is most effective for learning. :)
-
Very very helpful in explaining linear regression. Thank you.
-
SUPERefficient!!
-
thank you so much! I just wonder if you can explain me more how to interpret the line produced by the command termplot (model1), I didn't get it well
-
Great lesson ....thank you very much
-
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!
-
Thank you Christoph... I just had my first R class!
-
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?
. -
Does anyone have any experience with Version 3.3.0? I am having trouble with the "control R" part and calling data...
-
This is great!! Now I have a much better idea of what I'm doing in R. Thank you very much!!
-
Awesome, thank's a lot. Very helpful
-
Many thanks Mr Scherber.
-
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
> -
thank you..you have really been of great help to me
-
Thank you for this video, so useful. Do you have anything for multivariate multiple regression by any chance?
-
perfect for beginners.. i appreciate your work
-
Tks Mr. Scherber!
19m 22sLenght
702Rating