H0: People in colder regions and warmer regions have same resilience to flu
H1: People in colder regions are more resilient to flu then people in warmer regions
For this test, will be looking at data from 2023 to 2024, for months Oct, Nov, and Dec High ILI Activity means that large proportion of patient visits are due to influenza like symptoms
In data, when assigning states, 1 = warmer region and 2 = colder region
# Declaring Means and Standard Deviations of samples
# mean and standard deviation will not be negative here as avg number of flu cases present should be positive, 0 at least in a wildly healthy world
mean1 = 30
stdev1 = 4
# Creating random normal samples based on means and standard deviations
flu_cases <- rnorm(100,
mean = mean1,
sd = stdev1)
flu_cases
## [1] 25.94500 30.40664 32.49277 31.01753 32.81981 31.70585 31.09240 33.03993
## [9] 28.13398 33.29875 29.43570 28.16660 31.42153 34.55571 25.88180 28.17306
## [17] 32.15281 25.44768 30.47358 26.22657 35.14487 18.55346 25.43509 28.25721
## [25] 24.88967 28.49357 32.85098 36.95344 29.92623 28.66589 27.46890 30.33376
## [33] 25.43656 30.17890 32.70856 29.94120 38.08401 28.45616 23.17688 25.74489
## [41] 19.79848 33.32161 31.63387 28.38589 33.95855 31.22632 27.93053 32.15667
## [49] 33.05223 28.55207 24.06948 29.71777 31.09682 30.84369 23.44091 31.90450
## [57] 30.96885 29.83035 36.58094 29.14035 29.89447 29.81223 27.41862 29.00572
## [65] 36.70069 28.12139 29.81103 24.73169 34.60883 29.51554 28.53941 28.09345
## [73] 30.93841 28.20003 31.32182 37.15756 29.12520 29.90087 32.22040 18.92187
## [81] 33.75095 33.11342 32.74765 30.51781 33.66921 27.42130 19.66014 24.54070
## [89] 25.21656 26.43560 26.44318 33.42566 32.18265 34.45485 33.65021 43.06998
## [97] 29.75254 29.72114 27.46170 28.78214
# Creating data set with descriptive columns based on generated samples
flu_data <- data.frame(flu_cases)
# Randomly assign categorical
flu_data$states <- sample(c(1,2))
flu_data
## flu_cases states
## 1 25.94500 1
## 2 30.40664 2
## 3 32.49277 1
## 4 31.01753 2
## 5 32.81981 1
## 6 31.70585 2
## 7 31.09240 1
## 8 33.03993 2
## 9 28.13398 1
## 10 33.29875 2
## 11 29.43570 1
## 12 28.16660 2
## 13 31.42153 1
## 14 34.55571 2
## 15 25.88180 1
## 16 28.17306 2
## 17 32.15281 1
## 18 25.44768 2
## 19 30.47358 1
## 20 26.22657 2
## 21 35.14487 1
## 22 18.55346 2
## 23 25.43509 1
## 24 28.25721 2
## 25 24.88967 1
## 26 28.49357 2
## 27 32.85098 1
## 28 36.95344 2
## 29 29.92623 1
## 30 28.66589 2
## 31 27.46890 1
## 32 30.33376 2
## 33 25.43656 1
## 34 30.17890 2
## 35 32.70856 1
## 36 29.94120 2
## 37 38.08401 1
## 38 28.45616 2
## 39 23.17688 1
## 40 25.74489 2
## 41 19.79848 1
## 42 33.32161 2
## 43 31.63387 1
## 44 28.38589 2
## 45 33.95855 1
## 46 31.22632 2
## 47 27.93053 1
## 48 32.15667 2
## 49 33.05223 1
## 50 28.55207 2
## 51 24.06948 1
## 52 29.71777 2
## 53 31.09682 1
## 54 30.84369 2
## 55 23.44091 1
## 56 31.90450 2
## 57 30.96885 1
## 58 29.83035 2
## 59 36.58094 1
## 60 29.14035 2
## 61 29.89447 1
## 62 29.81223 2
## 63 27.41862 1
## 64 29.00572 2
## 65 36.70069 1
## 66 28.12139 2
## 67 29.81103 1
## 68 24.73169 2
## 69 34.60883 1
## 70 29.51554 2
## 71 28.53941 1
## 72 28.09345 2
## 73 30.93841 1
## 74 28.20003 2
## 75 31.32182 1
## 76 37.15756 2
## 77 29.12520 1
## 78 29.90087 2
## 79 32.22040 1
## 80 18.92187 2
## 81 33.75095 1
## 82 33.11342 2
## 83 32.74765 1
## 84 30.51781 2
## 85 33.66921 1
## 86 27.42130 2
## 87 19.66014 1
## 88 24.54070 2
## 89 25.21656 1
## 90 26.43560 2
## 91 26.44318 1
## 92 33.42566 2
## 93 32.18265 1
## 94 34.45485 2
## 95 33.65021 1
## 96 43.06998 2
## 97 29.75254 1
## 98 29.72114 2
## 99 27.46170 1
## 100 28.78214 2
# Creating Var of data and adding that to data <- double check, unsure if he wants us to provide a var or find it
flu_data$variance <- var(flu_cases)
flu_data
## flu_cases states variance
## 1 25.94500 1 16.42369
## 2 30.40664 2 16.42369
## 3 32.49277 1 16.42369
## 4 31.01753 2 16.42369
## 5 32.81981 1 16.42369
## 6 31.70585 2 16.42369
## 7 31.09240 1 16.42369
## 8 33.03993 2 16.42369
## 9 28.13398 1 16.42369
## 10 33.29875 2 16.42369
## 11 29.43570 1 16.42369
## 12 28.16660 2 16.42369
## 13 31.42153 1 16.42369
## 14 34.55571 2 16.42369
## 15 25.88180 1 16.42369
## 16 28.17306 2 16.42369
## 17 32.15281 1 16.42369
## 18 25.44768 2 16.42369
## 19 30.47358 1 16.42369
## 20 26.22657 2 16.42369
## 21 35.14487 1 16.42369
## 22 18.55346 2 16.42369
## 23 25.43509 1 16.42369
## 24 28.25721 2 16.42369
## 25 24.88967 1 16.42369
## 26 28.49357 2 16.42369
## 27 32.85098 1 16.42369
## 28 36.95344 2 16.42369
## 29 29.92623 1 16.42369
## 30 28.66589 2 16.42369
## 31 27.46890 1 16.42369
## 32 30.33376 2 16.42369
## 33 25.43656 1 16.42369
## 34 30.17890 2 16.42369
## 35 32.70856 1 16.42369
## 36 29.94120 2 16.42369
## 37 38.08401 1 16.42369
## 38 28.45616 2 16.42369
## 39 23.17688 1 16.42369
## 40 25.74489 2 16.42369
## 41 19.79848 1 16.42369
## 42 33.32161 2 16.42369
## 43 31.63387 1 16.42369
## 44 28.38589 2 16.42369
## 45 33.95855 1 16.42369
## 46 31.22632 2 16.42369
## 47 27.93053 1 16.42369
## 48 32.15667 2 16.42369
## 49 33.05223 1 16.42369
## 50 28.55207 2 16.42369
## 51 24.06948 1 16.42369
## 52 29.71777 2 16.42369
## 53 31.09682 1 16.42369
## 54 30.84369 2 16.42369
## 55 23.44091 1 16.42369
## 56 31.90450 2 16.42369
## 57 30.96885 1 16.42369
## 58 29.83035 2 16.42369
## 59 36.58094 1 16.42369
## 60 29.14035 2 16.42369
## 61 29.89447 1 16.42369
## 62 29.81223 2 16.42369
## 63 27.41862 1 16.42369
## 64 29.00572 2 16.42369
## 65 36.70069 1 16.42369
## 66 28.12139 2 16.42369
## 67 29.81103 1 16.42369
## 68 24.73169 2 16.42369
## 69 34.60883 1 16.42369
## 70 29.51554 2 16.42369
## 71 28.53941 1 16.42369
## 72 28.09345 2 16.42369
## 73 30.93841 1 16.42369
## 74 28.20003 2 16.42369
## 75 31.32182 1 16.42369
## 76 37.15756 2 16.42369
## 77 29.12520 1 16.42369
## 78 29.90087 2 16.42369
## 79 32.22040 1 16.42369
## 80 18.92187 2 16.42369
## 81 33.75095 1 16.42369
## 82 33.11342 2 16.42369
## 83 32.74765 1 16.42369
## 84 30.51781 2 16.42369
## 85 33.66921 1 16.42369
## 86 27.42130 2 16.42369
## 87 19.66014 1 16.42369
## 88 24.54070 2 16.42369
## 89 25.21656 1 16.42369
## 90 26.43560 2 16.42369
## 91 26.44318 1 16.42369
## 92 33.42566 2 16.42369
## 93 32.18265 1 16.42369
## 94 34.45485 2 16.42369
## 95 33.65021 1 16.42369
## 96 43.06998 2 16.42369
## 97 29.75254 1 16.42369
## 98 29.72114 2 16.42369
## 99 27.46170 1 16.42369
## 100 28.78214 2 16.42369
Here we will test our fake data using ANOVA
## Df Sum Sq Mean Sq F value Pr(>F)
## states 1 0.2 0.248 0.015 0.903
## Residuals 98 1625.7 16.589
Here we are going to set up for loops to iterate through other parameters with the data, seeing how much we need to achieve a p-value < 0.05
n = 1000
count = 0
smallest_sample_size = 0
seq_5 <- seq(1, n, by = 5)
seq_10 <- seq(1, n, by = 10)
for (i in 1:length(seq_5)) {
flu_cases <- (rnorm(seq_5[i],
mean = mean1,
sd = stdev1))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
cat("\n","The sample size is ->", seq_5[i], "\n")
cat("The p-value is ->", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
if (i > 1 & count == 0) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
smallest_sample_size = seq_5[i]
}
}
if (i > 1) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
count = count + 1
cat("There is a signifact difference between colder and warmer region flu cases at a sample size of ", seq_5[i], "with a p-value of ", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
}
}
cat("Total signifcant flu cases ", count, "out of ", i, "trials", "\n")
cat("Smallest sample size for significant difference", smallest_sample_size, "\n")
}
##
## The sample size is -> 1
## The p-value is ->
## Total signifcant flu cases 0 out of 1 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 6
## The p-value is -> 0.5106948
## Total signifcant flu cases 0 out of 2 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 11
## The p-value is -> 0.9678323
## Total signifcant flu cases 0 out of 3 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 16
## The p-value is -> 0.4085059
## Total signifcant flu cases 0 out of 4 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 21
## The p-value is -> 0.6011326
## Total signifcant flu cases 0 out of 5 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 26
## The p-value is -> 0.8387038
## Total signifcant flu cases 0 out of 6 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 31
## The p-value is -> 0.3984864
## Total signifcant flu cases 0 out of 7 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 36
## The p-value is -> 0.7886645
## Total signifcant flu cases 0 out of 8 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 41
## The p-value is -> 0.3835959
## Total signifcant flu cases 0 out of 9 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 46
## The p-value is -> 0.5754333
## Total signifcant flu cases 0 out of 10 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 51
## The p-value is -> 0.2152835
## Total signifcant flu cases 0 out of 11 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 56
## The p-value is -> 0.06795712
## Total signifcant flu cases 0 out of 12 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 61
## The p-value is -> 0.07332116
## Total signifcant flu cases 0 out of 13 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 66
## The p-value is -> 0.497023
## Total signifcant flu cases 0 out of 14 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 71
## The p-value is -> 0.656706
## Total signifcant flu cases 0 out of 15 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 76
## The p-value is -> 0.5254369
## Total signifcant flu cases 0 out of 16 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 81
## The p-value is -> 0.4775288
## Total signifcant flu cases 0 out of 17 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 86
## The p-value is -> 0.5302023
## Total signifcant flu cases 0 out of 18 trials
## Smallest sample size for significant difference 0
##
## The sample size is -> 91
## The p-value is -> 0.02503792
## There is a signifact difference between colder and warmer region flu cases at a sample size of 91 with a p-value of 0.02503792
## Total signifcant flu cases 1 out of 19 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 96
## The p-value is -> 0.1147285
## Total signifcant flu cases 1 out of 20 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 101
## The p-value is -> 0.8144053
## Total signifcant flu cases 1 out of 21 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 106
## The p-value is -> 0.7527999
## Total signifcant flu cases 1 out of 22 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 111
## The p-value is -> 0.6467541
## Total signifcant flu cases 1 out of 23 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 116
## The p-value is -> 0.3062134
## Total signifcant flu cases 1 out of 24 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 121
## The p-value is -> 0.03487085
## There is a signifact difference between colder and warmer region flu cases at a sample size of 121 with a p-value of 0.03487085
## Total signifcant flu cases 2 out of 25 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 126
## The p-value is -> 0.4207727
## Total signifcant flu cases 2 out of 26 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 131
## The p-value is -> 0.5678886
## Total signifcant flu cases 2 out of 27 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 136
## The p-value is -> 0.2333495
## Total signifcant flu cases 2 out of 28 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 141
## The p-value is -> 0.8881648
## Total signifcant flu cases 2 out of 29 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 146
## The p-value is -> 0.9281794
## Total signifcant flu cases 2 out of 30 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 151
## The p-value is -> 0.8021779
## Total signifcant flu cases 2 out of 31 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 156
## The p-value is -> 0.4187272
## Total signifcant flu cases 2 out of 32 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 161
## The p-value is -> 0.5453381
## Total signifcant flu cases 2 out of 33 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 166
## The p-value is -> 0.4850372
## Total signifcant flu cases 2 out of 34 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 171
## The p-value is -> 0.4392078
## Total signifcant flu cases 2 out of 35 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 176
## The p-value is -> 0.06564739
## Total signifcant flu cases 2 out of 36 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 181
## The p-value is -> 0.3906675
## Total signifcant flu cases 2 out of 37 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 186
## The p-value is -> 0.01931325
## There is a signifact difference between colder and warmer region flu cases at a sample size of 186 with a p-value of 0.01931325
## Total signifcant flu cases 3 out of 38 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 191
## The p-value is -> 0.9979525
## Total signifcant flu cases 3 out of 39 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 196
## The p-value is -> 0.7716177
## Total signifcant flu cases 3 out of 40 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 201
## The p-value is -> 0.3254518
## Total signifcant flu cases 3 out of 41 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 206
## The p-value is -> 0.8850736
## Total signifcant flu cases 3 out of 42 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 211
## The p-value is -> 0.7853006
## Total signifcant flu cases 3 out of 43 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 216
## The p-value is -> 0.947301
## Total signifcant flu cases 3 out of 44 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 221
## The p-value is -> 0.04966684
## There is a signifact difference between colder and warmer region flu cases at a sample size of 221 with a p-value of 0.04966684
## Total signifcant flu cases 4 out of 45 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 226
## The p-value is -> 0.5299987
## Total signifcant flu cases 4 out of 46 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 231
## The p-value is -> 0.1256983
## Total signifcant flu cases 4 out of 47 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 236
## The p-value is -> 0.2881545
## Total signifcant flu cases 4 out of 48 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 241
## The p-value is -> 0.7436217
## Total signifcant flu cases 4 out of 49 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 246
## The p-value is -> 0.7762627
## Total signifcant flu cases 4 out of 50 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 251
## The p-value is -> 0.9562854
## Total signifcant flu cases 4 out of 51 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 256
## The p-value is -> 0.09890616
## Total signifcant flu cases 4 out of 52 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 261
## The p-value is -> 0.05326824
## Total signifcant flu cases 4 out of 53 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 266
## The p-value is -> 0.2542177
## Total signifcant flu cases 4 out of 54 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 271
## The p-value is -> 0.6137268
## Total signifcant flu cases 4 out of 55 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 276
## The p-value is -> 0.1253095
## Total signifcant flu cases 4 out of 56 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 281
## The p-value is -> 0.2816848
## Total signifcant flu cases 4 out of 57 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 286
## The p-value is -> 0.4686325
## Total signifcant flu cases 4 out of 58 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 291
## The p-value is -> 0.6513576
## Total signifcant flu cases 4 out of 59 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 296
## The p-value is -> 0.9860414
## Total signifcant flu cases 4 out of 60 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 301
## The p-value is -> 0.8053977
## Total signifcant flu cases 4 out of 61 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 306
## The p-value is -> 0.9316048
## Total signifcant flu cases 4 out of 62 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 311
## The p-value is -> 0.6178824
## Total signifcant flu cases 4 out of 63 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 316
## The p-value is -> 0.1002274
## Total signifcant flu cases 4 out of 64 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 321
## The p-value is -> 0.3103327
## Total signifcant flu cases 4 out of 65 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 326
## The p-value is -> 0.8201394
## Total signifcant flu cases 4 out of 66 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 331
## The p-value is -> 0.05230837
## Total signifcant flu cases 4 out of 67 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 336
## The p-value is -> 0.7237357
## Total signifcant flu cases 4 out of 68 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 341
## The p-value is -> 0.5079496
## Total signifcant flu cases 4 out of 69 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 346
## The p-value is -> 0.3235191
## Total signifcant flu cases 4 out of 70 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 351
## The p-value is -> 0.8067621
## Total signifcant flu cases 4 out of 71 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 356
## The p-value is -> 0.9560404
## Total signifcant flu cases 4 out of 72 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 361
## The p-value is -> 0.6781044
## Total signifcant flu cases 4 out of 73 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 366
## The p-value is -> 0.6962999
## Total signifcant flu cases 4 out of 74 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 371
## The p-value is -> 0.5918531
## Total signifcant flu cases 4 out of 75 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 376
## The p-value is -> 0.6987713
## Total signifcant flu cases 4 out of 76 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 381
## The p-value is -> 0.8988323
## Total signifcant flu cases 4 out of 77 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 386
## The p-value is -> 0.170895
## Total signifcant flu cases 4 out of 78 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 391
## The p-value is -> 0.2059382
## Total signifcant flu cases 4 out of 79 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 396
## The p-value is -> 0.07495393
## Total signifcant flu cases 4 out of 80 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 401
## The p-value is -> 0.5731249
## Total signifcant flu cases 4 out of 81 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 406
## The p-value is -> 0.3076082
## Total signifcant flu cases 4 out of 82 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 411
## The p-value is -> 0.6697683
## Total signifcant flu cases 4 out of 83 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 416
## The p-value is -> 0.2395966
## Total signifcant flu cases 4 out of 84 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 421
## The p-value is -> 0.5367502
## Total signifcant flu cases 4 out of 85 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 426
## The p-value is -> 0.7436752
## Total signifcant flu cases 4 out of 86 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 431
## The p-value is -> 0.6260414
## Total signifcant flu cases 4 out of 87 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 436
## The p-value is -> 0.4421753
## Total signifcant flu cases 4 out of 88 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 441
## The p-value is -> 0.6397151
## Total signifcant flu cases 4 out of 89 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 446
## The p-value is -> 0.5089551
## Total signifcant flu cases 4 out of 90 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 451
## The p-value is -> 0.1804405
## Total signifcant flu cases 4 out of 91 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 456
## The p-value is -> 0.3994684
## Total signifcant flu cases 4 out of 92 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 461
## The p-value is -> 0.1418152
## Total signifcant flu cases 4 out of 93 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 466
## The p-value is -> 0.8411136
## Total signifcant flu cases 4 out of 94 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 471
## The p-value is -> 0.615057
## Total signifcant flu cases 4 out of 95 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 476
## The p-value is -> 0.2028054
## Total signifcant flu cases 4 out of 96 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 481
## The p-value is -> 0.3557648
## Total signifcant flu cases 4 out of 97 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 486
## The p-value is -> 0.5357313
## Total signifcant flu cases 4 out of 98 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 491
## The p-value is -> 0.968479
## Total signifcant flu cases 4 out of 99 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 496
## The p-value is -> 0.2696359
## Total signifcant flu cases 4 out of 100 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 501
## The p-value is -> 0.5111133
## Total signifcant flu cases 4 out of 101 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 506
## The p-value is -> 0.8573264
## Total signifcant flu cases 4 out of 102 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 511
## The p-value is -> 0.6092084
## Total signifcant flu cases 4 out of 103 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 516
## The p-value is -> 0.05865493
## Total signifcant flu cases 4 out of 104 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 521
## The p-value is -> 0.9520109
## Total signifcant flu cases 4 out of 105 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 526
## The p-value is -> 0.9692814
## Total signifcant flu cases 4 out of 106 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 531
## The p-value is -> 0.0904244
## Total signifcant flu cases 4 out of 107 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 536
## The p-value is -> 0.7356918
## Total signifcant flu cases 4 out of 108 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 541
## The p-value is -> 0.152701
## Total signifcant flu cases 4 out of 109 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 546
## The p-value is -> 0.359567
## Total signifcant flu cases 4 out of 110 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 551
## The p-value is -> 0.7347299
## Total signifcant flu cases 4 out of 111 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 556
## The p-value is -> 0.8502083
## Total signifcant flu cases 4 out of 112 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 561
## The p-value is -> 0.2670028
## Total signifcant flu cases 4 out of 113 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 566
## The p-value is -> 0.5207071
## Total signifcant flu cases 4 out of 114 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 571
## The p-value is -> 0.492641
## Total signifcant flu cases 4 out of 115 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 576
## The p-value is -> 0.2737672
## Total signifcant flu cases 4 out of 116 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 581
## The p-value is -> 0.8036041
## Total signifcant flu cases 4 out of 117 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 586
## The p-value is -> 0.2992094
## Total signifcant flu cases 4 out of 118 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 591
## The p-value is -> 0.06305557
## Total signifcant flu cases 4 out of 119 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 596
## The p-value is -> 0.1317571
## Total signifcant flu cases 4 out of 120 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 601
## The p-value is -> 0.2178749
## Total signifcant flu cases 4 out of 121 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 606
## The p-value is -> 0.5253752
## Total signifcant flu cases 4 out of 122 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 611
## The p-value is -> 0.4444112
## Total signifcant flu cases 4 out of 123 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 616
## The p-value is -> 0.6069858
## Total signifcant flu cases 4 out of 124 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 621
## The p-value is -> 0.7182592
## Total signifcant flu cases 4 out of 125 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 626
## The p-value is -> 0.05616974
## Total signifcant flu cases 4 out of 126 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 631
## The p-value is -> 0.8378986
## Total signifcant flu cases 4 out of 127 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 636
## The p-value is -> 0.2934759
## Total signifcant flu cases 4 out of 128 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 641
## The p-value is -> 0.2596641
## Total signifcant flu cases 4 out of 129 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 646
## The p-value is -> 0.3658938
## Total signifcant flu cases 4 out of 130 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 651
## The p-value is -> 0.3145522
## Total signifcant flu cases 4 out of 131 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 656
## The p-value is -> 0.1580886
## Total signifcant flu cases 4 out of 132 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 661
## The p-value is -> 0.02040959
## There is a signifact difference between colder and warmer region flu cases at a sample size of 661 with a p-value of 0.02040959
## Total signifcant flu cases 5 out of 133 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 666
## The p-value is -> 0.2290797
## Total signifcant flu cases 5 out of 134 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 671
## The p-value is -> 0.1581163
## Total signifcant flu cases 5 out of 135 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 676
## The p-value is -> 0.8454443
## Total signifcant flu cases 5 out of 136 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 681
## The p-value is -> 0.3086262
## Total signifcant flu cases 5 out of 137 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 686
## The p-value is -> 0.2948475
## Total signifcant flu cases 5 out of 138 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 691
## The p-value is -> 0.5687653
## Total signifcant flu cases 5 out of 139 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 696
## The p-value is -> 0.5050774
## Total signifcant flu cases 5 out of 140 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 701
## The p-value is -> 0.5192124
## Total signifcant flu cases 5 out of 141 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 706
## The p-value is -> 0.3570631
## Total signifcant flu cases 5 out of 142 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 711
## The p-value is -> 0.6664561
## Total signifcant flu cases 5 out of 143 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 716
## The p-value is -> 0.1091425
## Total signifcant flu cases 5 out of 144 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 721
## The p-value is -> 0.1816518
## Total signifcant flu cases 5 out of 145 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 726
## The p-value is -> 0.1319489
## Total signifcant flu cases 5 out of 146 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 731
## The p-value is -> 0.7546288
## Total signifcant flu cases 5 out of 147 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 736
## The p-value is -> 0.6145865
## Total signifcant flu cases 5 out of 148 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 741
## The p-value is -> 0.7634528
## Total signifcant flu cases 5 out of 149 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 746
## The p-value is -> 0.2510106
## Total signifcant flu cases 5 out of 150 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 751
## The p-value is -> 0.5418623
## Total signifcant flu cases 5 out of 151 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 756
## The p-value is -> 0.07847847
## Total signifcant flu cases 5 out of 152 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 761
## The p-value is -> 0.6245795
## Total signifcant flu cases 5 out of 153 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 766
## The p-value is -> 0.01887014
## There is a signifact difference between colder and warmer region flu cases at a sample size of 766 with a p-value of 0.01887014
## Total signifcant flu cases 6 out of 154 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 771
## The p-value is -> 0.6545496
## Total signifcant flu cases 6 out of 155 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 776
## The p-value is -> 0.1010776
## Total signifcant flu cases 6 out of 156 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 781
## The p-value is -> 0.6185636
## Total signifcant flu cases 6 out of 157 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 786
## The p-value is -> 0.5080109
## Total signifcant flu cases 6 out of 158 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 791
## The p-value is -> 0.2840964
## Total signifcant flu cases 6 out of 159 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 796
## The p-value is -> 0.4109504
## Total signifcant flu cases 6 out of 160 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 801
## The p-value is -> 0.7990803
## Total signifcant flu cases 6 out of 161 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 806
## The p-value is -> 0.4422727
## Total signifcant flu cases 6 out of 162 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 811
## The p-value is -> 0.6440968
## Total signifcant flu cases 6 out of 163 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 816
## The p-value is -> 0.1358615
## Total signifcant flu cases 6 out of 164 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 821
## The p-value is -> 0.7975637
## Total signifcant flu cases 6 out of 165 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 826
## The p-value is -> 0.3256264
## Total signifcant flu cases 6 out of 166 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 831
## The p-value is -> 0.1920249
## Total signifcant flu cases 6 out of 167 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 836
## The p-value is -> 0.3861772
## Total signifcant flu cases 6 out of 168 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 841
## The p-value is -> 0.08849789
## Total signifcant flu cases 6 out of 169 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 846
## The p-value is -> 0.4551328
## Total signifcant flu cases 6 out of 170 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 851
## The p-value is -> 0.8441035
## Total signifcant flu cases 6 out of 171 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 856
## The p-value is -> 0.9195265
## Total signifcant flu cases 6 out of 172 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 861
## The p-value is -> 0.3389194
## Total signifcant flu cases 6 out of 173 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 866
## The p-value is -> 0.4966679
## Total signifcant flu cases 6 out of 174 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 871
## The p-value is -> 0.5930632
## Total signifcant flu cases 6 out of 175 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 876
## The p-value is -> 0.4325368
## Total signifcant flu cases 6 out of 176 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 881
## The p-value is -> 0.2617479
## Total signifcant flu cases 6 out of 177 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 886
## The p-value is -> 0.2590661
## Total signifcant flu cases 6 out of 178 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 891
## The p-value is -> 0.9018074
## Total signifcant flu cases 6 out of 179 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 896
## The p-value is -> 0.6781099
## Total signifcant flu cases 6 out of 180 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 901
## The p-value is -> 0.9542938
## Total signifcant flu cases 6 out of 181 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 906
## The p-value is -> 0.7687492
## Total signifcant flu cases 6 out of 182 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 911
## The p-value is -> 0.2554554
## Total signifcant flu cases 6 out of 183 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 916
## The p-value is -> 0.9820056
## Total signifcant flu cases 6 out of 184 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 921
## The p-value is -> 0.2589867
## Total signifcant flu cases 6 out of 185 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 926
## The p-value is -> 0.6439669
## Total signifcant flu cases 6 out of 186 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 931
## The p-value is -> 0.03162947
## There is a signifact difference between colder and warmer region flu cases at a sample size of 931 with a p-value of 0.03162947
## Total signifcant flu cases 7 out of 187 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 936
## The p-value is -> 0.1192682
## Total signifcant flu cases 7 out of 188 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 941
## The p-value is -> 0.5163906
## Total signifcant flu cases 7 out of 189 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 946
## The p-value is -> 0.7169867
## Total signifcant flu cases 7 out of 190 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 951
## The p-value is -> 0.5103322
## Total signifcant flu cases 7 out of 191 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 956
## The p-value is -> 0.3155888
## Total signifcant flu cases 7 out of 192 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 961
## The p-value is -> 0.5523944
## Total signifcant flu cases 7 out of 193 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 966
## The p-value is -> 0.8261954
## Total signifcant flu cases 7 out of 194 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 971
## The p-value is -> 0.7564485
## Total signifcant flu cases 7 out of 195 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 976
## The p-value is -> 0.4764971
## Total signifcant flu cases 7 out of 196 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 981
## The p-value is -> 0.5823174
## Total signifcant flu cases 7 out of 197 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 986
## The p-value is -> 0.5928227
## Total signifcant flu cases 7 out of 198 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 991
## The p-value is -> 0.9404265
## Total signifcant flu cases 7 out of 199 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 996
## The p-value is -> 0.4279822
## Total signifcant flu cases 7 out of 200 trials
## Smallest sample size for significant difference 91
# Need to reset counter for each loop
count = 0
for (i in 1:length(seq_10)) {
flu_cases <- (rnorm(seq_10[i],
mean = mean1,
sd = stdev1))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
cat("\n","The sample size is ->", seq_10[i], "\n")
cat("The p-value is ->", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
if (i > 1 & count == 0) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
smallest_sample_size = seq_10[i]
}
}
if (i > 1) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
count = count + 1
cat("There is a signifact difference between colder and warmer region flu cases at a sample size of ", seq_10[i], "with a p-value of ", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
}
}
cat("Total signifcant flu cases ", count, "out of ", i, "trials", "\n")
cat("Smallest sample size for significant difference", smallest_sample_size, "\n")
}
##
## The sample size is -> 1
## The p-value is ->
## Total signifcant flu cases 0 out of 1 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 11
## The p-value is -> 0.6000062
## Total signifcant flu cases 0 out of 2 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 21
## The p-value is -> 0.7787037
## Total signifcant flu cases 0 out of 3 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 31
## The p-value is -> 0.2524321
## Total signifcant flu cases 0 out of 4 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 41
## The p-value is -> 0.7109421
## Total signifcant flu cases 0 out of 5 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 51
## The p-value is -> 0.7003825
## Total signifcant flu cases 0 out of 6 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 61
## The p-value is -> 0.3687309
## Total signifcant flu cases 0 out of 7 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 71
## The p-value is -> 0.4981922
## Total signifcant flu cases 0 out of 8 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 81
## The p-value is -> 0.6088305
## Total signifcant flu cases 0 out of 9 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 91
## The p-value is -> 0.6465656
## Total signifcant flu cases 0 out of 10 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 101
## The p-value is -> 0.4621256
## Total signifcant flu cases 0 out of 11 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 111
## The p-value is -> 0.9946152
## Total signifcant flu cases 0 out of 12 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 121
## The p-value is -> 0.616271
## Total signifcant flu cases 0 out of 13 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 131
## The p-value is -> 0.728792
## Total signifcant flu cases 0 out of 14 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 141
## The p-value is -> 0.2373934
## Total signifcant flu cases 0 out of 15 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 151
## The p-value is -> 0.7902918
## Total signifcant flu cases 0 out of 16 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 161
## The p-value is -> 0.7641848
## Total signifcant flu cases 0 out of 17 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 171
## The p-value is -> 0.1685983
## Total signifcant flu cases 0 out of 18 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 181
## The p-value is -> 0.08508033
## Total signifcant flu cases 0 out of 19 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 191
## The p-value is -> 0.9709528
## Total signifcant flu cases 0 out of 20 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 201
## The p-value is -> 0.6213549
## Total signifcant flu cases 0 out of 21 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 211
## The p-value is -> 0.1817231
## Total signifcant flu cases 0 out of 22 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 221
## The p-value is -> 0.3652502
## Total signifcant flu cases 0 out of 23 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 231
## The p-value is -> 0.4354472
## Total signifcant flu cases 0 out of 24 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 241
## The p-value is -> 0.9010818
## Total signifcant flu cases 0 out of 25 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 251
## The p-value is -> 0.9220202
## Total signifcant flu cases 0 out of 26 trials
## Smallest sample size for significant difference 91
##
## The sample size is -> 261
## The p-value is -> 0.03622272
## There is a signifact difference between colder and warmer region flu cases at a sample size of 261 with a p-value of 0.03622272
## Total signifcant flu cases 1 out of 27 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 271
## The p-value is -> 0.9701471
## Total signifcant flu cases 1 out of 28 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 281
## The p-value is -> 0.4587492
## Total signifcant flu cases 1 out of 29 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 291
## The p-value is -> 0.6293383
## Total signifcant flu cases 1 out of 30 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 301
## The p-value is -> 0.7282301
## Total signifcant flu cases 1 out of 31 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 311
## The p-value is -> 0.02316597
## There is a signifact difference between colder and warmer region flu cases at a sample size of 311 with a p-value of 0.02316597
## Total signifcant flu cases 2 out of 32 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 321
## The p-value is -> 0.9758291
## Total signifcant flu cases 2 out of 33 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 331
## The p-value is -> 0.06369116
## Total signifcant flu cases 2 out of 34 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 341
## The p-value is -> 0.200242
## Total signifcant flu cases 2 out of 35 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 351
## The p-value is -> 0.597222
## Total signifcant flu cases 2 out of 36 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 361
## The p-value is -> 0.9420939
## Total signifcant flu cases 2 out of 37 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 371
## The p-value is -> 0.7685948
## Total signifcant flu cases 2 out of 38 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 381
## The p-value is -> 0.576229
## Total signifcant flu cases 2 out of 39 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 391
## The p-value is -> 0.8202309
## Total signifcant flu cases 2 out of 40 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 401
## The p-value is -> 0.5821382
## Total signifcant flu cases 2 out of 41 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 411
## The p-value is -> 0.1764276
## Total signifcant flu cases 2 out of 42 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 421
## The p-value is -> 0.2396096
## Total signifcant flu cases 2 out of 43 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 431
## The p-value is -> 0.6806384
## Total signifcant flu cases 2 out of 44 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 441
## The p-value is -> 0.7633106
## Total signifcant flu cases 2 out of 45 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 451
## The p-value is -> 0.6658355
## Total signifcant flu cases 2 out of 46 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 461
## The p-value is -> 0.888849
## Total signifcant flu cases 2 out of 47 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 471
## The p-value is -> 0.9457109
## Total signifcant flu cases 2 out of 48 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 481
## The p-value is -> 0.001490146
## There is a signifact difference between colder and warmer region flu cases at a sample size of 481 with a p-value of 0.001490146
## Total signifcant flu cases 3 out of 49 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 491
## The p-value is -> 0.1437149
## Total signifcant flu cases 3 out of 50 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 501
## The p-value is -> 0.1735532
## Total signifcant flu cases 3 out of 51 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 511
## The p-value is -> 0.2617107
## Total signifcant flu cases 3 out of 52 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 521
## The p-value is -> 0.5535551
## Total signifcant flu cases 3 out of 53 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 531
## The p-value is -> 0.1505312
## Total signifcant flu cases 3 out of 54 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 541
## The p-value is -> 0.5536441
## Total signifcant flu cases 3 out of 55 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 551
## The p-value is -> 0.2826596
## Total signifcant flu cases 3 out of 56 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 561
## The p-value is -> 0.1209141
## Total signifcant flu cases 3 out of 57 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 571
## The p-value is -> 0.2798639
## Total signifcant flu cases 3 out of 58 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 581
## The p-value is -> 0.6147583
## Total signifcant flu cases 3 out of 59 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 591
## The p-value is -> 0.04087035
## There is a signifact difference between colder and warmer region flu cases at a sample size of 591 with a p-value of 0.04087035
## Total signifcant flu cases 4 out of 60 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 601
## The p-value is -> 0.1607043
## Total signifcant flu cases 4 out of 61 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 611
## The p-value is -> 0.8797387
## Total signifcant flu cases 4 out of 62 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 621
## The p-value is -> 0.4454981
## Total signifcant flu cases 4 out of 63 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 631
## The p-value is -> 0.2620585
## Total signifcant flu cases 4 out of 64 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 641
## The p-value is -> 0.6169533
## Total signifcant flu cases 4 out of 65 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 651
## The p-value is -> 0.7777665
## Total signifcant flu cases 4 out of 66 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 661
## The p-value is -> 0.6387247
## Total signifcant flu cases 4 out of 67 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 671
## The p-value is -> 0.8508544
## Total signifcant flu cases 4 out of 68 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 681
## The p-value is -> 0.9271148
## Total signifcant flu cases 4 out of 69 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 691
## The p-value is -> 0.9143808
## Total signifcant flu cases 4 out of 70 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 701
## The p-value is -> 0.4637091
## Total signifcant flu cases 4 out of 71 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 711
## The p-value is -> 0.9104159
## Total signifcant flu cases 4 out of 72 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 721
## The p-value is -> 0.7023564
## Total signifcant flu cases 4 out of 73 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 731
## The p-value is -> 0.6963047
## Total signifcant flu cases 4 out of 74 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 741
## The p-value is -> 0.07948798
## Total signifcant flu cases 4 out of 75 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 751
## The p-value is -> 0.1467055
## Total signifcant flu cases 4 out of 76 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 761
## The p-value is -> 0.5406979
## Total signifcant flu cases 4 out of 77 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 771
## The p-value is -> 0.2542753
## Total signifcant flu cases 4 out of 78 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 781
## The p-value is -> 0.9738273
## Total signifcant flu cases 4 out of 79 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 791
## The p-value is -> 0.7329897
## Total signifcant flu cases 4 out of 80 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 801
## The p-value is -> 0.0989951
## Total signifcant flu cases 4 out of 81 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 811
## The p-value is -> 0.3528761
## Total signifcant flu cases 4 out of 82 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 821
## The p-value is -> 0.5697599
## Total signifcant flu cases 4 out of 83 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 831
## The p-value is -> 0.7985076
## Total signifcant flu cases 4 out of 84 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 841
## The p-value is -> 0.9462743
## Total signifcant flu cases 4 out of 85 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 851
## The p-value is -> 0.03658198
## There is a signifact difference between colder and warmer region flu cases at a sample size of 851 with a p-value of 0.03658198
## Total signifcant flu cases 5 out of 86 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 861
## The p-value is -> 0.4474592
## Total signifcant flu cases 5 out of 87 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 871
## The p-value is -> 0.1753096
## Total signifcant flu cases 5 out of 88 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 881
## The p-value is -> 0.2201427
## Total signifcant flu cases 5 out of 89 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 891
## The p-value is -> 0.3347701
## Total signifcant flu cases 5 out of 90 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 901
## The p-value is -> 0.2700708
## Total signifcant flu cases 5 out of 91 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 911
## The p-value is -> 0.2506011
## Total signifcant flu cases 5 out of 92 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 921
## The p-value is -> 0.1462292
## Total signifcant flu cases 5 out of 93 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 931
## The p-value is -> 0.08101955
## Total signifcant flu cases 5 out of 94 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 941
## The p-value is -> 0.9716899
## Total signifcant flu cases 5 out of 95 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 951
## The p-value is -> 0.1785673
## Total signifcant flu cases 5 out of 96 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 961
## The p-value is -> 0.2597192
## Total signifcant flu cases 5 out of 97 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 971
## The p-value is -> 0.1183305
## Total signifcant flu cases 5 out of 98 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 981
## The p-value is -> 0.9302266
## Total signifcant flu cases 5 out of 99 trials
## Smallest sample size for significant difference 261
##
## The sample size is -> 991
## The p-value is -> 0.3464314
## Total signifcant flu cases 5 out of 100 trials
## Smallest sample size for significant difference 261
Here we can see that as we alter the sample size and iterate through different sample sizes, we get close to having significant differences but it is not likely to happen (about 5 - 15% of the time). Now we will use loops to alter Mean and Standard Deviation to see if we can get significant changes.
First we will look at the mean:
n = 1000
count = 0
smallest_mean_size = 0
seq_5 <- seq(1, n, by = 5)
seq_10 <- seq(1, n, by = 10)
for (i in 1:length(seq_5)) {
flu_cases <- (rnorm(n,
mean = seq_5[i],
sd = stdev1))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
cat("\n","The mean is ->", seq_5[i], "\n")
cat("The p-value is ->", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
if (i > 1 & count == 0) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
smallest_mean_size = seq_5[i]
}
}
if (i > 1) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
count = count + 1
cat("There is a signifact difference between colder and warmer region flu cases at a mean value of ", seq_5[i], "with a p-value of ", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
}
}
cat("Total signifcant flu cases ", count, "out of ", i, "trials", "\n")
cat("Smallest mean for significant difference", smallest_mean_size, "\n")
}
##
## The mean is -> 1
## The p-value is -> 0.6294092
## Total signifcant flu cases 0 out of 1 trials
## Smallest mean for significant difference 0
##
## The mean is -> 6
## The p-value is -> 0.0980738
## Total signifcant flu cases 0 out of 2 trials
## Smallest mean for significant difference 0
##
## The mean is -> 11
## The p-value is -> 0.108941
## Total signifcant flu cases 0 out of 3 trials
## Smallest mean for significant difference 0
##
## The mean is -> 16
## The p-value is -> 0.2211129
## Total signifcant flu cases 0 out of 4 trials
## Smallest mean for significant difference 0
##
## The mean is -> 21
## The p-value is -> 0.9028631
## Total signifcant flu cases 0 out of 5 trials
## Smallest mean for significant difference 0
##
## The mean is -> 26
## The p-value is -> 0.4330346
## Total signifcant flu cases 0 out of 6 trials
## Smallest mean for significant difference 0
##
## The mean is -> 31
## The p-value is -> 0.6138268
## Total signifcant flu cases 0 out of 7 trials
## Smallest mean for significant difference 0
##
## The mean is -> 36
## The p-value is -> 0.4208079
## Total signifcant flu cases 0 out of 8 trials
## Smallest mean for significant difference 0
##
## The mean is -> 41
## The p-value is -> 0.4592023
## Total signifcant flu cases 0 out of 9 trials
## Smallest mean for significant difference 0
##
## The mean is -> 46
## The p-value is -> 0.09139908
## Total signifcant flu cases 0 out of 10 trials
## Smallest mean for significant difference 0
##
## The mean is -> 51
## The p-value is -> 0.2676931
## Total signifcant flu cases 0 out of 11 trials
## Smallest mean for significant difference 0
##
## The mean is -> 56
## The p-value is -> 0.4591053
## Total signifcant flu cases 0 out of 12 trials
## Smallest mean for significant difference 0
##
## The mean is -> 61
## The p-value is -> 0.7648518
## Total signifcant flu cases 0 out of 13 trials
## Smallest mean for significant difference 0
##
## The mean is -> 66
## The p-value is -> 0.3355406
## Total signifcant flu cases 0 out of 14 trials
## Smallest mean for significant difference 0
##
## The mean is -> 71
## The p-value is -> 0.3780525
## Total signifcant flu cases 0 out of 15 trials
## Smallest mean for significant difference 0
##
## The mean is -> 76
## The p-value is -> 0.7127179
## Total signifcant flu cases 0 out of 16 trials
## Smallest mean for significant difference 0
##
## The mean is -> 81
## The p-value is -> 0.1870674
## Total signifcant flu cases 0 out of 17 trials
## Smallest mean for significant difference 0
##
## The mean is -> 86
## The p-value is -> 0.3655113
## Total signifcant flu cases 0 out of 18 trials
## Smallest mean for significant difference 0
##
## The mean is -> 91
## The p-value is -> 0.3582473
## Total signifcant flu cases 0 out of 19 trials
## Smallest mean for significant difference 0
##
## The mean is -> 96
## The p-value is -> 0.9744462
## Total signifcant flu cases 0 out of 20 trials
## Smallest mean for significant difference 0
##
## The mean is -> 101
## The p-value is -> 0.3478826
## Total signifcant flu cases 0 out of 21 trials
## Smallest mean for significant difference 0
##
## The mean is -> 106
## The p-value is -> 0.9057021
## Total signifcant flu cases 0 out of 22 trials
## Smallest mean for significant difference 0
##
## The mean is -> 111
## The p-value is -> 0.397738
## Total signifcant flu cases 0 out of 23 trials
## Smallest mean for significant difference 0
##
## The mean is -> 116
## The p-value is -> 0.3002333
## Total signifcant flu cases 0 out of 24 trials
## Smallest mean for significant difference 0
##
## The mean is -> 121
## The p-value is -> 0.0967691
## Total signifcant flu cases 0 out of 25 trials
## Smallest mean for significant difference 0
##
## The mean is -> 126
## The p-value is -> 0.7028098
## Total signifcant flu cases 0 out of 26 trials
## Smallest mean for significant difference 0
##
## The mean is -> 131
## The p-value is -> 0.5520364
## Total signifcant flu cases 0 out of 27 trials
## Smallest mean for significant difference 0
##
## The mean is -> 136
## The p-value is -> 0.5219789
## Total signifcant flu cases 0 out of 28 trials
## Smallest mean for significant difference 0
##
## The mean is -> 141
## The p-value is -> 0.4227854
## Total signifcant flu cases 0 out of 29 trials
## Smallest mean for significant difference 0
##
## The mean is -> 146
## The p-value is -> 0.595814
## Total signifcant flu cases 0 out of 30 trials
## Smallest mean for significant difference 0
##
## The mean is -> 151
## The p-value is -> 0.3186232
## Total signifcant flu cases 0 out of 31 trials
## Smallest mean for significant difference 0
##
## The mean is -> 156
## The p-value is -> 0.4729749
## Total signifcant flu cases 0 out of 32 trials
## Smallest mean for significant difference 0
##
## The mean is -> 161
## The p-value is -> 0.9518259
## Total signifcant flu cases 0 out of 33 trials
## Smallest mean for significant difference 0
##
## The mean is -> 166
## The p-value is -> 0.9753226
## Total signifcant flu cases 0 out of 34 trials
## Smallest mean for significant difference 0
##
## The mean is -> 171
## The p-value is -> 0.6323891
## Total signifcant flu cases 0 out of 35 trials
## Smallest mean for significant difference 0
##
## The mean is -> 176
## The p-value is -> 0.1078136
## Total signifcant flu cases 0 out of 36 trials
## Smallest mean for significant difference 0
##
## The mean is -> 181
## The p-value is -> 0.1877873
## Total signifcant flu cases 0 out of 37 trials
## Smallest mean for significant difference 0
##
## The mean is -> 186
## The p-value is -> 0.9683209
## Total signifcant flu cases 0 out of 38 trials
## Smallest mean for significant difference 0
##
## The mean is -> 191
## The p-value is -> 0.9194659
## Total signifcant flu cases 0 out of 39 trials
## Smallest mean for significant difference 0
##
## The mean is -> 196
## The p-value is -> 0.3832199
## Total signifcant flu cases 0 out of 40 trials
## Smallest mean for significant difference 0
##
## The mean is -> 201
## The p-value is -> 0.06087828
## Total signifcant flu cases 0 out of 41 trials
## Smallest mean for significant difference 0
##
## The mean is -> 206
## The p-value is -> 0.8846775
## Total signifcant flu cases 0 out of 42 trials
## Smallest mean for significant difference 0
##
## The mean is -> 211
## The p-value is -> 0.4083054
## Total signifcant flu cases 0 out of 43 trials
## Smallest mean for significant difference 0
##
## The mean is -> 216
## The p-value is -> 0.1897492
## Total signifcant flu cases 0 out of 44 trials
## Smallest mean for significant difference 0
##
## The mean is -> 221
## The p-value is -> 0.5110704
## Total signifcant flu cases 0 out of 45 trials
## Smallest mean for significant difference 0
##
## The mean is -> 226
## The p-value is -> 0.6983069
## Total signifcant flu cases 0 out of 46 trials
## Smallest mean for significant difference 0
##
## The mean is -> 231
## The p-value is -> 0.9133948
## Total signifcant flu cases 0 out of 47 trials
## Smallest mean for significant difference 0
##
## The mean is -> 236
## The p-value is -> 0.2576413
## Total signifcant flu cases 0 out of 48 trials
## Smallest mean for significant difference 0
##
## The mean is -> 241
## The p-value is -> 0.869415
## Total signifcant flu cases 0 out of 49 trials
## Smallest mean for significant difference 0
##
## The mean is -> 246
## The p-value is -> 0.453628
## Total signifcant flu cases 0 out of 50 trials
## Smallest mean for significant difference 0
##
## The mean is -> 251
## The p-value is -> 0.2161361
## Total signifcant flu cases 0 out of 51 trials
## Smallest mean for significant difference 0
##
## The mean is -> 256
## The p-value is -> 0.9613764
## Total signifcant flu cases 0 out of 52 trials
## Smallest mean for significant difference 0
##
## The mean is -> 261
## The p-value is -> 0.3931404
## Total signifcant flu cases 0 out of 53 trials
## Smallest mean for significant difference 0
##
## The mean is -> 266
## The p-value is -> 0.1992096
## Total signifcant flu cases 0 out of 54 trials
## Smallest mean for significant difference 0
##
## The mean is -> 271
## The p-value is -> 0.7340795
## Total signifcant flu cases 0 out of 55 trials
## Smallest mean for significant difference 0
##
## The mean is -> 276
## The p-value is -> 0.6994924
## Total signifcant flu cases 0 out of 56 trials
## Smallest mean for significant difference 0
##
## The mean is -> 281
## The p-value is -> 0.8771581
## Total signifcant flu cases 0 out of 57 trials
## Smallest mean for significant difference 0
##
## The mean is -> 286
## The p-value is -> 0.3552992
## Total signifcant flu cases 0 out of 58 trials
## Smallest mean for significant difference 0
##
## The mean is -> 291
## The p-value is -> 0.2446058
## Total signifcant flu cases 0 out of 59 trials
## Smallest mean for significant difference 0
##
## The mean is -> 296
## The p-value is -> 0.2891482
## Total signifcant flu cases 0 out of 60 trials
## Smallest mean for significant difference 0
##
## The mean is -> 301
## The p-value is -> 0.148242
## Total signifcant flu cases 0 out of 61 trials
## Smallest mean for significant difference 0
##
## The mean is -> 306
## The p-value is -> 0.6094669
## Total signifcant flu cases 0 out of 62 trials
## Smallest mean for significant difference 0
##
## The mean is -> 311
## The p-value is -> 0.5820897
## Total signifcant flu cases 0 out of 63 trials
## Smallest mean for significant difference 0
##
## The mean is -> 316
## The p-value is -> 0.1208716
## Total signifcant flu cases 0 out of 64 trials
## Smallest mean for significant difference 0
##
## The mean is -> 321
## The p-value is -> 0.4013024
## Total signifcant flu cases 0 out of 65 trials
## Smallest mean for significant difference 0
##
## The mean is -> 326
## The p-value is -> 0.9157896
## Total signifcant flu cases 0 out of 66 trials
## Smallest mean for significant difference 0
##
## The mean is -> 331
## The p-value is -> 0.288315
## Total signifcant flu cases 0 out of 67 trials
## Smallest mean for significant difference 0
##
## The mean is -> 336
## The p-value is -> 0.6567135
## Total signifcant flu cases 0 out of 68 trials
## Smallest mean for significant difference 0
##
## The mean is -> 341
## The p-value is -> 0.9133032
## Total signifcant flu cases 0 out of 69 trials
## Smallest mean for significant difference 0
##
## The mean is -> 346
## The p-value is -> 0.9096135
## Total signifcant flu cases 0 out of 70 trials
## Smallest mean for significant difference 0
##
## The mean is -> 351
## The p-value is -> 0.03094406
## There is a signifact difference between colder and warmer region flu cases at a mean value of 351 with a p-value of 0.03094406
## Total signifcant flu cases 1 out of 71 trials
## Smallest mean for significant difference 351
##
## The mean is -> 356
## The p-value is -> 0.1958136
## Total signifcant flu cases 1 out of 72 trials
## Smallest mean for significant difference 351
##
## The mean is -> 361
## The p-value is -> 0.1174663
## Total signifcant flu cases 1 out of 73 trials
## Smallest mean for significant difference 351
##
## The mean is -> 366
## The p-value is -> 0.5644649
## Total signifcant flu cases 1 out of 74 trials
## Smallest mean for significant difference 351
##
## The mean is -> 371
## The p-value is -> 0.8267449
## Total signifcant flu cases 1 out of 75 trials
## Smallest mean for significant difference 351
##
## The mean is -> 376
## The p-value is -> 0.3378817
## Total signifcant flu cases 1 out of 76 trials
## Smallest mean for significant difference 351
##
## The mean is -> 381
## The p-value is -> 0.07584788
## Total signifcant flu cases 1 out of 77 trials
## Smallest mean for significant difference 351
##
## The mean is -> 386
## The p-value is -> 0.4342604
## Total signifcant flu cases 1 out of 78 trials
## Smallest mean for significant difference 351
##
## The mean is -> 391
## The p-value is -> 0.375363
## Total signifcant flu cases 1 out of 79 trials
## Smallest mean for significant difference 351
##
## The mean is -> 396
## The p-value is -> 0.1784625
## Total signifcant flu cases 1 out of 80 trials
## Smallest mean for significant difference 351
##
## The mean is -> 401
## The p-value is -> 0.4967869
## Total signifcant flu cases 1 out of 81 trials
## Smallest mean for significant difference 351
##
## The mean is -> 406
## The p-value is -> 0.4209707
## Total signifcant flu cases 1 out of 82 trials
## Smallest mean for significant difference 351
##
## The mean is -> 411
## The p-value is -> 0.4153493
## Total signifcant flu cases 1 out of 83 trials
## Smallest mean for significant difference 351
##
## The mean is -> 416
## The p-value is -> 0.481055
## Total signifcant flu cases 1 out of 84 trials
## Smallest mean for significant difference 351
##
## The mean is -> 421
## The p-value is -> 0.05203791
## Total signifcant flu cases 1 out of 85 trials
## Smallest mean for significant difference 351
##
## The mean is -> 426
## The p-value is -> 0.2457755
## Total signifcant flu cases 1 out of 86 trials
## Smallest mean for significant difference 351
##
## The mean is -> 431
## The p-value is -> 0.2179357
## Total signifcant flu cases 1 out of 87 trials
## Smallest mean for significant difference 351
##
## The mean is -> 436
## The p-value is -> 0.3625287
## Total signifcant flu cases 1 out of 88 trials
## Smallest mean for significant difference 351
##
## The mean is -> 441
## The p-value is -> 0.2365123
## Total signifcant flu cases 1 out of 89 trials
## Smallest mean for significant difference 351
##
## The mean is -> 446
## The p-value is -> 0.7737081
## Total signifcant flu cases 1 out of 90 trials
## Smallest mean for significant difference 351
##
## The mean is -> 451
## The p-value is -> 0.9713704
## Total signifcant flu cases 1 out of 91 trials
## Smallest mean for significant difference 351
##
## The mean is -> 456
## The p-value is -> 0.2266247
## Total signifcant flu cases 1 out of 92 trials
## Smallest mean for significant difference 351
##
## The mean is -> 461
## The p-value is -> 0.8067724
## Total signifcant flu cases 1 out of 93 trials
## Smallest mean for significant difference 351
##
## The mean is -> 466
## The p-value is -> 0.4960461
## Total signifcant flu cases 1 out of 94 trials
## Smallest mean for significant difference 351
##
## The mean is -> 471
## The p-value is -> 0.8767869
## Total signifcant flu cases 1 out of 95 trials
## Smallest mean for significant difference 351
##
## The mean is -> 476
## The p-value is -> 0.5899058
## Total signifcant flu cases 1 out of 96 trials
## Smallest mean for significant difference 351
##
## The mean is -> 481
## The p-value is -> 0.4063524
## Total signifcant flu cases 1 out of 97 trials
## Smallest mean for significant difference 351
##
## The mean is -> 486
## The p-value is -> 0.9084474
## Total signifcant flu cases 1 out of 98 trials
## Smallest mean for significant difference 351
##
## The mean is -> 491
## The p-value is -> 0.1589016
## Total signifcant flu cases 1 out of 99 trials
## Smallest mean for significant difference 351
##
## The mean is -> 496
## The p-value is -> 0.8924491
## Total signifcant flu cases 1 out of 100 trials
## Smallest mean for significant difference 351
##
## The mean is -> 501
## The p-value is -> 0.6009671
## Total signifcant flu cases 1 out of 101 trials
## Smallest mean for significant difference 351
##
## The mean is -> 506
## The p-value is -> 0.3681754
## Total signifcant flu cases 1 out of 102 trials
## Smallest mean for significant difference 351
##
## The mean is -> 511
## The p-value is -> 0.980482
## Total signifcant flu cases 1 out of 103 trials
## Smallest mean for significant difference 351
##
## The mean is -> 516
## The p-value is -> 0.8223378
## Total signifcant flu cases 1 out of 104 trials
## Smallest mean for significant difference 351
##
## The mean is -> 521
## The p-value is -> 0.2849494
## Total signifcant flu cases 1 out of 105 trials
## Smallest mean for significant difference 351
##
## The mean is -> 526
## The p-value is -> 0.2319742
## Total signifcant flu cases 1 out of 106 trials
## Smallest mean for significant difference 351
##
## The mean is -> 531
## The p-value is -> 0.08707715
## Total signifcant flu cases 1 out of 107 trials
## Smallest mean for significant difference 351
##
## The mean is -> 536
## The p-value is -> 0.6762076
## Total signifcant flu cases 1 out of 108 trials
## Smallest mean for significant difference 351
##
## The mean is -> 541
## The p-value is -> 0.8592928
## Total signifcant flu cases 1 out of 109 trials
## Smallest mean for significant difference 351
##
## The mean is -> 546
## The p-value is -> 0.1791758
## Total signifcant flu cases 1 out of 110 trials
## Smallest mean for significant difference 351
##
## The mean is -> 551
## The p-value is -> 0.9222941
## Total signifcant flu cases 1 out of 111 trials
## Smallest mean for significant difference 351
##
## The mean is -> 556
## The p-value is -> 0.8970039
## Total signifcant flu cases 1 out of 112 trials
## Smallest mean for significant difference 351
##
## The mean is -> 561
## The p-value is -> 0.993143
## Total signifcant flu cases 1 out of 113 trials
## Smallest mean for significant difference 351
##
## The mean is -> 566
## The p-value is -> 0.4907093
## Total signifcant flu cases 1 out of 114 trials
## Smallest mean for significant difference 351
##
## The mean is -> 571
## The p-value is -> 0.5829258
## Total signifcant flu cases 1 out of 115 trials
## Smallest mean for significant difference 351
##
## The mean is -> 576
## The p-value is -> 0.1837719
## Total signifcant flu cases 1 out of 116 trials
## Smallest mean for significant difference 351
##
## The mean is -> 581
## The p-value is -> 0.8866689
## Total signifcant flu cases 1 out of 117 trials
## Smallest mean for significant difference 351
##
## The mean is -> 586
## The p-value is -> 0.4113946
## Total signifcant flu cases 1 out of 118 trials
## Smallest mean for significant difference 351
##
## The mean is -> 591
## The p-value is -> 0.8588362
## Total signifcant flu cases 1 out of 119 trials
## Smallest mean for significant difference 351
##
## The mean is -> 596
## The p-value is -> 0.5917008
## Total signifcant flu cases 1 out of 120 trials
## Smallest mean for significant difference 351
##
## The mean is -> 601
## The p-value is -> 0.207668
## Total signifcant flu cases 1 out of 121 trials
## Smallest mean for significant difference 351
##
## The mean is -> 606
## The p-value is -> 0.1583368
## Total signifcant flu cases 1 out of 122 trials
## Smallest mean for significant difference 351
##
## The mean is -> 611
## The p-value is -> 0.473294
## Total signifcant flu cases 1 out of 123 trials
## Smallest mean for significant difference 351
##
## The mean is -> 616
## The p-value is -> 0.6441086
## Total signifcant flu cases 1 out of 124 trials
## Smallest mean for significant difference 351
##
## The mean is -> 621
## The p-value is -> 0.2096791
## Total signifcant flu cases 1 out of 125 trials
## Smallest mean for significant difference 351
##
## The mean is -> 626
## The p-value is -> 0.3853782
## Total signifcant flu cases 1 out of 126 trials
## Smallest mean for significant difference 351
##
## The mean is -> 631
## The p-value is -> 0.5523691
## Total signifcant flu cases 1 out of 127 trials
## Smallest mean for significant difference 351
##
## The mean is -> 636
## The p-value is -> 0.6525928
## Total signifcant flu cases 1 out of 128 trials
## Smallest mean for significant difference 351
##
## The mean is -> 641
## The p-value is -> 0.6889215
## Total signifcant flu cases 1 out of 129 trials
## Smallest mean for significant difference 351
##
## The mean is -> 646
## The p-value is -> 0.05050328
## Total signifcant flu cases 1 out of 130 trials
## Smallest mean for significant difference 351
##
## The mean is -> 651
## The p-value is -> 0.09358994
## Total signifcant flu cases 1 out of 131 trials
## Smallest mean for significant difference 351
##
## The mean is -> 656
## The p-value is -> 0.6500115
## Total signifcant flu cases 1 out of 132 trials
## Smallest mean for significant difference 351
##
## The mean is -> 661
## The p-value is -> 0.03102176
## There is a signifact difference between colder and warmer region flu cases at a mean value of 661 with a p-value of 0.03102176
## Total signifcant flu cases 2 out of 133 trials
## Smallest mean for significant difference 351
##
## The mean is -> 666
## The p-value is -> 0.6341848
## Total signifcant flu cases 2 out of 134 trials
## Smallest mean for significant difference 351
##
## The mean is -> 671
## The p-value is -> 0.7940603
## Total signifcant flu cases 2 out of 135 trials
## Smallest mean for significant difference 351
##
## The mean is -> 676
## The p-value is -> 0.7690327
## Total signifcant flu cases 2 out of 136 trials
## Smallest mean for significant difference 351
##
## The mean is -> 681
## The p-value is -> 0.5267041
## Total signifcant flu cases 2 out of 137 trials
## Smallest mean for significant difference 351
##
## The mean is -> 686
## The p-value is -> 0.4410342
## Total signifcant flu cases 2 out of 138 trials
## Smallest mean for significant difference 351
##
## The mean is -> 691
## The p-value is -> 0.7961298
## Total signifcant flu cases 2 out of 139 trials
## Smallest mean for significant difference 351
##
## The mean is -> 696
## The p-value is -> 0.06540886
## Total signifcant flu cases 2 out of 140 trials
## Smallest mean for significant difference 351
##
## The mean is -> 701
## The p-value is -> 0.2339643
## Total signifcant flu cases 2 out of 141 trials
## Smallest mean for significant difference 351
##
## The mean is -> 706
## The p-value is -> 0.4265065
## Total signifcant flu cases 2 out of 142 trials
## Smallest mean for significant difference 351
##
## The mean is -> 711
## The p-value is -> 0.9823478
## Total signifcant flu cases 2 out of 143 trials
## Smallest mean for significant difference 351
##
## The mean is -> 716
## The p-value is -> 0.6066509
## Total signifcant flu cases 2 out of 144 trials
## Smallest mean for significant difference 351
##
## The mean is -> 721
## The p-value is -> 0.0445174
## There is a signifact difference between colder and warmer region flu cases at a mean value of 721 with a p-value of 0.0445174
## Total signifcant flu cases 3 out of 145 trials
## Smallest mean for significant difference 351
##
## The mean is -> 726
## The p-value is -> 0.6315536
## Total signifcant flu cases 3 out of 146 trials
## Smallest mean for significant difference 351
##
## The mean is -> 731
## The p-value is -> 0.1654869
## Total signifcant flu cases 3 out of 147 trials
## Smallest mean for significant difference 351
##
## The mean is -> 736
## The p-value is -> 0.4369637
## Total signifcant flu cases 3 out of 148 trials
## Smallest mean for significant difference 351
##
## The mean is -> 741
## The p-value is -> 0.3233097
## Total signifcant flu cases 3 out of 149 trials
## Smallest mean for significant difference 351
##
## The mean is -> 746
## The p-value is -> 0.7068512
## Total signifcant flu cases 3 out of 150 trials
## Smallest mean for significant difference 351
##
## The mean is -> 751
## The p-value is -> 0.1700876
## Total signifcant flu cases 3 out of 151 trials
## Smallest mean for significant difference 351
##
## The mean is -> 756
## The p-value is -> 0.4558587
## Total signifcant flu cases 3 out of 152 trials
## Smallest mean for significant difference 351
##
## The mean is -> 761
## The p-value is -> 0.5414984
## Total signifcant flu cases 3 out of 153 trials
## Smallest mean for significant difference 351
##
## The mean is -> 766
## The p-value is -> 0.5236461
## Total signifcant flu cases 3 out of 154 trials
## Smallest mean for significant difference 351
##
## The mean is -> 771
## The p-value is -> 0.5490883
## Total signifcant flu cases 3 out of 155 trials
## Smallest mean for significant difference 351
##
## The mean is -> 776
## The p-value is -> 0.8251093
## Total signifcant flu cases 3 out of 156 trials
## Smallest mean for significant difference 351
##
## The mean is -> 781
## The p-value is -> 0.3934739
## Total signifcant flu cases 3 out of 157 trials
## Smallest mean for significant difference 351
##
## The mean is -> 786
## The p-value is -> 0.008203447
## There is a signifact difference between colder and warmer region flu cases at a mean value of 786 with a p-value of 0.008203447
## Total signifcant flu cases 4 out of 158 trials
## Smallest mean for significant difference 351
##
## The mean is -> 791
## The p-value is -> 0.9649499
## Total signifcant flu cases 4 out of 159 trials
## Smallest mean for significant difference 351
##
## The mean is -> 796
## The p-value is -> 0.3532289
## Total signifcant flu cases 4 out of 160 trials
## Smallest mean for significant difference 351
##
## The mean is -> 801
## The p-value is -> 0.4986937
## Total signifcant flu cases 4 out of 161 trials
## Smallest mean for significant difference 351
##
## The mean is -> 806
## The p-value is -> 0.7728943
## Total signifcant flu cases 4 out of 162 trials
## Smallest mean for significant difference 351
##
## The mean is -> 811
## The p-value is -> 0.7754159
## Total signifcant flu cases 4 out of 163 trials
## Smallest mean for significant difference 351
##
## The mean is -> 816
## The p-value is -> 0.1946631
## Total signifcant flu cases 4 out of 164 trials
## Smallest mean for significant difference 351
##
## The mean is -> 821
## The p-value is -> 0.90411
## Total signifcant flu cases 4 out of 165 trials
## Smallest mean for significant difference 351
##
## The mean is -> 826
## The p-value is -> 0.2390831
## Total signifcant flu cases 4 out of 166 trials
## Smallest mean for significant difference 351
##
## The mean is -> 831
## The p-value is -> 0.5747001
## Total signifcant flu cases 4 out of 167 trials
## Smallest mean for significant difference 351
##
## The mean is -> 836
## The p-value is -> 0.6838151
## Total signifcant flu cases 4 out of 168 trials
## Smallest mean for significant difference 351
##
## The mean is -> 841
## The p-value is -> 0.1553447
## Total signifcant flu cases 4 out of 169 trials
## Smallest mean for significant difference 351
##
## The mean is -> 846
## The p-value is -> 0.4016984
## Total signifcant flu cases 4 out of 170 trials
## Smallest mean for significant difference 351
##
## The mean is -> 851
## The p-value is -> 0.125751
## Total signifcant flu cases 4 out of 171 trials
## Smallest mean for significant difference 351
##
## The mean is -> 856
## The p-value is -> 0.7949279
## Total signifcant flu cases 4 out of 172 trials
## Smallest mean for significant difference 351
##
## The mean is -> 861
## The p-value is -> 0.1946302
## Total signifcant flu cases 4 out of 173 trials
## Smallest mean for significant difference 351
##
## The mean is -> 866
## The p-value is -> 0.7585338
## Total signifcant flu cases 4 out of 174 trials
## Smallest mean for significant difference 351
##
## The mean is -> 871
## The p-value is -> 0.7105475
## Total signifcant flu cases 4 out of 175 trials
## Smallest mean for significant difference 351
##
## The mean is -> 876
## The p-value is -> 0.249202
## Total signifcant flu cases 4 out of 176 trials
## Smallest mean for significant difference 351
##
## The mean is -> 881
## The p-value is -> 0.03246643
## There is a signifact difference between colder and warmer region flu cases at a mean value of 881 with a p-value of 0.03246643
## Total signifcant flu cases 5 out of 177 trials
## Smallest mean for significant difference 351
##
## The mean is -> 886
## The p-value is -> 0.3602979
## Total signifcant flu cases 5 out of 178 trials
## Smallest mean for significant difference 351
##
## The mean is -> 891
## The p-value is -> 0.8059529
## Total signifcant flu cases 5 out of 179 trials
## Smallest mean for significant difference 351
##
## The mean is -> 896
## The p-value is -> 0.4433425
## Total signifcant flu cases 5 out of 180 trials
## Smallest mean for significant difference 351
##
## The mean is -> 901
## The p-value is -> 0.4691468
## Total signifcant flu cases 5 out of 181 trials
## Smallest mean for significant difference 351
##
## The mean is -> 906
## The p-value is -> 0.1618057
## Total signifcant flu cases 5 out of 182 trials
## Smallest mean for significant difference 351
##
## The mean is -> 911
## The p-value is -> 0.9151926
## Total signifcant flu cases 5 out of 183 trials
## Smallest mean for significant difference 351
##
## The mean is -> 916
## The p-value is -> 0.1039725
## Total signifcant flu cases 5 out of 184 trials
## Smallest mean for significant difference 351
##
## The mean is -> 921
## The p-value is -> 0.1184916
## Total signifcant flu cases 5 out of 185 trials
## Smallest mean for significant difference 351
##
## The mean is -> 926
## The p-value is -> 0.3206211
## Total signifcant flu cases 5 out of 186 trials
## Smallest mean for significant difference 351
##
## The mean is -> 931
## The p-value is -> 0.8373892
## Total signifcant flu cases 5 out of 187 trials
## Smallest mean for significant difference 351
##
## The mean is -> 936
## The p-value is -> 0.4638345
## Total signifcant flu cases 5 out of 188 trials
## Smallest mean for significant difference 351
##
## The mean is -> 941
## The p-value is -> 0.8149721
## Total signifcant flu cases 5 out of 189 trials
## Smallest mean for significant difference 351
##
## The mean is -> 946
## The p-value is -> 0.02805346
## There is a signifact difference between colder and warmer region flu cases at a mean value of 946 with a p-value of 0.02805346
## Total signifcant flu cases 6 out of 190 trials
## Smallest mean for significant difference 351
##
## The mean is -> 951
## The p-value is -> 0.9520372
## Total signifcant flu cases 6 out of 191 trials
## Smallest mean for significant difference 351
##
## The mean is -> 956
## The p-value is -> 0.1866317
## Total signifcant flu cases 6 out of 192 trials
## Smallest mean for significant difference 351
##
## The mean is -> 961
## The p-value is -> 0.2892103
## Total signifcant flu cases 6 out of 193 trials
## Smallest mean for significant difference 351
##
## The mean is -> 966
## The p-value is -> 0.7793073
## Total signifcant flu cases 6 out of 194 trials
## Smallest mean for significant difference 351
##
## The mean is -> 971
## The p-value is -> 0.5052709
## Total signifcant flu cases 6 out of 195 trials
## Smallest mean for significant difference 351
##
## The mean is -> 976
## The p-value is -> 0.1825231
## Total signifcant flu cases 6 out of 196 trials
## Smallest mean for significant difference 351
##
## The mean is -> 981
## The p-value is -> 0.08535514
## Total signifcant flu cases 6 out of 197 trials
## Smallest mean for significant difference 351
##
## The mean is -> 986
## The p-value is -> 0.9837567
## Total signifcant flu cases 6 out of 198 trials
## Smallest mean for significant difference 351
##
## The mean is -> 991
## The p-value is -> 0.3225141
## Total signifcant flu cases 6 out of 199 trials
## Smallest mean for significant difference 351
##
## The mean is -> 996
## The p-value is -> 0.1574491
## Total signifcant flu cases 6 out of 200 trials
## Smallest mean for significant difference 351
count = 0
for (i in 1:length(seq_10)) {
flu_cases <- (rnorm(n,
mean = seq_10[i],
sd = stdev1))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
cat("\n","The mean is ->", seq_10[i], "\n")
cat("The p-value is ->", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
if (i > 1) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
count = count + 1
cat("There is a signifact difference between colder and warmer region flu cases at a mean value of ", seq_10[i], "with a p-value of ", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
}
}
cat("Total signifcant flu cases ", count, "out of ", i, "trials", "\n")
cat("Smallest mean for significant difference", smallest_mean_size, "\n")
}
##
## The mean is -> 1
## The p-value is -> 0.9723208
## Total signifcant flu cases 0 out of 1 trials
## Smallest mean for significant difference 351
##
## The mean is -> 11
## The p-value is -> 0.5224795
## Total signifcant flu cases 0 out of 2 trials
## Smallest mean for significant difference 351
##
## The mean is -> 21
## The p-value is -> 0.9031117
## Total signifcant flu cases 0 out of 3 trials
## Smallest mean for significant difference 351
##
## The mean is -> 31
## The p-value is -> 0.6729678
## Total signifcant flu cases 0 out of 4 trials
## Smallest mean for significant difference 351
##
## The mean is -> 41
## The p-value is -> 0.003393514
## There is a signifact difference between colder and warmer region flu cases at a mean value of 41 with a p-value of 0.003393514
## Total signifcant flu cases 1 out of 5 trials
## Smallest mean for significant difference 351
##
## The mean is -> 51
## The p-value is -> 0.2015388
## Total signifcant flu cases 1 out of 6 trials
## Smallest mean for significant difference 351
##
## The mean is -> 61
## The p-value is -> 0.8868883
## Total signifcant flu cases 1 out of 7 trials
## Smallest mean for significant difference 351
##
## The mean is -> 71
## The p-value is -> 0.5065441
## Total signifcant flu cases 1 out of 8 trials
## Smallest mean for significant difference 351
##
## The mean is -> 81
## The p-value is -> 0.2471436
## Total signifcant flu cases 1 out of 9 trials
## Smallest mean for significant difference 351
##
## The mean is -> 91
## The p-value is -> 0.1005468
## Total signifcant flu cases 1 out of 10 trials
## Smallest mean for significant difference 351
##
## The mean is -> 101
## The p-value is -> 0.4512696
## Total signifcant flu cases 1 out of 11 trials
## Smallest mean for significant difference 351
##
## The mean is -> 111
## The p-value is -> 0.7483212
## Total signifcant flu cases 1 out of 12 trials
## Smallest mean for significant difference 351
##
## The mean is -> 121
## The p-value is -> 0.05555331
## Total signifcant flu cases 1 out of 13 trials
## Smallest mean for significant difference 351
##
## The mean is -> 131
## The p-value is -> 0.5920528
## Total signifcant flu cases 1 out of 14 trials
## Smallest mean for significant difference 351
##
## The mean is -> 141
## The p-value is -> 0.1834114
## Total signifcant flu cases 1 out of 15 trials
## Smallest mean for significant difference 351
##
## The mean is -> 151
## The p-value is -> 0.9559285
## Total signifcant flu cases 1 out of 16 trials
## Smallest mean for significant difference 351
##
## The mean is -> 161
## The p-value is -> 0.9136589
## Total signifcant flu cases 1 out of 17 trials
## Smallest mean for significant difference 351
##
## The mean is -> 171
## The p-value is -> 0.1705377
## Total signifcant flu cases 1 out of 18 trials
## Smallest mean for significant difference 351
##
## The mean is -> 181
## The p-value is -> 0.830143
## Total signifcant flu cases 1 out of 19 trials
## Smallest mean for significant difference 351
##
## The mean is -> 191
## The p-value is -> 0.3946712
## Total signifcant flu cases 1 out of 20 trials
## Smallest mean for significant difference 351
##
## The mean is -> 201
## The p-value is -> 0.9595559
## Total signifcant flu cases 1 out of 21 trials
## Smallest mean for significant difference 351
##
## The mean is -> 211
## The p-value is -> 0.6939159
## Total signifcant flu cases 1 out of 22 trials
## Smallest mean for significant difference 351
##
## The mean is -> 221
## The p-value is -> 0.9143925
## Total signifcant flu cases 1 out of 23 trials
## Smallest mean for significant difference 351
##
## The mean is -> 231
## The p-value is -> 0.3099618
## Total signifcant flu cases 1 out of 24 trials
## Smallest mean for significant difference 351
##
## The mean is -> 241
## The p-value is -> 0.0679993
## Total signifcant flu cases 1 out of 25 trials
## Smallest mean for significant difference 351
##
## The mean is -> 251
## The p-value is -> 0.8914952
## Total signifcant flu cases 1 out of 26 trials
## Smallest mean for significant difference 351
##
## The mean is -> 261
## The p-value is -> 0.6603441
## Total signifcant flu cases 1 out of 27 trials
## Smallest mean for significant difference 351
##
## The mean is -> 271
## The p-value is -> 0.656667
## Total signifcant flu cases 1 out of 28 trials
## Smallest mean for significant difference 351
##
## The mean is -> 281
## The p-value is -> 0.9425376
## Total signifcant flu cases 1 out of 29 trials
## Smallest mean for significant difference 351
##
## The mean is -> 291
## The p-value is -> 0.3614884
## Total signifcant flu cases 1 out of 30 trials
## Smallest mean for significant difference 351
##
## The mean is -> 301
## The p-value is -> 0.666138
## Total signifcant flu cases 1 out of 31 trials
## Smallest mean for significant difference 351
##
## The mean is -> 311
## The p-value is -> 0.1071825
## Total signifcant flu cases 1 out of 32 trials
## Smallest mean for significant difference 351
##
## The mean is -> 321
## The p-value is -> 0.3561309
## Total signifcant flu cases 1 out of 33 trials
## Smallest mean for significant difference 351
##
## The mean is -> 331
## The p-value is -> 0.6628361
## Total signifcant flu cases 1 out of 34 trials
## Smallest mean for significant difference 351
##
## The mean is -> 341
## The p-value is -> 0.5231457
## Total signifcant flu cases 1 out of 35 trials
## Smallest mean for significant difference 351
##
## The mean is -> 351
## The p-value is -> 0.1577404
## Total signifcant flu cases 1 out of 36 trials
## Smallest mean for significant difference 351
##
## The mean is -> 361
## The p-value is -> 0.7417251
## Total signifcant flu cases 1 out of 37 trials
## Smallest mean for significant difference 351
##
## The mean is -> 371
## The p-value is -> 0.774522
## Total signifcant flu cases 1 out of 38 trials
## Smallest mean for significant difference 351
##
## The mean is -> 381
## The p-value is -> 0.5369836
## Total signifcant flu cases 1 out of 39 trials
## Smallest mean for significant difference 351
##
## The mean is -> 391
## The p-value is -> 0.1074897
## Total signifcant flu cases 1 out of 40 trials
## Smallest mean for significant difference 351
##
## The mean is -> 401
## The p-value is -> 0.1660229
## Total signifcant flu cases 1 out of 41 trials
## Smallest mean for significant difference 351
##
## The mean is -> 411
## The p-value is -> 0.2251047
## Total signifcant flu cases 1 out of 42 trials
## Smallest mean for significant difference 351
##
## The mean is -> 421
## The p-value is -> 0.8297658
## Total signifcant flu cases 1 out of 43 trials
## Smallest mean for significant difference 351
##
## The mean is -> 431
## The p-value is -> 0.2129434
## Total signifcant flu cases 1 out of 44 trials
## Smallest mean for significant difference 351
##
## The mean is -> 441
## The p-value is -> 0.9522409
## Total signifcant flu cases 1 out of 45 trials
## Smallest mean for significant difference 351
##
## The mean is -> 451
## The p-value is -> 0.4761852
## Total signifcant flu cases 1 out of 46 trials
## Smallest mean for significant difference 351
##
## The mean is -> 461
## The p-value is -> 0.8772994
## Total signifcant flu cases 1 out of 47 trials
## Smallest mean for significant difference 351
##
## The mean is -> 471
## The p-value is -> 0.3965405
## Total signifcant flu cases 1 out of 48 trials
## Smallest mean for significant difference 351
##
## The mean is -> 481
## The p-value is -> 0.8326065
## Total signifcant flu cases 1 out of 49 trials
## Smallest mean for significant difference 351
##
## The mean is -> 491
## The p-value is -> 0.1146276
## Total signifcant flu cases 1 out of 50 trials
## Smallest mean for significant difference 351
##
## The mean is -> 501
## The p-value is -> 0.7155539
## Total signifcant flu cases 1 out of 51 trials
## Smallest mean for significant difference 351
##
## The mean is -> 511
## The p-value is -> 0.2260117
## Total signifcant flu cases 1 out of 52 trials
## Smallest mean for significant difference 351
##
## The mean is -> 521
## The p-value is -> 0.2131886
## Total signifcant flu cases 1 out of 53 trials
## Smallest mean for significant difference 351
##
## The mean is -> 531
## The p-value is -> 0.9664006
## Total signifcant flu cases 1 out of 54 trials
## Smallest mean for significant difference 351
##
## The mean is -> 541
## The p-value is -> 0.9116479
## Total signifcant flu cases 1 out of 55 trials
## Smallest mean for significant difference 351
##
## The mean is -> 551
## The p-value is -> 0.7261777
## Total signifcant flu cases 1 out of 56 trials
## Smallest mean for significant difference 351
##
## The mean is -> 561
## The p-value is -> 0.1215297
## Total signifcant flu cases 1 out of 57 trials
## Smallest mean for significant difference 351
##
## The mean is -> 571
## The p-value is -> 0.787963
## Total signifcant flu cases 1 out of 58 trials
## Smallest mean for significant difference 351
##
## The mean is -> 581
## The p-value is -> 0.8898109
## Total signifcant flu cases 1 out of 59 trials
## Smallest mean for significant difference 351
##
## The mean is -> 591
## The p-value is -> 0.3499282
## Total signifcant flu cases 1 out of 60 trials
## Smallest mean for significant difference 351
##
## The mean is -> 601
## The p-value is -> 0.6898711
## Total signifcant flu cases 1 out of 61 trials
## Smallest mean for significant difference 351
##
## The mean is -> 611
## The p-value is -> 0.5550041
## Total signifcant flu cases 1 out of 62 trials
## Smallest mean for significant difference 351
##
## The mean is -> 621
## The p-value is -> 0.1369829
## Total signifcant flu cases 1 out of 63 trials
## Smallest mean for significant difference 351
##
## The mean is -> 631
## The p-value is -> 0.3682489
## Total signifcant flu cases 1 out of 64 trials
## Smallest mean for significant difference 351
##
## The mean is -> 641
## The p-value is -> 0.05658386
## Total signifcant flu cases 1 out of 65 trials
## Smallest mean for significant difference 351
##
## The mean is -> 651
## The p-value is -> 0.9909932
## Total signifcant flu cases 1 out of 66 trials
## Smallest mean for significant difference 351
##
## The mean is -> 661
## The p-value is -> 0.08589805
## Total signifcant flu cases 1 out of 67 trials
## Smallest mean for significant difference 351
##
## The mean is -> 671
## The p-value is -> 0.2367026
## Total signifcant flu cases 1 out of 68 trials
## Smallest mean for significant difference 351
##
## The mean is -> 681
## The p-value is -> 0.8251594
## Total signifcant flu cases 1 out of 69 trials
## Smallest mean for significant difference 351
##
## The mean is -> 691
## The p-value is -> 0.5123982
## Total signifcant flu cases 1 out of 70 trials
## Smallest mean for significant difference 351
##
## The mean is -> 701
## The p-value is -> 0.7583511
## Total signifcant flu cases 1 out of 71 trials
## Smallest mean for significant difference 351
##
## The mean is -> 711
## The p-value is -> 0.528616
## Total signifcant flu cases 1 out of 72 trials
## Smallest mean for significant difference 351
##
## The mean is -> 721
## The p-value is -> 0.07112723
## Total signifcant flu cases 1 out of 73 trials
## Smallest mean for significant difference 351
##
## The mean is -> 731
## The p-value is -> 0.2521965
## Total signifcant flu cases 1 out of 74 trials
## Smallest mean for significant difference 351
##
## The mean is -> 741
## The p-value is -> 0.294557
## Total signifcant flu cases 1 out of 75 trials
## Smallest mean for significant difference 351
##
## The mean is -> 751
## The p-value is -> 0.3535556
## Total signifcant flu cases 1 out of 76 trials
## Smallest mean for significant difference 351
##
## The mean is -> 761
## The p-value is -> 0.6962779
## Total signifcant flu cases 1 out of 77 trials
## Smallest mean for significant difference 351
##
## The mean is -> 771
## The p-value is -> 0.979388
## Total signifcant flu cases 1 out of 78 trials
## Smallest mean for significant difference 351
##
## The mean is -> 781
## The p-value is -> 0.6173703
## Total signifcant flu cases 1 out of 79 trials
## Smallest mean for significant difference 351
##
## The mean is -> 791
## The p-value is -> 0.199368
## Total signifcant flu cases 1 out of 80 trials
## Smallest mean for significant difference 351
##
## The mean is -> 801
## The p-value is -> 0.4823889
## Total signifcant flu cases 1 out of 81 trials
## Smallest mean for significant difference 351
##
## The mean is -> 811
## The p-value is -> 0.3713603
## Total signifcant flu cases 1 out of 82 trials
## Smallest mean for significant difference 351
##
## The mean is -> 821
## The p-value is -> 0.1355641
## Total signifcant flu cases 1 out of 83 trials
## Smallest mean for significant difference 351
##
## The mean is -> 831
## The p-value is -> 0.2582349
## Total signifcant flu cases 1 out of 84 trials
## Smallest mean for significant difference 351
##
## The mean is -> 841
## The p-value is -> 0.8693118
## Total signifcant flu cases 1 out of 85 trials
## Smallest mean for significant difference 351
##
## The mean is -> 851
## The p-value is -> 0.4364386
## Total signifcant flu cases 1 out of 86 trials
## Smallest mean for significant difference 351
##
## The mean is -> 861
## The p-value is -> 0.6631283
## Total signifcant flu cases 1 out of 87 trials
## Smallest mean for significant difference 351
##
## The mean is -> 871
## The p-value is -> 0.6107999
## Total signifcant flu cases 1 out of 88 trials
## Smallest mean for significant difference 351
##
## The mean is -> 881
## The p-value is -> 0.732139
## Total signifcant flu cases 1 out of 89 trials
## Smallest mean for significant difference 351
##
## The mean is -> 891
## The p-value is -> 0.9184461
## Total signifcant flu cases 1 out of 90 trials
## Smallest mean for significant difference 351
##
## The mean is -> 901
## The p-value is -> 0.5337544
## Total signifcant flu cases 1 out of 91 trials
## Smallest mean for significant difference 351
##
## The mean is -> 911
## The p-value is -> 0.6753215
## Total signifcant flu cases 1 out of 92 trials
## Smallest mean for significant difference 351
##
## The mean is -> 921
## The p-value is -> 0.4012866
## Total signifcant flu cases 1 out of 93 trials
## Smallest mean for significant difference 351
##
## The mean is -> 931
## The p-value is -> 0.5789441
## Total signifcant flu cases 1 out of 94 trials
## Smallest mean for significant difference 351
##
## The mean is -> 941
## The p-value is -> 0.5422278
## Total signifcant flu cases 1 out of 95 trials
## Smallest mean for significant difference 351
##
## The mean is -> 951
## The p-value is -> 0.5407129
## Total signifcant flu cases 1 out of 96 trials
## Smallest mean for significant difference 351
##
## The mean is -> 961
## The p-value is -> 0.4782265
## Total signifcant flu cases 1 out of 97 trials
## Smallest mean for significant difference 351
##
## The mean is -> 971
## The p-value is -> 0.8831199
## Total signifcant flu cases 1 out of 98 trials
## Smallest mean for significant difference 351
##
## The mean is -> 981
## The p-value is -> 0.7327152
## Total signifcant flu cases 1 out of 99 trials
## Smallest mean for significant difference 351
##
## The mean is -> 991
## The p-value is -> 0.2966205
## Total signifcant flu cases 1 out of 100 trials
## Smallest mean for significant difference 351
Now we will look at altering the standard deviation:
n = mean1
count = 0
smallest_stdev_size = 0
seq_5 <- seq(1, n, by = 5)
seq_10 <- seq(1, n, by = 10)
for (i in 1:length(seq_5)) {
flu_cases <- (rnorm(n,
mean = mean1,
sd = seq_5[i]))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
cat("\n","The standard deviation is ->", seq_5[i], "\n")
cat("The p-value is ->", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
if (i > 1 & count == 0) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
smallest_stdev_size = seq_5[i]
}
}
if (i > 1) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
count = count + 1
cat("There is a signifact difference between colder and warmer region flu cases at a stdev value of ", smallest_stdev_size, "with a p-value of ", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
}
}
cat("Total signifcant flu cases ", count, "out of ", i, "trials", "\n")
cat("Smallest standard deviation size for significant difference", smallest_stdev_size, "\n")
}
##
## The standard deviation is -> 1
## The p-value is -> 0.07228899
## Total signifcant flu cases 0 out of 1 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 6
## The p-value is -> 0.9806166
## Total signifcant flu cases 0 out of 2 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 11
## The p-value is -> 0.2216364
## Total signifcant flu cases 0 out of 3 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 16
## The p-value is -> 0.5157431
## Total signifcant flu cases 0 out of 4 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 21
## The p-value is -> 0.3383277
## Total signifcant flu cases 0 out of 5 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 26
## The p-value is -> 0.4261707
## Total signifcant flu cases 0 out of 6 trials
## Smallest standard deviation size for significant difference 0
count = 0
for (i in 1:length(seq_10)) {
flu_cases <- (rnorm(n,
mean = mean1,
sd = seq_10[i]))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
cat("\n","The standard deviation is ->", seq_10[i], "\n")
cat("The p-value is ->", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
if (i > 1 & count == 0) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
smallest_stdev_size = seq_10[i]
}
}
if (i > 1) {
if (flu_data_sum[[1]]$`Pr(>F)`[1] < 0.05) {
count = count + 1
cat("There is a signifact difference between colder and warmer region flu cases at a stdev value of ", seq_10[i], "with a p-value of ", flu_data_sum[[1]]$`Pr(>F)`[1], "\n")
}
}
cat("Total signifcant flu cases ", count, "out of ", i, "trials", "\n")
cat("Smallest standard deviation size for significant difference", smallest_stdev_size, "\n")
}
##
## The standard deviation is -> 1
## The p-value is -> 0.449475
## Total signifcant flu cases 0 out of 1 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 11
## The p-value is -> 0.5778109
## Total signifcant flu cases 0 out of 2 trials
## Smallest standard deviation size for significant difference 0
##
## The standard deviation is -> 21
## The p-value is -> 0.7692925
## Total signifcant flu cases 0 out of 3 trials
## Smallest standard deviation size for significant difference 0
Looking back at our original data, set up at the top, what is the smallest sample size I could do to get a significant value?
After numerous runs, the best I got was a sample size of 40, but this was due to random generation, you can see that we run it with 40 as the sample size, we might not repeat this result. Side note - this is why set.seed is helpful for sharing code/data so we can repeat results. In this example, we are working with random data every time
flu_cases <- (rnorm(40,
mean = mean1,
sd = stdev1))
flu_data <- data.frame(flu_cases)
flu_data$states <- sample(c(1,2), length(flu_cases), replace = TRUE)
flu_data$variance <- var(flu_cases)
flu_data_aov <- aov(flu_cases~states, data = flu_data)
flu_data_sum <- summary(flu_data_aov)
flu_data_sum
## Df Sum Sq Mean Sq F value Pr(>F)
## states 1 11.1 11.14 0.757 0.39
## Residuals 38 559.7 14.73
We can see all in all that through manipulation of mean and sample size, we notice about 5-15% of the runs will result in a significant difference of flu cases between warmer and colder regions. Switching standard deviation gives us about 0-33% of the runs result in significant difference.