Explanatory variable

Topic of Linear regression, part of Statistical inference · Also in Regression examples

Explanatory variable

Type Topic
Taught in Linear regression · Regression examples
Part Statistical inference · Data analysis
Questions using it 26

A variable x used to explain or predict a response y; also called a covariate or predictor. In a designed experiment it is set by the experimenter, in an observational study it is only recorded, and a fitted association with it is not by itself causal.

In Linear regression

Regression analysis explains a response variable by one or more explanatory variables. The name comes from Francis Galton, who noticed in the 1880s that the children of unusually tall parents are, on the whole, less unusually tall. A father 5% taller than average tends to have a son less than 5% taller than average. Galton called it regression towards mediocrity.

In Regression examples

A survey of 100 students recorded, among other things, each student’s height in centimetres, shoe size in centimetres and weight in kilograms. Does shoe size help predict height?

Example 1 (Height and shoe size) Question. Fit the regression of height on shoe size and interpret the output.

Solution.

survey <- read.csv("studentsurvey.csv")
model1 <- lm(height ~ shoe, data = survey)
summary(model1)
# Residuals:
#      Min       1Q   Median       3Q      Max
# -18.9073  -6.1465   0.1096   6.3626  22.6384
# Coefficients:
#             Estimate Std. Error t value Pr(>|t|)
# (Intercept) 145.7776     5.7629  25.296  < 2e-16 ***
# shoe          1.0048     0.2178   4.613  1.2e-05 ***
# Residual standard error: 9.299 on 98 degrees of freedom
# Multiple R-squared:  0.1784,  Adjusted R-squared:  0.17
# F-statistic: 21.28 on 1 and 98 DF,  p-value: 1.199e-05

The fitted line is height =145.78+1.005\times shoe size: each extra centimetre of shoe goes with about one more centimetre of height, on average. Reading the rest:

  • Residuals. The five-number summary of e_i=y_i-\widehat y_i. A median near 0 and quartiles roughly symmetric about it are what a normal error model predicts.
  • Coefficients. Each estimate comes with its standard error, the t statistic estimate divided by standard error, and the two-sided p-value for the hypothesis that the coefficient is zero. For the slope, t=1.0048/0.2178=4.61 on 98 degrees of freedom, so shoe size is clearly associated with height. The test for the intercept, that the mean height is zero at shoe size zero, is meaningless here and is ignored.
  • Residual standard error. The estimate S=9.3 cm of the error standard deviation \sigma: a typical student is about 9 cm from the line.
  • R^2. Shoe size accounts for 17.8% of the variation in height. The relationship is real but explains little; most of the variation is elsewhere.
  • F statistic. The test that every slope is zero. With one explanatory variable it is the square of the slope’s t, 4.613^2=21.28, with the same p-value.

Example 2 (Predicting a student’s height) Question. For a student with shoe size 30 cm, give a 95% interval for the mean height of such students, and a 95% interval for the height of one such student.

Solution.

predict(model1, data.frame(shoe = 30), interval = "confidence")
#        fit      lwr      upr
#   175.9217 173.4261 178.4172
predict(model1, data.frame(shoe = 30), interval = "prediction")
#        fit      lwr      upr
#   175.9217 157.2999 194.5434

The point prediction is 145.78+1.0048\times30=175.9 cm in both cases. The mean height of students with this shoe size is pinned down to within about 2.5 cm. A single student’s height is not: the prediction interval is (157.3,\ 194.5), about 37 cm wide, because a new student varies about the line with standard deviation near 9.3 cm whatever the sample size. The two intervals are the interval for the mean response and the prediction interval.

Used in

See also

Designed experiment · Adjusted R-squared · Confounding variable · Dummy variable coding · Generalised linear model · Linear predictor · Marginal model · Measurement error

Glossary and index