6
$\begingroup$

Can anyone expalin to me in simple terms what happens when we use weights in regsubsets or lm in R? What effect do weights have on a linear regression? for example :

Model1<-lm(Ozone~Solar.R,data=airquality)
summary(Model1)
#Coefficients:
#            Estimate Std. Error t value Pr(>|t|)    
#(Intercept) 18.59873    6.74790   2.756 0.006856 ** 
#Solar.R      0.12717    0.03278   3.880 0.000179 ***
Model1<-lm(Ozone~Solar.R,data=airquality,weights=(2*seq(nrow(airquality),1,-1)))
summary(Model1)
#Coefficients:
#            Estimate Std. Error t value Pr(>|t|)    
#(Intercept) 18.57106    6.26067   2.966 0.003704 ** 
#Solar.R      0.10824    0.02927   3.699 0.000341 ***

please explain the changes in intercepts and slope.

$\endgroup$
3
  • 1
    $\begingroup$ This is not a SO question -- what you're asking is how linear regression w/ or w/o weights works. But the simple answer: assigning weights is equivalent to adding more data points where you think the values are more reliable. $\endgroup$ Commented Mar 21, 2014 at 11:30
  • $\begingroup$ @CarlWitthoft that's not strictly true as the type of weighting used by R does't affect the df of the t-distribution. $\endgroup$
    – hadley
    Commented Mar 21, 2014 at 14:36
  • $\begingroup$ @hadley fair enough. I prob'ly should have written "sorta kinda like" instead of "equivalent to" . $\endgroup$ Commented Mar 21, 2014 at 16:15

2 Answers 2

7
$\begingroup$

Ordinary least squares minimizes the sum of squared residuals (residual = measured value - fitted value). Weighted least squares weights the sqared residuals. From help("lm"):

weighted least squares is used with weights weights (that is, minimizing sum(w*e^2))

$\endgroup$
1
$\begingroup$

In simple terms, it means that each data point is assigned a weight which either increases or decreases the influence of that data point on the final model. Thus the slope and intercept change as the raw data is not used, but rather the weighted data.

If you want more detailed information, I'd suggest stats.stackexchange.com This forum is really just for programming questions, not statistical questions (unless the two blend extensively).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.