-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
160 lines (113 loc) · 4.07 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "",
fig.path = "man/figures/README-",
out.width = "100%",
fig.width = 7,
fig.height = 5,
dev = "png",
dpi = 600
)
```
# getspanel
<!-- badges: start -->
[![R build status](https://github.com/moritzpschwarz/getspanel/workflows/R-CMD-check/badge.svg)](https://github.com/moritzpschwarz/getspanel/actions)
[![CRAN status](https://www.r-pkg.org/badges/version/getspanel)](https://CRAN.R-project.org/package=getspanel)
<!-- badges: end -->
The package is a panel adaptation of the gets package [see here](https://CRAN.R-project.org/package=gets).
This code is being developed by Felix Pretis and Moritz Schwarz. The associated working paper is published under "Panel Break Detection: Detecting Unknown Treatment, Stability, Heterogeneity, and Outliers" by Pretis and Schwarz, which is available at SSRN [here](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4022745) and was applied to a study by Nico Koch and colleagues on EU Road CO~2~ emissions, which was [published in Nature Energy in 2022](https://www.nature.com/articles/s41560-022-01095-6).
## Installation
You can install the released version of getspanel from [CRAN](https://cran.r-project.org/package=getspanel) with:
``` r
install.packages("getspanel")
```
And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("moritzpschwarz/getspanel")
```
## Example
```{r example}
library(getspanel)
data("EU_emissions_road")
# let's subset a few countries to make this faster
subset <- c("Austria", "Belgium", "Germany", "Denmark", "Spain",
"France", "Greece", "Ireland", "Italy", "Netherlands", "Sweden", "United Kingdom")
EU_emissions_road <- EU_emissions_road[EU_emissions_road$country %in% subset, ]
is1 <- isatpanel(data = EU_emissions_road,
formula = transport.emissions ~ lgdp + lpop,
index = c("country","year"),
effect = "twoways",
fesis = TRUE,
print.searchinfo = FALSE # to save space we suppress the status information in the estimation
)
```
```{r example_textoutput}
is1
```
```{r example_plot}
plot(is1)
```
Let's explore the other plots that we can use:
```{r}
plot_grid(is1)
```
We can plot the counterfactuals as well:
```{r}
plot_counterfactual(is1, plus_t = 5)
```
We can plot the residuals against an OLS model:
```{r}
plot_residuals(is1)
```
An example using coefficient step indicator saturation and impulse indicator saturation:
```{r, results='hide'}
is2 <- isatpanel(data = EU_emissions_road,
formula = transport.emissions ~ lgdp + lpop,
index = c("country","year"),
effect = "twoways",
csis = TRUE,
iis = TRUE,
print.searchinfo = FALSE # to save space we suppress the status information in the estimation
)
```
```{r}
is2
plot(is2)
```
```{r}
plot_grid(is2)
```
and an example of Coefficient Fixed-Effect Step indicator saturation:
```{r, results='hide'}
is3 <- isatpanel(data = EU_emissions_road,
formula = transport.emissions ~ lgdp + lpop,
index = c("country","year"),
effect = "twoways",
cfesis = TRUE,
print.searchinfo = FALSE # to save space we suppress the status information in the estimation
)
```
```{r, results='hide'}
is3
plot(is3)
```
We can also use e.g. the `fixest` package to estimate our models:
```{r, results='hide'}
is4 <- isatpanel(data = EU_emissions_road,
formula = transport.emissions ~ lgdp + lpop,
index = c("country","year"),
effect = "twoways",
engine = "fixest",
fesis = TRUE,
print.searchinfo = FALSE # to save space we suppress the status information in the estimation
)
```
```{r, results='hide'}
plot(is4)
```