Learn R Programming

skedastic (version 2.0.2)

avm.fwls: Apply Feasible Weighted Least Squares to a Linear Regression Model

Description

This function applies feasible weighted least squares (FWLS) to a linear regression model using error variance estimates obtained from an auxiliary linear variance model fit using alvm.fit or from an auxiliary nonlinear variance model fit using anlvm.fit.

Usage

avm.fwls(object, fastfit = FALSE)

Value

Either an object of class

"lm"

(if fastfit is FALSE) or otherwise a generic list object

Arguments

object

Either an object of class "alvm.fit" or an object of class "anlvm.fit"

fastfit

A logical. If FALSE (the default), the linear regression model is fit using lm; otherwise, using lm.wfit

Details

The function simply calculates $$\hat{\beta}=(X'\hat{\Omega}^{-1}X)^{-1}X'\hat{\Omega}^{-1}y$$, where \(X\) is the design matrix, \(y\) is the response vector, and \(\hat{\Omega}\) is the diagonal variance-covariance matrix of the random errors, whose diagonal elements have been estimated by an auxiliary variance model.

References

See Also

alvm.fit, anlvm.fit, avm.vcov

Examples

Run this code
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
myalvm <- alvm.fit(mainlm = mtcars_lm, model = "linear",
   varselect = "qgcv.linear")
myfwls <- avm.fwls(myalvm)
cbind(coef(mtcars_lm), coef(myfwls))

Run the code above in your browser using DataLab