Learn R Programming

stevemisc (version 1.8.0)

wls: Get Weighted Least Squares of Your OLS Model

Description

wls() takes an OLS model and re-estimates it using a weighted least squares approach. Weighted least squares is often a "textbook" approach to dealing with the presence of heteroskedastic standard errors, for which the weighted least squares estimates are compared to the OLS estimates of uncertainty to check for consistency or potential inferential implications.

Usage

wls(mod)

Value

wls() returns a new model object that is a weighted least squares re-estimation of the OLS model supplied to it.

Arguments

mod

a fitted OLS model

Author

Steven V. Miller

Details

The function should be robust to potential model specification oddities (e.g. polynomials and fixed effects). It also should perform nicely in the presence of missing data, if and only if na.action = na.exclude is supplied first to the offending OLS model supplied to the function for a weighted least squares re-estimation.

Examples

Run this code

M1 <- lm(mpg ~ ., data=mtcars)
M2 <- wls(M1)

summary(M2)

Run the code above in your browser using DataLab