Bambi <- read.table(file = "clipboard",
sep = "\t", header = TRUE)
str(Bambi)
## 'data.frame': 8 obs. of 4 variables:
## $ X1: num 2.9 2.4 2 2.3 3.2 ...
## $ X2: num 9.2 8.7 7.2 8.5 9.6 ...
## $ X3: num 13.2 11.5 10.8 12.3 12.6 ...
## $ X4: int 2 3 4 2 3 5 1 3
columns <- c("No_of_fawn", "adult_population","annual_precipitation", "winter_condition")
colnames(Bambi) <- columns
library(ggplot2)
library(cowplot)
##
## ********************************************************
## Note: As of version 1.0.0, cowplot does not change the
## default ggplot2 theme anymore. To recover the previous
## behavior, execute:
## theme_set(theme_cowplot())
## ********************************************************
Pop <- ggplot(Bambi, aes(x=adult_population, y=No_of_fawn)) + geom_point() + theme_classic()
Rain <- ggplot(Bambi, aes(x=annual_precipitation, y=No_of_fawn)) +
geom_point() + theme_classic()
Winter <- ggplot(Bambi, aes(x=winter_condition, y=No_of_fawn)) +
geom_point() + theme_classic()
plot_grid(Pop,Rain,Winter, nrow = 1, ncol = 3, labels = "AUTO")

modelOne <- lm(formula = No_of_fawn~ winter_condition, data = Bambi)
VizOne <-plot(Bambi$winter_condition,Bambi$No_of_fawn,
main = "Fawn Birth/Response to Winter Condition",
xlab = 'Winter Intesity', ylab = 'Expected Births')
abline(lm(No_of_fawn~winter_condition, data = Bambi), col = 'red')

summary(modelOne)
##
## Call:
## lm(formula = No_of_fawn ~ winter_condition, data = Bambi)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.52069 -0.20431 -0.00172 0.13017 0.71724
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.4966 0.3904 8.957 0.000108 ***
## winter_condition -0.3379 0.1258 -2.686 0.036263 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.415 on 6 degrees of freedom
## Multiple R-squared: 0.5459, Adjusted R-squared: 0.4702
## F-statistic: 7.213 on 1 and 6 DF, p-value: 0.03626
modelTwo <- lm(formula = No_of_fawn ~ adult_population + winter_condition,
data = Bambi)
plot(modelTwo)




summary(modelTwo)
##
## Call:
## lm(formula = No_of_fawn ~ adult_population + winter_condition,
## data = Bambi)
##
## Residuals:
## 1 2 3 4 5 6 7 8
## 0.01231 -0.27531 0.10301 -0.19154 0.01535 0.15880 0.29992 -0.12256
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.46009 1.53443 -1.603 0.1698
## adult_population 0.56594 0.14439 3.920 0.0112 *
## winter_condition 0.07058 0.12461 0.566 0.5956
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2252 on 5 degrees of freedom
## Multiple R-squared: 0.8885, Adjusted R-squared: 0.8439
## F-statistic: 19.92 on 2 and 5 DF, p-value: 0.004152
modelThree <- lm(formula = No_of_fawn~ adult_population +
winter_condition + annual_precipitation, data = Bambi)
plot(modelThree)




summary(modelThree)
##
## Call:
## lm(formula = No_of_fawn ~ adult_population + winter_condition +
## annual_precipitation, data = Bambi)
##
## Residuals:
## 1 2 3 4 5 6 7 8
## -0.11533 -0.02661 0.09882 -0.11723 0.02734 -0.04854 0.11715 0.06441
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.92201 1.25562 -4.716 0.0092 **
## adult_population 0.33822 0.09947 3.400 0.0273 *
## winter_condition 0.26295 0.08514 3.089 0.0366 *
## annual_precipitation 0.40150 0.10990 3.653 0.0217 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1209 on 4 degrees of freedom
## Multiple R-squared: 0.9743, Adjusted R-squared: 0.955
## F-statistic: 50.52 on 3 and 4 DF, p-value: 0.001229
#All the models work well, but I prefer the simplicity of model one.
#I would then run all the variables independently against $No_of_fawn
#to see which variables would hod value in running in conjuntion.
#A high R^2 value indicates a statistical signifigance between independent and
# dependent variables. All three models indicate significant R^2 value > 50%.
#Since Model Three has the highest R^2 value, it works best.
#The pasimonious model:
BICONE<-BIC(modelOne)
print(BICONE)
## [1] 12.56635
BICTWO <-BIC(modelTwo)
print(BICTWO)
## [1] 3.411571
BICTHREE <- BIC(modelThree)
print(BICTHREE)
## [1] -6.245971
#modelThree is the most parsimonious