-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
90 lines (60 loc) · 2.26 KB
/
README.Rmd
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
output:
github_document:
html_preview: false
---
# prais
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/prais)](https://cran.r-project.org/package=prais)
[![R-CMD-check](https://github.com/FranzMohr/prais/workflows/R-CMD-check/badge.svg)](https://github.com/FranzMohr/prais/actions)
## Overview
`prais` implements the Prais-Winsten estimator for models with strictly exogenous regressors and AR(1) serial correlation of the errors.
## Installation
### CRAN
```{r cran, eval = FALSE}
install.packages("prais")
```
### Development version
```{r github, eval = FALSE}
# install.packages("devtools")
devtools::install_github("franzmohr/prais")
```
## Usage
```{r usage, message = FALSE}
# Load the package
library(prais)
# Load the data
data("barium")
pw <- prais_winsten(lchnimp ~ lchempi + lgas + lrtwex + befile6 + affile6 + afdec6,
data = barium, index = "t")
summary(pw)
```
## Robust standard errors
### White's estimator
```{r, message = FALSE}
library(lmtest)
coeftest(pw, vcov. = vcovHC(pw, "HC1"))
```
### Panel-corrected standard errors (PCSE)
Estimate a panel model, for which PCSE should be obtained.
```{r, message = FALSE}
# Example 2 in the documentation of Stata function xtpcse
# Load data
data <- haven::read_dta("http://www.stata-press.com/data/r14/grunfeld.dta")
# Estimate
x <- prais_winsten(invest ~ mvalue + kstock, data = data, index = c("company", "year"),
twostep = TRUE, panelwise = TRUE, rhoweight = "T1")
# Results
summary(x)
```
Obtain PCSE by using only those residuals from periods that are common to all panels by setting `pairwise = FALSE`.
```{r}
coeftest(x, vcov. = vcovPC(x, pairwise = FALSE))
```
Obtain PCSE by using all observations that can be matched by period between two panels by setting `pairwise = TRUE`.
```{r}
coeftest(x, vcov. = vcovPC(x, pairwise = TRUE))
```
## References
Beck, N. L. and Katz, J. N. (1995): What to do (and not to do) with time-series cross-section data. American Political Science Review 89, 634-647.
Prais, S. J. and Winsten, C. B. (1954): Trend Estimators and Serial Correlation. Cowles Commission Discussion Paper, 383 (Chicago).
Wooldridge, J. M. (2016). Introductory Econometrics. A Modern Approach. 6th ed. Mason, OH: South-Western Cengage Learning.