-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarch9.Rmd
More file actions
129 lines (83 loc) · 1.94 KB
/
Copy pathMarch9.Rmd
File metadata and controls
129 lines (83 loc) · 1.94 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
129
---
title: "March9"
author: "Gustavo Facincani Dourado"
date: "3/9/2020"
output: html_document
---
```{r setup, include=FALSE}
wq <- suppressMessages(read_csv("C:/Users/gusta/Desktop/PhD/Classes/ES207/BayDeltaWQ.csv", col_names = TRUE, na = c("NA", "n/p", "n/a"), guess_max = 30000))
```
```{r}
wq <- wq %>%
filter(StationCode %in% c("C3", "D10", "D4", "D22", "D12",
"D16", "D26", "D19", "MD10", "D28A",
"P8", "C10", "D7", "D8", "D6", "D41"))
wq <- wq %>%
select(2:6, Oxygen, pH, `Secchi Depth`, Temperature, Turbidity) %>%
na.omit()
wq
```
```{r}
ggplot(wq, aes(x = `Secchi Depth`, y = Turbidity)) +
geom_point(alpha = 0.2) + theme_bw()
```
```{r}
ggplot(wq, aes(x = log(`Secchi Depth`), y = log(Turbidity))) +
geom_point(alpha = 0.2) + theme_bw()
```
```{r}
lm1 <- lm(Turbidity ~ `Secchi Depth`, data = wq)
summary(lm1)
```
```{r}
lm2 <- lm(log(Turbidity) ~ log(`Secchi Depth`), data = wq)
summary(lm2)
```
```{r}
broom::tidy(summary(lm2))
```
```{r}
broom::glance(summary(lm2))
```
```{r}
ggplot(wq, aes(x = `Secchi Depth`, y = Turbidity)) + theme_bw() +
geom_point(alpha = 0.2) + geom_smooth(method = "lm") + ylim(c(0,400))
```
```{r}
ggplot(wq, aes(x = log(`Secchi Depth`), y = log(Turbidity))) + theme_bw() +
geom_point(alpha = 0.2) + geom_smooth(method = "lm", se = TRUE)
```
```{r}
d <- broom::tidy(summary(lm2)) %>%
mutate(low = estimate - std.error,
high = estimate + std.error)
d
```
```{r}
ggplot(d, aes(estimate, term, xmin = low, xmax = high, heght = 0)) +
geom_point() + geom_vline(xintercept = 0) + geom_errorbarh()
```
```{r}
names(lm1)
```
```{r}
lm1$coefficients
```
```{r}
head(lm1$residuals)
```
```{r}
head(lm1$fitted.values)
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```