-
Notifications
You must be signed in to change notification settings - Fork 0
/
204Hw3_script.Rmd
65 lines (48 loc) · 1.54 KB
/
204Hw3_script.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
---
title: "204Hw3"
author: "Casey Moorhead"
date: "5/15/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r data}
library(tidyverse)
# HW3Data <- read_csv("~/Desktop/ESM 204 - Econ/HW3Data.csv")
setwd("C:/github/esm204_HW3")
HW3Data <- read_csv("HW3Data.csv")
## Change character columns to factors columns and relevel
HW3Data$income<-factor(HW3Data$income, levels=c("poor","middle","rich","very_rich","one_percent"))
HW3Data$age<-factor(HW3Data$age,levels=c("tothirty","toforty","tofifty","tosixty","oversixty"))
levels(HW3Data$age)
class(HW3Data$age)
# Model using glm which is what is generally used for probability/binomial
# glm<-glm(vote~age+income+NEP+bid+risk, data=HW3Data, family="binomial")
# glm
# summary(glm)
```
```{r lm}
# Model using linear model b
datalm<-lm(vote~age+income+NEP+bid+risk, data=HW3Data, family="binomial")
summary(datalm)
# we must assume that anything above 0.5 is a yes vote
plot(datalm)
ggplot(data = datalm, aes(x=vote, y=bid))+
geom_line()
```
2.
```{r WTP_60%}
# reshuffle the equation to isolate bid (or price).
# Set risk at 60%
# determine the willingness to pay.
# calculate the vertical distance between the vertical distance between the original lm and the new
# lm with a risk value of 60%.
```
```{r pick3}
#value of a single prevented whale death
respondent1<-sample_n(HW3Data,1)
respondent2<-sample_n(HW3Data,1)
respondent3<-sample_n(HW3Data,1)
#plug in probability of yes based on calculation, and then calculate the WTP? Change risk to 60.
```