-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSeaWatchLinearRegression.Rmd
More file actions
129 lines (105 loc) · 1.97 KB
/
SeaWatchLinearRegression.Rmd
File metadata and controls
129 lines (105 loc) · 1.97 KB
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
---
title: "R Notebook"
output: html_notebook
---
SeaWatch Group Project
Target Variable: GROSS - We would like to predict the Gross donations for a given area.
```{r}
mydata <- na.omit(Seawatch_C_w_blanks[, 3:20])
str(mydata)
for (col in 2:ncol(mydata)){
hist(unlist(mydata[,col]),main = names(mydata[col]))
}
```
```{r}
hist(mydata[,2])
hist(as.numeric(unlist(mydata[,2])))
```
```{r}
attach(Seawatch_C_w_blanks)
hist(MON,nclass=30)
```
```{r}
hist(MOY,nclass=30)
```
```{r}
hist(POP80,nclass=30)
```
```{r}
mydata[mydata$POP80==max(mydata$POP80,na.rm=T),]
```
```{r}
cor(PERCAPI,HHMEDI,use="complete.obs")
```
```{r}
plot(GROSS,POVPR*POP80)
cor(GROSS,POVPR*POP80/100,use="complete.obs")
```
```{r}
plot(GROSS,POVPR)
cor(GROSS,POVPR,use="complete.obs")
```
We see that the correlation increaes when POPVR is expressed in numbers.
```{r}
plot(GROSS,MFGPR)
cor(GROSS,MFGPR,use = "complete.obs")
```
```{r}
plot(GROSS,MFGPR*POP80)
cor(GROSS,MFGPR*POP80,use="complete.obs")
```
```{r}
plot(GROSS,MAGE)
cor(GROSS,MAGE,use="complete.obs")
```
```{r}
min(MAGE,na.rm=TRUE)
```
```{r}
mydata[mydata$MAGE==min(mydata$MAGE,na.rm=T),]
```
```{r}
plot(CART,GROSS)
plot(REAG,GROSS)
plot(ANDR,GROSS)
cor(GROSS,CART,use="complete.obs")
cor(GROSS,REAG,use="complete.obs")
cor(GROSS,ANDR,use="complete.obs")
```
```{r}
cor(ANDR,CART,use="complete.obs")
cor(CART,REAG,use="complete.obs")
cor(REAG,ANDR,use="complete.obs")
```
```{r}
plot(CART,GROSS)
plot(CART/POP80,GROSS,xlim = c(0.1,2))
plot(REAG,GROSS)
plot(ANDR,GROSS)
na.omit(mydata[CART>POP80,])
install.packages("car")
library(car)
```
```{r}
mydata[GROSS==43,]
```
Fixing the wrong population data
```{r}
detach(Seawatch_C_w_blanks)
attach(mydata)
mydata$num_COLL<-COLLPR*POP80
model1<-lm(GROSS~POP80+MOY+CPI+num_COLL+PERCAPI)
describe(GROSS)
summary(model1)
```
```{r}
#cor(mydata,use="complete.obs")
mydata$VISIT<-as.factor(mydata$VISIT)
model1<-lm(GROSS~POP80+CPI+num_COLL+PERCAPI+VISIT)
summary(model1)
```
```{r}
plot(model1)
```
```{r}
```