forked from bquast/Regression-Models
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuiz4.R
More file actions
40 lines (33 loc) · 741 Bytes
/
Quiz4.R
File metadata and controls
40 lines (33 loc) · 741 Bytes
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
# Regression Models
# Coursera
# Quiz 4
# Bastiaan Quast
# Question 1
library(MASS)
?shuttle
data(shuttle)
str(shuttle)
names(shuttle)
?glm
fit <- glm(use ~ wind, family='binomial', shuttle)
exp(fit$coeff)
# Question 2
fit <- glm(use ~ wind + as.factor(magn), family='binomial', shuttle)
exp(fit$coeff)
# Question 3
# Question 4
data(InsectSprays)
outp <- exp(coef(glm(count ~ as.factor(spray) - 1, family="poisson", InsectSprays)))
outp
outp[1]/outp[2]
# Question 5
?offset
log(10)
# Question 6
x <- -5:5
y <- c(5.12, 3.93, 2.67, 1.87, 0.52, 0.08, 0.93, 2.05, 2.54, 3.87, 4.97)
plot(y ~ x)
d1 <- c(0, 0 ,0, 0, 0, 0, 1 , 1, 1 , 1 , 1)
d2 <- c(1, 1 ,1, 1, 1, 1, 0 , 0, 0, 0 , 0)
# y = c + d1 * x + d2 * x
summary(lm(y ~ d1*x))