My data consists of 3 variables, one is a numerical variable of the number of flower visits that I have counted on certain locations and on certain shrub species. My other 2 variables are categorical variables: Category ID (location), which can be either "RA", "RN" or "UN" and Species, which can be either "Common hawthorn", "Blackberry" or "Rose". See below for the data and ggplot of the data:
> visits_df
# A tibble: 74 × 3
Category_ID Species Total_visits
<fct> <fct> <dbl>
1 UN Common hawthorn 22
2 UN Common hawthorn 42
3 UN Common hawthorn 3
4 UN Common hawthorn 13
5 UN Common hawthorn 76
6 UN Common hawthorn 95
7 UN Common hawthorn 53
8 RN Common hawthorn 50
9 RN Common hawthorn 18
10 UN Common hawthorn 6
11 UN Common hawthorn 16
12 RA Common hawthorn 48
13 RA Common hawthorn 63
14 RA Common hawthorn 35
15 RA Common hawthorn 40
16 RN Common hawthorn 49
17 RA Common hawthorn 25
18 RA Common hawthorn 73
19 RN Common hawthorn 107
20 UN Common hawthorn 62
21 UN Common hawthorn 60
22 RN Common hawthorn 66
23 RN Common hawthorn 29
24 RN Common hawthorn 33
25 RN Common hawthorn 79
26 UN Common hawthorn 19
27 UN Common hawthorn 16
28 UN Common hawthorn 35
29 UN Common hawthorn 43
30 RN Common hawthorn 30
31 RN Common hawthorn 27
32 UN Common hawthorn 94
33 UN Common hawthorn 54
34 RN Blackberry 126
35 RN Blackberry 145
36 RN Blackberry 145
37 UN Blackberry 93
38 UN Blackberry 173
39 RA Rose 17
40 RA Rose 26
41 RA Rose 44
42 RA Rose 9
43 RA Rose 18
44 UN Blackberry 144
45 RN Blackberry 129
46 RN Blackberry 168
47 RN Blackberry 334
48 RN Blackberry 342
49 RN Blackberry 306
50 RN Blackberry 283
51 UN Blackberry 308
52 RN Blackberry 266
53 RN Blackberry 244
54 RA Rose 44
55 RA Rose 36
56 RA Rose 62
57 RA Rose 85
58 UN Blackberry 106
59 RN Blackberry 123
60 RN Blackberry 153
61 RN Blackberry 198
62 UN Blackberry 181
63 RA Rose 58
64 UN Blackberry 64
65 RN Blackberry 150
66 RN Blackberry 85
67 RN Blackberry 114
68 RN Blackberry 137
69 UN Blackberry 84
70 RN Blackberry 121
71 RN Blackberry 148
72 RN Blackberry 104
73 RN Blackberry 117
74 UN Blackberry 93
I tested if my data to see if its fits a Poisson distribution, as it is count data, using the following code (I found this code online):
obs_freq <- table(visits_df$Total_visits)
lambda <- mean(visits_df$Total_visits)
exp_freq <- dpois(as.numeric(names(obs_freq)), lambda) * length(visits_df$Total_visits)
chisq.test(obs_freq, p = exp_freq, rescale.p = TRUE)
# not a poission distribution: p-value = 2.2e-16
Does anybody know how to proceed? As I would like to test if there are differences between the boxplots. Can I still use a Poisson regression even though my data does not seem to follow a Poisson distribution?
Comparing the mean and variance of the number of flower visits gave me these results:
> mean_data <- mean(visits_df$Total_visits)
> var_data <- var(visits_df$Total_visits)
> cat("Mean:", mean_data, "\nVariance:", var_data)
Mean: 95.45946
Variance: 6703.128