CigaretteDemand | R Documentation |
Determinants of cigarette demand for the 48 continental US States in 1995 and compared between 1995 and 1985.
data("CigaretteDemand", package = "ivreg")
A data frame with 48 rows and 10 columns.
Number of cigarette packs per capita sold in 1995.
Real price in 1995 (including sales tax).
Real per capita income in 1995.
Sales tax in 1995.
Cigarette-specific taxes (federal and average local excise taxes) in 1995.
Difference in log(packs)
(between 1995 and 1985).
Difference in log(rprice)
(between 1995 and 1985).
Difference in log(rincome)
(between 1995 and 1985).
Difference in salestax
(between 1995 and 1985).
Difference in cigtax
(between 1995 and 1985).
The data are taken from the online complements to Stock and Watson (2007) and
had been prepared as panel data (in long form) in CigarettesSW
from the AER package (Kleiber and Zeileis 2008). Here, the data are provided by
state (in wide form), readily preprocessed to contain all variables needed for
illustrations of OLS and IV regressions. More related examples from Stock and
Watson (2007) are provided in the AER package in StockWatson2007
.
A detailed discussion of the various cigarette demand examples with R code
is provided by Hanck et al. (2020, Chapter 12).
Online complements to Stock and Watson (2007).
Hanck, C., Arnold, M., Gerber, A., and Schmelzer, M. (2020). Introduction to Econometrics with R. https://www.econometrics-with-r.org/
Kleiber, C. and Zeileis, A. (2008). Applied Econometrics with R. Springer-Verlag
Stock, J.H. and Watson, M.W. (2007). Introduction to Econometrics, 2nd ed., Addison Wesley.
CigarettesSW
.
## load data
data("CigaretteDemand", package = "ivreg")
## basic price elasticity: OLS vs. IV
cig_ols <- lm(log(packs) ~ log(rprice), data = CigaretteDemand)
cig_iv <- ivreg(log(packs) ~ log(rprice) | salestax, data = CigaretteDemand)
cbind(OLS = coef(cig_ols), IV = coef(cig_iv))
## adjusting for income differences (exogenous)
cig_iv2 <- ivreg(log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome),
data = CigaretteDemand)
## adding a second instrument for log(rprice)
cig_iv3 <- update(cig_iv2, . ~ . | . + cigtax)
## comparison using heteroscedasticity-consistent standard errors
library("lmtest")
library("sandwich")
coeftest(cig_iv2, vcov = vcovHC, type = "HC1")
coeftest(cig_iv3, vcov = vcovHC, type = "HC1")
## long-run price elasticity using differences between 1995 and 1985
cig_ivdiff1 <- ivreg(packsdiff ~ pricediff + incomediff | incomediff + salestaxdiff,
data = CigaretteDemand)
cig_ivdiff2 <- update(cig_ivdiff1, . ~ . | . - salestaxdiff + cigtaxdiff)
cig_ivdiff3 <- update(cig_ivdiff1, . ~ . | . + cigtaxdiff)
coeftest(cig_ivdiff1, vcov = vcovHC, type = "HC1")
coeftest(cig_ivdiff2, vcov = vcovHC, type = "HC1")
coeftest(cig_ivdiff3, vcov = vcovHC, type = "HC1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.