-
Notifications
You must be signed in to change notification settings - Fork 1
/
poisson_model_code.Rmd
115 lines (62 loc) · 1.33 KB
/
poisson_model_code.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
---
title: "Poisson Regression Code"
output: html_document
---
# Load and Format data
Here, we read and format data.
```{r}
library("pscl")
bioChemists$kid5 <- factor(bioChemists$kid5)
```
# Summary of Data
```{r}
# print head of dataset
```
```{r}
# print summary of dataset
```
# Poisson Regression in R
## Constant Term
We will now build a logistic model with a constant term and a TotalVolume term.
```{r}
# model with constant term, poisson(link = log))
```
### Model Summary
```{r}
# print model summary
```
You can also get the coefficents of the model.
```{r}
# print model coefs
```
## Model with Constant + Gender Term
We will now build a Poisson model with a constant term and sex.
```{r}
# poisson glm with fem and constant, family = poisson(link = log)) as model_sex
```
### Model Summary
```{r}
# print model summary
```
## Model Comparison
We can compare models using the anova function.
```{r}
# compare model_constant vs. model_sex
```
## Model with fem and ment
### Create Model
```{r}
# poisson glm with fem, constant, ment family = poisson(link = log)) as model_sex_ment
```
### Model Summary
```{r}
# print model summary
```
### Anova with null model
```{r}
# compare model_constant and model_sex_ment
```
### Anova with model with only sex
```{r}
# compare model_sex and model_sex_ment
```