143886View
19m 22sLenght
702Rating

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)