homevisits: A panel dataset of residential fires in 153 rescue service...

Description Usage Format Examples

Description

A panel dataset of residential fires in 153 rescue service confederations in Sweden (2000-2015).

Usage

1

Format

A data frame with N=153 units observed over T=17 years, containing the following variables:

year

actual year

id

unit id

rtjf_15

unit name

pop

population size

fires

number of residential fire events

treat

treatment unit dummy variable

post

post-intervention dummy, coded as 1 if year>=2010

Examples

 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
## Not run: 
#This code replicates the case study results from the paper (Bonander, in preparation).

data(homevisits) #Open the data

#Find the optimal value for k and estimate effects

firmod <- idd(eventvar="fires",
             popvar="pop",
             idvar="id",
             timevar="year",
             postvar="post",
             treatvar="treat",
             names="rtjf_15",
             data=homevisits)

firmod$id_controls #Show the selected controls

idd.kplot(firmod) #Plot the k-minimization function (figure 2)

#Reproduce figure 3 using grid and gridExtra

A <- idd.cfplot(firmod, mult=100000)
B <- idd.gplot(firmod, mult=100000)
B <- idd.pplot(firmod)

require(grid)
require(gridExtra)

grid.arrange(A, B, C, ncol=1)

#Perform the placebo studies (fair warning: 1000 iterations will take a while; expect 15-30 min)

set.seed(12049135) ##Set seed to replicate the results in the paper

placebt <- iddplacebo(eventvar="fires",
                     popvar="pop",
                     idvar="id",
                     timevar="year",
                     postvar="post",
                     treatvar="treat",
                     data=homevisits,
                     iter=1000)

#Reproduce figure 4

A2 <- iddplacebo.hist(placebt, convert=F, quantile=T)
B2 <- iddplacebo.hist(placebt, convert=T, quantile=T)
C2 <- iddplacebo.ecdf(placebt, convert=T, quantile=T)
grid.arrange(A2, B2, C2, ncol=1)

#Obtain placebo-based confidence intervals and p-values

pci <- placeboci(placebt, alpha=0.05)

#Reproduce figure 5

A1 <- placebo.ciplot(pci)
B1 <- placebo.pplot(pci)
grid.arrange(A1, B1, ncol=1)

##Other results and features

#Find the probability of finding a parametric p-value <=0.05 in the untreated units

mean(as.numeric(placebt$Resdata$param_p<=0.05))

#Generate a Synthetic control-style "spaghetti plot" to view the placebo effects

iddplacebo.spaghetti(placebt)

#Find the RMSE ratio for the treated unit

placebt$Treat.ratio

#Look at the raw data (without standardizing the matched controls to the level of the treated unit)

idd.dplot(firmod)

#Add a line for the entire donor pool for comparison

idd.dplot(firmod, donor=T)

## End(Not run)

carlbona/idd documentation built on May 19, 2019, 10:48 p.m.