-
Notifications
You must be signed in to change notification settings - Fork 0
/
step-01.02-spells.RMD
149 lines (76 loc) · 1.94 KB
/
step-01.02-spells.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
---
title: "Spells"
author: "Jesse Lecy"
output:
html_document:
theme: readable
df_print: paged
highlight: zenburn
toc: true
self_contained: false
number_sections: false
css: clean.css
---
```
output: word_document
```
# SETUP
```{r, warning=FALSE, message=FALSE}
library( foreign )
library( memisc )
library( knitr )
library( dplyr )
library( xtable )
library( stargazer )
library( broom )
library( pander )
```
# LOAD DATA
```{r, warning=FALSE }
dat <- readRDS( "./Data/CompleteHazardSpells.rds" )
# lapply( dat, class )
#
# head( dat, 25 ) %>% pander
```
# SPELLS
## Inspect Spells
```{r}
dat.sub <- dat[ ,c("ein","fisyr","age","FS_Totrev_adj","prof","JustNowProfessionalized") ]
head( dat.sub, 100 ) %>% pander
```
## Typical Spell Lengths
NOTE - do we want to experiment with imputing observations backwards for sensitivity analysis?
NOTE - if we don't impute spell lengths backwards, should we set age to first year in dataset?
```{r}
# count of spells by length
table( table( dat$ein ) )
# proportion that professionalize
sum( dat$prof ) / length(unique(dat$ein))
```
Number that never professionalize - are right-censored because of end of study.
```{r}
sum( dat$prof == 0 & dat$age == 5 )
# 2815 that never professioalize
# 7744 orgs
2815 / 7744
```
Those that drop out before professionalization:
```{r}
do.prof <- tapply( dat$prof, dat$ein, sum )
these.do.not <- names(do.prof)[ do.prof == 0 ]
dat.not <- dat[ dat$ein %in% these.do.not , ]
nrow( dat.not )
table( tapply( dat.not$age, dat.not$ein, max ) )
2472 / 7744 # do not report (fail)
2815 / 7744 # right-censored (alive in 2003 but small)
2457 / 7744 # professionalize
table( tapply( dat.not$age, dat.not$ein, max ) ) /
table( dat$age )
```
## Observation Accounting
```{r}
table( dat$AGE )
table( dat$fisyr )
table( dat$age, dat$fisyr ) %>% kable
table( dat$fisyr, dat$prof ) %>% kable
```