Using the class’ Ciliate population data, produce a scatterplot of population (y-axis) vs. week (x-axis) (do not alter the color of the points based on the ciliate species - leave them grouped together for this activity). Describe the direction (positive or negative), strength (weak, moderate, strong) and type (linear, quadratic, log, exponential, etc.) of the relationship you observe between population age and population size. Hint: You may need to change the data frame format and tell Program R to treat your week variable as numeric.
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.2
## Warning: package 'readr' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readr)
library(dslabs)
## Warning: package 'dslabs' was built under R version 4.3.2
library(ggplot2)
cilliate_00 <- read_csv("C:/Users/Cupid/Downloads/cilliate 00.csv")
## Rows: 40 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): species
## dbl (2): Week, Number_of_Bacterium
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cilliate_00 %>% ggplot(aes(x=Week, y=Number_of_Bacterium)) +
geom_point() +
labs(x="Week", y="Number of Bacterium") +
theme_classic()
Answer: It is a positive correlation which looks weak due to a little curvature. It’s linear as well. ***
Determine the correlation between population age and population size and interpret this number.
cilliate_00 %>% with(cor.test(Number_of_Bacterium, Week))
##
## Pearson's product-moment correlation
##
## data: Number_of_Bacterium and Week
## t = 7.2503, df = 38, p-value = 1.131e-08
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.5904760 0.8674857
## sample estimates:
## cor
## 0.7618514
Answer: This correlation is significant and are strongly correlated with each other because the “cor” is between .7 and 1. ***
Fit a simple linear regression model to the population age (x) and population size (y) data. Provide the equation of the least squares regression line predicting population age and population size using good statistical notation.
summary(cilliate_00)
## species Week Number_of_Bacterium
## Length:40 Min. :1 Min. : 0.0000
## Class :character 1st Qu.:2 1st Qu.: 0.9142
## Mode :character Median :3 Median : 2.5985
## Mean :3 Mean : 6.0213
## 3rd Qu.:4 3rd Qu.: 9.0275
## Max. :5 Max. :29.3300
lm(Number_of_Bacterium~Week, data=cilliate_00) %>% summary()
##
## Call:
## lm(formula = Number_of_Bacterium ~ Week, data = cilliate_00)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.9584 -3.3631 -0.2849 2.0358 15.2516
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.0643 1.8429 -3.291 0.00216 **
## Week 4.0286 0.5556 7.250 1.13e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.97 on 38 degrees of freedom
## Multiple R-squared: 0.5804, Adjusted R-squared: 0.5694
## F-statistic: 52.57 on 1 and 38 DF, p-value: 1.131e-08
Answer: y = 4.0286x - 6.0643 ***
Interpret the slope and intercept of your least squares regression line from question #3.
Answer: The slope is the point in which the data’s average growth is best represented. As for the negative y-intercept, it is due to a loss of bacteria at the starting point. ***
Is there a statistically significant linear association between population age and population size? Explain, citing an appropriate test statistic and p-value from your analysis to support your answer.
Answer: It definitely is linear and it can be supported through an interpretation of the slope. It is a positive correlation with bacteria growth corresponding with an increase in growth period. The small “1.131e-08” p-value is more than enough proven to be statistically significant. ***
Use the least-squares regression equation to predict the population size at 3 weeks. Show your work.
Answer: Considering the one bacteria is growing continuously according to the data and the other hit a max, the population sized should still be linear if we take our y = 4.0286x - 6.0643 equation and place any length of time for “x”. ***
Use the least-squares regression equation to predict the population size at 10 weeks. What are you assuming about the relationship between population age and population size when using the least-squares regression line to extrapolate to this population size?
Answer: According to my equation it should be continuous if we place 10 in for x but of course there is a cap from a limited resource and space competition, so clearly the equation isn’t perfect but if gives a good representation on how quickly the population can grow considering if they did have access to unlimited resources and space. ***
Make a publication quality figure of your lab 2 data (PVC in two locations), with figure caption.
library(readr)
Lab222 <- read_csv("C:/Users/Cupid/Downloads/Lab222.csv")
## Rows: 48 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Area
## dbl (1): Veg_Cover
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(Lab222)
Lab222 %>% ggplot(aes(x=Area, y=Veg_Cover)) +
geom_boxplot() + theme_classic() + labs(x= "Area", y= "Veg_Cover")
This figure shows the variation of percent coverage in Riparian and grassland environments. The larger error bar in the Riparian community represents a larger variation in percent coverage. ***
Perform an appropriate statistical test on your lab 2 data (PVC in two locations) and write a properly formatted results statement.
t.test(Veg_Cover~Area, data=Lab222)
##
## Welch Two Sample t-test
##
## data: Veg_Cover by Area
## t = -4.2149, df = 42.57, p-value = 0.0001275
## alternative hypothesis: true difference in means between group Grassland and group Riparian is not equal to 0
## 95 percent confidence interval:
## -50.02622 -17.64045
## sample estimates:
## mean in group Grassland mean in group Riparian
## 35.62500 69.45833
Results Statement: There is a significant relation between location and vegetation percent due to p-value being below .05. ***
Make a publication quality figure of your lab 4 data (H_Prime in two locations), with figure caption.
Lab444 <- read_csv("C:/Users/Cupid/Downloads/Lab444.csv")
## Rows: 42 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Area
## dbl (1): Shannon
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(Lab444)
Lab444 %>% ggplot(aes(x=Area, y=Shannon)) +
geom_boxplot() + theme_classic() + labs(x= "Area", y= "Shannon")
This graph represents the Shannon Index for both the Creek area and the Rocky area. The error bars are placed to show possible error for the data with a give or take depending on the data apart from mean. ***
Perform an appropriate statistical test on your lab 4 data (H_Prime in two locations) and write a properly formatted results statement.
t.test(Shannon~Area, data=Lab444)
##
## Welch Two Sample t-test
##
## data: Shannon by Area
## t = -0.65562, df = 37.813, p-value = 0.516
## alternative hypothesis: true difference in means between group Creek and group Rocky is not equal to 0
## 95 percent confidence interval:
## -0.2073839 0.1059305
## sample estimates:
## mean in group Creek mean in group Rocky
## 1.258297 1.309024
Results Statement: There is not a small enough p-value to reject the null so our data was either inadequate or there just was not much difference in the Shannon index to place a correct difference. ***