knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ec1027

R-CMD-check Codecov test coverage

This package provides datasets and some functions to be used in the course EC1027 - Econometrics I.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("jcpernias/ec1027")

Datasets

The ec1027 package provides some datasets taken from Jeffrey M. Wooldridge (2006:) Introductory econometrics : a modern approach, 3rd ed., Thomson South-Western:

Note that the package wooldridge provides access to many more datasets. Also note that derived variables (logarithms, lags, etc) are not included in the ec1027 data sets.

Example

Load the ec1027 package and use data to bring one of the included data sets to the global environment.

library(ec1027)

## data on house prices
data(hprice1)

## Show the first observations
head(hprice1)

Code

Robust standard errors

Several functions have an vce parameter that allows the use of variance covariance estimators consistent in the presence of heteroskedasticity or autocorrelation.

Output from regression models is usually examined with the summary function:

mod <- lm(price ~ sqrft + bdrms + colonial, data = hprice1)

summary(mod)

But summary only shows the OLS standard errors of estimates. The coef_table function produces output similar to summary but allows other covariance matrix estimators:

# Heteroskedasticity consistent errors
coef_table(mod, vce = "HC")

Also, the se function computes standard errors robust to heteroskedasticity and autocorrelation. See more details in the documentation of this function.

Heteroskedasticity tests

The function white_test computes White's test for heteroskedasticity:

white_test(mod)

The function het_test computes LM tests for heteroskedasticity that allow the user to specify the variables related to hetroskedasticity.

# Using all covariates
het_test(mod)

# Using only sqrft and colonial
het_test(mod, ~ sqrft + colonial)

Hypotheses tests

The drop_test function performs a Wald test of the null joint hypotheses that the parameters of some variables are 0. The vce argument allows the use of alternative covariance matrix estimators.

# Joint significant test with the OLS covariance matrix estimator
drop_test(mod)

# Now using a heteroskedasticity consistent covariance matrix estimator
drop_test(mod, vce = "HC")

# Heteroskedasticity robust rest test on the joint signifinace of 
# bdrms and colonial
drop_test(mod, ~ bdrms + colonial, vce = "HC")


jcpernias/ec1027 documentation built on Dec. 20, 2021, 10:03 p.m.