lmHetero: Function: Multiplicately weighted regression model

Description Usage Arguments Details Value Author(s) Source Examples

View source: R/lmHetero.R

Description

lmHetero accounts for heteroscedasticity in regression models

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
lmHetero(
  formula,
  hetero = ~1,
  data,
  subset,
  na.action,
  contrasts = NULL,
  iter = FALSE,
  ...
)

Arguments

formula

Formula object (perhaps, multiple parts formula y~x1+x2+...| log(z1)+log(z2)+...) linking the dependent variable to its set of associated independent variables x and a second expression separated by | modelling the local variances with the variables z. The formula y~x1+x2+... assumes homoscedasticity. Important: the weights variables z must be entered in their log-transformed form! This is the preferred specification of the function call.

hetero

Optional formula specification without "| log(z1)+log(z2)+...": A second parameter modeling the heteroscedasticity with a right-handed formula by a set of variables z. That is, "hetero=~log(z1)+log(z2)+...". Omitting the second parameter assumes "hetero=~1". This is only included for backward compatibility).

data

An optional data frame containing the variables in the model. By default the variables are taken from the environment of the formula.

subset

An optional vector specifying a subset of observations to be used in fitting the model.

na.action

A function that indicates what should happen when the data contain NAs. The default is set by the "na.action" option

contrasts

An optional list. See the "contrasts.arg" of model.matrix.default.

iter

Logical indicating whether the interation history should be displayed. The default setting if "FALSE".

...

Currently not in use.

Details

This function estimates the parameters of a regression model whose normally distributed disturbances have a variance that multiplicatively depends on a set of strictly positive weights variables. That is,

σ^2_i = \exp(γ_0 + γ_1 \cdot \log(z_{i1}) + ...)

The weights variables z must be entered in their logarithmic forms. The paramater \exp(γ_0) expresses the global variance.

Value

a list with 10 elements:

CALL

function call

sigma2

global variance estimate exp(gamma_0)

gamma

vector of estimated gamma coefficients

namesGamma

vector of variable names expressed by Z

beta

vector of estimated weight adjusted regression parameters

weights

vector of weights 1/σ^2_i estimates for each observation. It can be used in the call lm(..., weights=weights) to adjust for heteroscedasticity

covBeta

covariance matrix of the estimated regression coefficients

covGamma

covariance matrix of the estimated gamma coefficients

logLikeH1

log-likelihood of the heteroscedastic adjusted regression model

logLikeH0

log-likelihood of the unadjusted regression model

Author(s)

Michael Tiefelsdorf (tiefelsdorf@utdallas.edu) & Yongwan Chun

Source

The maximum likelihood estimation procedure for multiplicately weighted regression is given in Greene W. H. (2000). Econometric Analysis. 4th edition. Upper Saddle River: Prentice Hall. pp 516-521 (Note: page numbers will differ for other editions)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(sp)
data(tractShp)
validTractShp <- tractShp[!is.na(tractShp$BUYPOW), ]         # Remove 2 tracts with NA's
## Population at risk
totPop <- validTractShp$MALE+validTractShp$FEMALE

## H0 model (homoscedasticity)
mod.lm <- mod.lmH <- lmHetero(PERCAPINC~PCTNOHINS+PCTMINOR+PCTUNIVDEG+PCTWHITE,
                              data=validTractShp)
summary(mod.lm)

## Preferred heteroscedasticiy function call
mod.lmH <- lmHetero(PERCAPINC~PCTNOHINS+PCTMINOR+PCTUNIVDEG+PCTWHITE|log(totPop),
                    data=validTractShp)
summary(mod.lmH)

## Alternative equivalent heteroscedasticiy function call
mod.lmH <- lmHetero(PERCAPINC~PCTNOHINS+PCTMINOR+PCTUNIVDEG+PCTWHITE, hetero=~log(totPop),
                    data=validTractShp)
summary(mod.lmH)

## Use estimated weights as input for weighted lm-model.
## This also to perform further model diagnostics.
mod.lmW <- lm(PERCAPINC~PCTNOHINS+PCTMINOR+PCTUNIVDEG+PCTWHITE, weights=mod.lmH$weights,
              data=validTractShp)
summary(mod.lmW)
hist(weighted.residuals(mod.lmW))

TexMix documentation built on March 1, 2020, 5:10 p.m.