Skip to content

Question on quantiles for "by" variable #108

Answered by pbreheny
pbreheny asked this question in Q&A
Discussion options

You must be logged in to vote

The airquality data set has some missing data, which lm() throws out before fitting the model. The quantiles are calculated on the data that was actually used to fit the model:

airquality$Heat <- cut(airquality$Temp, 3, labels=c("Cool", "Mild", "Hot"))
fit <- lm(Ozone ~ Solar.R + Wind * Heat, data=airquality)
quantile(airquality$Wind, probs = c(.1, .5, .9))
#>   10%   50%   90% 
#>  5.82  9.70 14.90
quantile(model.frame(fit)$Wind, probs = c(.1, .5, .9))
#>  10%  50%  90% 
#>  5.7  9.7 14.9

Replies: 1 comment

Comment options

pbreheny
Apr 18, 2023
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by pbreheny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant