knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This package provides datasets and some functions to be used in the course EC1027 - Econometrics I.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("jcpernias/ec1027")
The ec1027
package provides some datasets taken from Jeffrey M. Wooldridge (2006:)
Introductory econometrics : a modern approach, 3rd ed., Thomson South-Western:
bwght
: Birth weight and cigarette smoking.
earns
: Earnings, productivity and hours (macro).
gpa1
: Gollege GPA and its predictors.
hprice1
: House prices and characteristics.
hseinv
: Housing investment and prices.
intdef
: Interest rates and Federal budget balance.
rdchem
: R & D and sales, chemical industry.
traffic2
: Speed limits and highway safety.
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.
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)
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.
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)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.