#Libraries and functions
library(truncnorm)
library(dplyr)
library(ggplot2)
source("Homework9.R")

Question #1

#Collecting parameters
f1 <- Data_Parameters(my_data =ALW_CPUE_basin)

#Creating fake data using real parameters
f2 <- Fake_Data(nMean = f1$mean, nSD = f1$sd, nSize = f1$count)

#Running ANOVA and creaing box plot of fake data
f3 <- ANO_model_figure(modelCPUE = f2$modelCPUE, ANOdata = f2, TGroup = f2$TGroup)
##              Df  Sum Sq Mean Sq F value  Pr(>F)   
## TGroup        2  140974   70487   5.406 0.00488 **
## Residuals   342 4459308   13039                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Question #2

#Re-ordering North, Central, South Main Lake on boxplot
f4 <- Fake_Data_ordered(nMean = f1$mean, nSD = f1$sd, nSize = f1$count)

#Adding Tukey test to statistical analyses
f5 <-ANO_model_figure_PlusTukey(modelCPUE = f4$modelCPUE, ANOdata = f4, TGroup = f4$TGroup)
##              Df  Sum Sq Mean Sq F value   Pr(>F)    
## TGroup        2  296917  148458    12.2 7.62e-06 ***
## Residuals   342 4161586   12168                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = modelCPUE ~ TGroup, data = ANOdata)
## 
## $TGroup
##                                        diff        lwr       upr     p adj
## Central Main Lake-North Main Lake  13.50162  -21.79398  48.79722 0.6403810
## South Main Lake-North Main Lake   -75.44462 -114.62673 -36.26251 0.0000240
## South Main Lake-Central Main Lake -88.94624 -135.44810 -42.44438 0.0000274