-
Notifications
You must be signed in to change notification settings - Fork 0
/
tobit_quantile_analysis.Rmd
170 lines (143 loc) · 5.71 KB
/
tobit_quantile_analysis.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
159
160
161
162
163
164
165
166
167
168
169
170
---
title: "Tobit v.s. Quantile Analysis"
author: "Carver Coleman"
date: "April 1, 2020"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(knitr)
theme_set(theme_bw())
```
```{r echo = FALSE}
# Read in Simulation data
quantile <- read.csv("quantile.csv")
tobit <- read.csv("tobit.csv")
```
Regressions and Correlation Matrices
```{r}
tobit_bias_regression <- lm(Coefficient ~ Alpha + Omega + Cutoff, data = tobit)
summary(tobit_bias_regression)
tobit_mse_regression <- lm((Coefficient - .5)^2 ~ Alpha + Omega + Cutoff, data = tobit)
summary(tobit_mse_regression)
quant_bias_regression <- lm(Coefficient ~ Alpha + Omega + Cutoff, data = quantile)
summary(quant_bias_regression)
quant_mse_regression <- lm((Coefficient - .5)^2 ~ Alpha + Omega + Cutoff, data = quantile)
summary(quant_mse_regression)
kable(cor(quantile))
kable(cor(tobit))
```
Graphics:
Change in Alpha with cutoffs greater than or equal to top 75% of data
```{r}
# Calculate subsetted averages
tob <- tapply(tobit$Coefficient, tobit$Alpha, mean)
quant <- tapply(quantile$Coefficient, quantile$Alpha, mean)
# Create dataframe with bias and MSE
data <- data.frame(-3:3, tob - .5, (tob - .5)^2, "Tobit", row.names = 1:7)
data1 <- data.frame(-3:3, quant - .5, (quant - .5)^2, "Quantile", row.names = 1:nrow(data))
colnames(data) <- c("Alpha", "Bias", "MSE" , "Type")
colnames(data1) <- colnames(data)
final <- as.data.frame(rbind(data, data1))
# Bias graph
jpeg('alpha_bias.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final, aes(x = Alpha, y = Bias, color = Type)) +
geom_point() +
geom_path() +
geom_abline(mapping = aes(slope = 0, intercept = 0)) +
ylim(-.1, .1) +
labs(title = "Tobit and Quantile Bias for levels of Skewness")
dev.off()
# MSE graph
jpeg('alpha_mse.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final, aes(x = Alpha, y = MSE, color = Type)) +
geom_point() +
geom_path() +
geom_abline(mapping = aes(slope = 0, intercept = 0)) +
ylim(-.005, .005) +
labs(title = "Tobit and Quantile MSE for levels of Skewness")
dev.off()
```
Change in Omega with 75th Percentile and Above and Base Alpha level
```{r}
# Calculate subsetted averages
tobit_alpha <- subset(tobit, tobit$Alpha == 0)
tob <- tapply(tobit_alpha$Coefficient, tobit_alpha$Omega, mean)
quantile_alpha <- subset(quantile, quantile$Alpha %in% c(-2,-1,0,1,2))
quant <- tapply(quantile_alpha$Coefficient, quantile_alpha$Omega, mean)
# Create dataframe with bias and MSE
data <- data.frame(1:7, tob - .5, (tob - .5)^2, "Tobit", row.names = 1:nrow(data))
data1 <- data.frame(1:7, quant - .5, (quant - .5)^2, "Quantile", row.names = 1:nrow(data1))
colnames(data) <- c("Omega", "Bias", "MSE", "Type")
colnames(data1) <- colnames(data)
final <- as.data.frame(rbind(data, data1))
# Bias graph
jpeg('omega_bias.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final, aes(x = Omega, y = Bias, color = Type)) +
geom_point() +
geom_path() +
geom_abline(mapping = aes(slope = 0, intercept = 0)) +
ylim(-.1, .1) +
labs(title = "Tobit and Quantile Bias for levels of Spread",
subtitle = "With Non-extreme Skewness")
dev.off()
# MSE graph
jpeg('omega_mse.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final, aes(x = Omega, y = MSE, color = Type)) +
geom_point() +
geom_path() +
geom_abline(mapping = aes(slope = 0, intercept = 0)) +
ylim(-.0005, .0005) +
labs(title = "Tobit and Quantile MSE for levels of Spread",
subtitle = "With Non-extreme Skewness")
dev.off()
```
Change in Cutoff with Base Alpha level
```{r}
# Calculate subsetted averages
tobit_alpha <- subset(tobit, tobit$Alpha == 0)
tob <- tapply(tobit_alpha$Coefficient, tobit_alpha$Cutoff, mean)
quantile_alpha <- subset(quantile, quantile$Alpha %in% c(-2,-1,0,1,2))
quant <- tapply(quantile_alpha$Coefficient, quantile_alpha$Cutoff, mean)
# Create dataframe with bias and MSE
data <- data.frame(c(.65, .7, .75, .8, .85, .9, .95), tob - .5, (tob - .5)^2, "Tobit",
row.names = 1:nrow(data))
data1 <- data.frame(c(.65, .7, .75, .8, .85, .9, .95), quant - .5, (quant - .5)^2, "Quantile",
row.names = 1:nrow(data1))
colnames(data) <- c("Cutoff", "Bias", "MSE", "Type")
colnames(data1) <- colnames(data)
final <- as.data.frame(rbind(data, data1))
# Bias graph
jpeg('cutoff_bias.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final, aes(x = Cutoff, y = Bias, color = Type)) +
geom_point() +
geom_path() +
geom_abline(mapping = aes(slope = 0, intercept = 0)) +
ylim(-.1, .1) +
labs(title = "Tobit and Quantile Bias for Percentile Cutoff Levels",
subtitle = "With Non-extreme Skewness")
dev.off()
# MSE graph
jpeg('cutoff_mse.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final, aes(x = Cutoff, y = MSE, color = Type)) +
geom_point() +
geom_path() +
geom_abline(mapping = aes(slope = 0, intercept = 0)) +
ylim(-.0005, .0005) +
labs(title = "Tobit and Quantile MSE for Percentile Cutoff Levels",
subtitle = "With Non-extreme Skewness")
dev.off()
```
```{r}
quantile <- data.frame(quantile, "Type" = "Quantile")
tobit <- data.frame(tobit, "Type" = "Tobit")
final_data <- as.data.frame(rbind(quantile, tobit))
jpeg('density.jpg', quality = 100, width = 12, height = 8, units = "in", res = 300)
ggplot(final_data, aes(x = Coefficient - .5, color = Type)) +
geom_density() +
xlim(-5,5) +
xlab("Bias") +
labs(title = "Bias Density of Tobit v.s. Quantile Coefficients")
dev.off()
```