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

View source: R/avm.fwls.R

avm.fwlsR Documentation

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)

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.

Value

Either an object of class "lm" (if fastfit is FALSE) or otherwise a generic list object

References

\insertAllCited

See Also

alvm.fit, anlvm.fit, avm.vcov

Examples

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))


skedastic documentation built on May 29, 2024, 12:20 p.m.