Statistics with R (1) - Linear regression

Christoph Scherber
Christoph Scherber
438.1 هزار بار بازدید - 11 سال پیش - In this video, I show
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)
11 سال پیش در تاریخ 1392/06/14 منتشر شده است.
438,174 بـار بازدید شده
... بیشتر