Skip to content

Commit

Permalink
update review lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
ccmothes committed Sep 30, 2024
1 parent dcfb25d commit 2abc027
Show file tree
Hide file tree
Showing 216 changed files with 408 additions and 179 deletions.
75 changes: 38 additions & 37 deletions 09-review.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ knitr::opts_chunk$set(echo=TRUE, eval=TRUE, message=FALSE, warning=FALSE, rows.p

In this lesson you will take all of the skills you have learned up to this point and use them on a completely new set of data.

#### Necessary packages:
#### Setup

::: {.alert .alert-info}
New packages for this lesson: `dataRetrieval`, `httr`, `jsonlite`

Add these to your 'setup.R' script if you want to follow along with the data retrieval part of this lesson (*optional*).
:::

```{r eval = FALSE}
source("setup.R")
```

```{r include=FALSE}
library(tidyverse)
Expand All @@ -18,21 +28,11 @@ library(sf) # for the map
library(mapview) # for making the interactive plot
```

```{r eval=FALSE}
library(tidyverse)
library(rstatix)
# new packages! Only if you want to work through the data retrieval process
library(httr)
library(jsonlite)
library(dataRetrieval)
```

## Tidying datasets

We are interested in looking at how the Cache la Poudre River's flow changes over time and space as it travels out of the mountainous Poudre Canyon and through Fort Collins.
We are interested in looking at how the Cache la Poudre River's flow changes over *time and space* as it travels out of the mountainous Poudre Canyon and through Fort Collins.

There are four stream flow monitoring sites on the Poudre that we are interested in: two managed by the US Geological Survey (USGS), and two managed by the Colorado Division of Water Resources (CDWR):
There are four stream flow monitoring sites along the Poudre that we are interested in: two managed by the US Geological Survey (USGS), and two managed by the Colorado Division of Water Resources (CDWR):

```{r echo = FALSE}
# Making a tibble to convert into coordinates for our sites
Expand Down Expand Up @@ -61,7 +61,7 @@ Using the `dataRetrieval` package we can pull all sorts of USGS water data. You
usgs <- dataRetrieval::readNWISdv(siteNumbers = c("06752260", "06752280"), # USGS site code for the Poudre River at the Lincoln Bridge and the ELC
parameterCd = "00060", # USGS code for stream flow
startDate = "2020-10-01", # YYYY-MM-DD formatting
endDate = "2023-10-01") %>% # YYYY-MM-DD formatting
endDate = "2024-09-30") %>% # YYYY-MM-DD formatting
rename(q_cfs = X_00060_00003) %>% # USGS code for stream flow units in cubic feet per second (CFS)
mutate(Date = lubridate::ymd(Date), # convert the Date column to "Date" formatting using the `lubridate` package
Site = case_when(site_no == "06752260" ~ "Lincoln",
Expand All @@ -74,22 +74,22 @@ usgs <- dataRetrieval::readNWISdv(siteNumbers = c("06752260", "06752280"), # USG

### Get CDWR stream flow data

Alas, CDWR doesn't have an R packge to easily pull data from their API like USGS does, but they do have user-friendly instructions about how to develop API calls.
Alas, CDWR doesn't have an R packge to easily pull data from their API like USGS does, but they do have user-friendly instructions about how to develop **API calls.**

**Don't stress if you have no clue what an API is**! We will learn a lot more about them in 523A, but this is good practice for our function writing and mapping skills.
**Don't stress if you have no clue what an API is**! We will learn a lot more about them in later lessons, but this is good practice for our function writing and mapping skills.

Using the ["URL Generator" steps outlined]((https://dwr.state.co.us/Rest/GET/Help/SurfaceWaterTSDayGenerator)), if we wanted data from 2020-2022 for the Canyon mouth side (site abbreviation = CLAFTCCO), it generates this URL to retrieve that data:
Using the ["URL Generator" steps outlined](https://dwr.state.co.us/Rest/GET/Help/SurfaceWaterTSDayGenerator), if we wanted data from 2020-2024 for the Canyon mouth site (site abbreviation = CLAFTCCO), it generates this URL to retrieve that data:

<https://dwr.state.co.us/Rest/GET/api/v2/surfacewater/surfacewatertsday/?format=json&dateFormat=dateOnly&fields=abbrev%2CmeasDate%2Cvalue%2CmeasUnit&encoding=deflate&abbrev=CLAFTCCO&min-measDate=10%2F01%2F2020&max-measDate=09%2F30%2F2022>
<https://dwr.state.co.us/Rest/GET/api/v2/surfacewater/surfacewatertsday/?dateFormat=dateOnly&fields=abbrev%2CmeasDate%2Cvalue%2CmeasUnit&abbrev=CLAFTCCO&min-measDate=10%2F01%2F2020&max-measDate=09%2F30%2F2024>

However, we want to pull this data for two different sites, and may want to change the year range of data. Therefore, we can write a function to pull data for our various sites and time frames:
However, we want to pull this data for two different sites, and may want to change the year range of data. Therefore, writing a custom function to pull data for our various sites and time frames would be useful:

```{r eval=FALSE}
# Functin to retrieve data
co_water_data <- function(site, start_year, end_year){
# Function to retrieve data
pull_cdwr <- function(site, start_year, end_year){
raw_data <- httr::GET(url = paste0("https://dwr.state.co.us/Rest/GET/api/v2/surfacewater/surfacewatertsday/?format=json&dateFormat=dateOnly&fields=abbrev%2CmeasDate%2Cvalue%2CmeasUnit&encoding=deflate&abbrev=",site,
raw_data <- httr::GET(url = paste0("https://dwr.state.co.us/Rest/GET/api/v2/surfacewater/surfacewatertsday/?dateFormat=dateOnly&fields=abbrev%2CmeasDate%2Cvalue%2CmeasUnit&abbrev=",site,
"&min-measDate=10%2F01%2F", start_year,
"&max-measDate=09%2F30%2F", end_year))
Expand All @@ -113,15 +113,15 @@ Now, lets use that function to pull data for our two CDWR sites of interest, whi
sites <- c("CLAFTCCO","CLARIVCO")
cdwr <- sites %>%
map_dfr(~ co_water_data(site = .x, start_year = 2020, end_year = 2023))
map_dfr(~ pull_cdwr(site = .x, start_year = 2020, end_year = 2024))
# If you want to save this file
#write_csv(cdwr, 'data/review-cdwr.csv')
```

### OR, read in the .csv's we already generated and saved for you:

Read in our two data sets. You will find that they provide the same information (daily streamflow from 2020-2022) but their variable names and structures are different:
Read in our two data sets. You will find that they provide the same information (daily streamflow from 2020-2024) but their variable names and structures are different:

```{r}
usgs <- read_csv('data/review-usgs.csv')
Expand All @@ -130,7 +130,7 @@ cdwr <- read_csv('data/review-cdwr.csv')
```

When we look at these two datasets, we see they provide the same information (daily streamflow from 2020-2023) but their variable names and structures are different:
When we look at these two datasets, we see they provide the same information (daily streamflow from 2020-2024) but their variable names and structures are different:

```{r}
glimpse(usgs)
Expand All @@ -148,7 +148,7 @@ cdwr_clean <- cdwr %>%
rename(q_cfs = value) %>%
# Add site and agency vars
mutate(Date = lubridate::ymd(measDate),
Site = ifelse(abbrev == "CLAFTCCO", "Canyon",
Site = if_else(abbrev == "CLAFTCCO", "Canyon",
"Timnath"),
agency_cd = "CDWR")
```
Expand Down Expand Up @@ -198,18 +198,19 @@ Let's look at the daily difference in discharge between the mouth of the Cache l
dif_data <- data %>%
# select vars of interest
select(Site, Date, q_cfs) %>%
# create a column of streamflow values for each site
# pivot wider so each site is its own column
pivot_wider(names_from = Site, values_from = q_cfs) %>%
# for each downstream site, create a new column that is the difference from the Canyon mouth site
mutate_at(c("Boxelder", "Lincoln", "Timnath"), .funs = ~ (Canyon - .)) %>%
# if you wanted to create new variables use this instead:
#mutate_at(c("Boxelder", "Lincoln", "Timnath"), .funs = list(dif = ~ (Canyon - .))) %>%
mutate_at(c("Boxelder", "Lincoln", "Timnath"), .funs = list(dif = ~ (Canyon - .))) %>%
# then pivot these new columns (i.e., NOT the date and canyon columns) longer again
pivot_longer(-c(Canyon, Date))
pivot_longer(-c(Canyon, Date)) %>%
# keep just the 'dif' values
filter(str_detect(name, "_dif"))
dif_data %>%
mutate(name = fct(name, levels = c("Lincoln", "Boxelder", "Timnath"))) %>%
# factor the site variable in order from distance to the canyon mouth for plotting purposes
mutate(name = fct(name, levels = c("Lincoln_dif", "Boxelder_dif", "Timnath_dif"))) %>%
ggplot() +
geom_line(aes(x = Date, y = value, color = name)) +
theme_bw() +
Expand Down Expand Up @@ -241,7 +242,7 @@ data %>%
shapiro_test(q_cfs)
```

Since the null hypothesis of the Shapiro-Wilk test is that the data is normally distributed, these results tell us all groups do not fit a normal distribution for daily stream flow. It is also quite clear from their histograms that they are not normally distributed.
Since the null hypothesis of the Shapiro-Wilk test is that the data **is** normally distributed, these results tell us all groups do not fit a normal distribution for daily stream flow. It is also quite clear from their histograms that they are not normally distributed.

### Testing for equal variance

Expand All @@ -252,7 +253,7 @@ data %>%
levene_test(q_cfs ~ Site)
```

Given this small p-value, we see that the variances of our groups are not equal.
Given this small p-value, we see that the variances of our groups are *not* equal.

### ANOVA - Kruskal-Wallis

Expand All @@ -263,18 +264,18 @@ data %>%
kruskal_test(q_cfs ~ Site)
```

Our results here are highly significant (at alpha = 0.05), meaning that at least one of our group's mean stream flow is significantly different from the others.
Our results here are highly significant (extremely small p-value), meaning that at least one of our sites has a stream flow significantly different from the others.

### ANOVA post-hoc analysis

Since we used the non-parametric Kruskal-Wallace test, we can use the associated Dunn's test to test across our sites for significant differences in mean stream flow:

```{r}
data %>%
dunn_test(q_cfs ~ Site)
dunn_test(q_cfs ~ Site, detailed = TRUE)
```

The results of our Dunn test signify that all of our sites are significantly different from eachother mean streamflow across our sites are significantly different.
The results of our Dunn test signify that *all* of our sites are significantly different from each other in terms of mean streamflow.

THOUGHT EXPERIMENT 1: Based on our results, which of our two gages have the greatest difference in mean daily stream flow?

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file added _main_files/figure-html/unnamed-chunk-103-1.png
Binary file added _main_files/figure-html/unnamed-chunk-105-1.png
Binary file added _main_files/figure-html/unnamed-chunk-115-1.png
Binary file added _main_files/figure-html/unnamed-chunk-116-1.png
Binary file added _main_files/figure-html/unnamed-chunk-123-1.png
Binary file added _main_files/figure-html/unnamed-chunk-127-1.png
Binary file added _main_files/figure-html/unnamed-chunk-128-1.png
Binary file added _main_files/figure-html/unnamed-chunk-144-1.png
Binary file added _main_files/figure-html/unnamed-chunk-148-1.png
Binary file added _main_files/figure-html/unnamed-chunk-162-1.png
Binary file added _main_files/figure-html/unnamed-chunk-163-1.png
Binary file added _main_files/figure-html/unnamed-chunk-183-1.png
Binary file added _main_files/figure-html/unnamed-chunk-184-1.png
Binary file added _main_files/figure-html/unnamed-chunk-185-1.png
Binary file added _main_files/figure-html/unnamed-chunk-186-1.png
Binary file added _main_files/figure-html/unnamed-chunk-3-1.png
Binary file added _main_files/figure-html/unnamed-chunk-4-2.png
Binary file added _main_files/figure-html/unnamed-chunk-57-1.png
Binary file added _main_files/figure-html/unnamed-chunk-58-1.png
Binary file added _main_files/figure-html/unnamed-chunk-59-1.png
Binary file added _main_files/figure-html/unnamed-chunk-60-1.png
Binary file added _main_files/figure-html/unnamed-chunk-61-1.png
Binary file added _main_files/figure-html/unnamed-chunk-62-1.png
Binary file added _main_files/figure-html/unnamed-chunk-67-1.png
Binary file added _main_files/figure-html/unnamed-chunk-68-1.png
Binary file added _main_files/figure-html/unnamed-chunk-69-1.png
Binary file added _main_files/figure-html/unnamed-chunk-7-2.png
Binary file added _main_files/figure-html/unnamed-chunk-70-1.png
Binary file added _main_files/figure-html/unnamed-chunk-71-1.png
Binary file added _main_files/figure-html/unnamed-chunk-72-1.png
Binary file added _main_files/figure-html/unnamed-chunk-73-1.png
Binary file added _main_files/figure-html/unnamed-chunk-74-1.png
Binary file added _main_files/figure-html/unnamed-chunk-75-1.png
Binary file added _main_files/figure-html/unnamed-chunk-76-1.png
Binary file added _main_files/figure-html/unnamed-chunk-79-1.png
Binary file added _main_files/figure-html/unnamed-chunk-80-1.png
Binary file added _main_files/figure-html/unnamed-chunk-81-1.png
Binary file added _main_files/figure-html/unnamed-chunk-84-1.png
Binary file added _main_files/figure-html/unnamed-chunk-85-1.png
Binary file added _main_files/figure-html/unnamed-chunk-86-1.png
Binary file added _main_files/figure-html/unnamed-chunk-87-1.png
Binary file added _main_files/figure-html/unnamed-chunk-88-1.png
Binary file added _main_files/figure-html/unnamed-chunk-89-1.png
Binary file added _main_files/figure-html/unnamed-chunk-90-1.png
Binary file added _main_files/figure-html/unnamed-chunk-93-1.png
13 changes: 9 additions & 4 deletions docs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Page not found | Introduction to Environmental Data Science</title>
<meta name="description" content="This site hosts the first half of the course content for ESS 523A at Colorado State University." />
<meta name="generator" content="bookdown 0.35 and GitBook 2.6.7" />
<meta name="generator" content="bookdown 0.40 and GitBook 2.6.7" />

<meta property="og:title" content="Page not found | Introduction to Environmental Data Science" />
<meta property="og:type" content="book" />
Expand All @@ -23,7 +23,7 @@
<meta name="author" content="Caitlin Mothes, PhD and Katie Willi" />


<meta name="date" content="2024-09-27" />
<meta name="date" content="2024-09-30" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down Expand Up @@ -52,6 +52,7 @@
<link href="libs/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.1.0/anchor-sections.js"></script>
<link href="libs/htmltools-fill-0.5.8.1/fill.css" rel="stylesheet" />
<script src="libs/htmlwidgets-1.6.4/htmlwidgets.js"></script>
<script src="libs/plotly-binding-4.10.4/plotly.js"></script>
<script src="libs/typedarray-0.1/typedarray.min.js"></script>
Expand All @@ -65,9 +66,13 @@
<script src="libs/proj4-2.6.2/proj4.min.js"></script>
<script src="libs/Proj4Leaflet-1.0.1/proj4leaflet.js"></script>
<link href="libs/rstudio_leaflet-1.3.1/rstudio_leaflet.css" rel="stylesheet" />
<script src="libs/leaflet-binding-2.2.1/leaflet.js"></script>
<script src="libs/leaflet-binding-2.2.2/leaflet.js"></script>
<script src="libs/leaflet-providers-2.0.0/leaflet-providers_2.0.0.js"></script>
<script src="libs/leaflet-providers-plugin-2.2.1/leaflet-providers-plugin.js"></script>
<script src="libs/leaflet-providers-plugin-2.2.2/leaflet-providers-plugin.js"></script>
<script src="libs/FlatGeoBuf-3.21.3/fgb.js"></script>
<script src="libs/FlatGeoBuf-3.21.3/flatgeobuf-geojson.min.js"></script>
<script src="libs/chromajs-2.1.0/chroma.min.js"></script>
<link id="Poudre_River_Monitoring-1-attachment" rel="attachment" href="libs/Poudre_River_Monitoring-0.0.1/Poudre_River_Monitoring_layer.fgb"/>
<link href="libs/HomeButton-0.0.1/home-button.css" rel="stylesheet" />
<script src="libs/HomeButton-0.0.1/home-button.js"></script>
<script src="libs/HomeButton-0.0.1/easy-button-src.min.js"></script>
Expand Down
Binary file modified docs/_main_files/figure-html/unnamed-chunk-103-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-105-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-115-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-116-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-122-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-123-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-123-2.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-127-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-127-2.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-128-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-144-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-148-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-162-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-163-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-183-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-184-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-185-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-186-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-57-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-58-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-59-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-60-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-61-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-62-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-67-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-68-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-69-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-70-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-71-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-72-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-73-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-74-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-75-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-76-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-79-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-80-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-81-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-84-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-85-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-86-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-87-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-88-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-89-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-90-1.png
Binary file modified docs/_main_files/figure-html/unnamed-chunk-93-1.png
17 changes: 11 additions & 6 deletions docs/correlation-and-simple-linear-regression.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title> 7 Correlation and Simple Linear Regression | Introduction to Environmental Data Science</title>
<meta name="description" content="This site hosts the first half of the course content for ESS 523A at Colorado State University." />
<meta name="generator" content="bookdown 0.35 and GitBook 2.6.7" />
<meta name="generator" content="bookdown 0.40 and GitBook 2.6.7" />

<meta property="og:title" content=" 7 Correlation and Simple Linear Regression | Introduction to Environmental Data Science" />
<meta property="og:type" content="book" />
Expand All @@ -23,7 +23,7 @@
<meta name="author" content="Caitlin Mothes, PhD and Katie Willi" />


<meta name="date" content="2024-09-27" />
<meta name="date" content="2024-09-30" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down Expand Up @@ -52,6 +52,7 @@
<link href="libs/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.1.0/anchor-sections.js"></script>
<link href="libs/htmltools-fill-0.5.8.1/fill.css" rel="stylesheet" />
<script src="libs/htmlwidgets-1.6.4/htmlwidgets.js"></script>
<script src="libs/plotly-binding-4.10.4/plotly.js"></script>
<script src="libs/typedarray-0.1/typedarray.min.js"></script>
Expand All @@ -65,9 +66,13 @@
<script src="libs/proj4-2.6.2/proj4.min.js"></script>
<script src="libs/Proj4Leaflet-1.0.1/proj4leaflet.js"></script>
<link href="libs/rstudio_leaflet-1.3.1/rstudio_leaflet.css" rel="stylesheet" />
<script src="libs/leaflet-binding-2.2.1/leaflet.js"></script>
<script src="libs/leaflet-binding-2.2.2/leaflet.js"></script>
<script src="libs/leaflet-providers-2.0.0/leaflet-providers_2.0.0.js"></script>
<script src="libs/leaflet-providers-plugin-2.2.1/leaflet-providers-plugin.js"></script>
<script src="libs/leaflet-providers-plugin-2.2.2/leaflet-providers-plugin.js"></script>
<script src="libs/FlatGeoBuf-3.21.3/fgb.js"></script>
<script src="libs/FlatGeoBuf-3.21.3/flatgeobuf-geojson.min.js"></script>
<script src="libs/chromajs-2.1.0/chroma.min.js"></script>
<link id="Poudre_River_Monitoring-1-attachment" rel="attachment" href="libs/Poudre_River_Monitoring-0.0.1/Poudre_River_Monitoring_layer.fgb"/>
<link href="libs/HomeButton-0.0.1/home-button.css" rel="stylesheet" />
<script src="libs/HomeButton-0.0.1/home-button.js"></script>
<script src="libs/HomeButton-0.0.1/easy-button-src.min.js"></script>
Expand Down Expand Up @@ -342,13 +347,13 @@ <h5><span class="header-section-number">7.1.0.1.1</span> Parametric vs. non-par
## Shapiro-Wilk normality test
##
## data: sal_sub$length_2_mm
## W = 0.93584, p-value &lt; 2.2e-16</code></pre>
## W = 0.93321, p-value &lt; 2.2e-16</code></pre>
<div class="sourceCode" id="cb151"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb151-1"><a href="correlation-and-simple-linear-regression.html#cb151-1" tabindex="-1"></a><span class="fu">shapiro.test</span>(sal_sub<span class="sc">$</span>weight_g)</span></code></pre></div>
<pre><code>##
## Shapiro-Wilk normality test
##
## data: sal_sub$weight_g
## W = 0.5666, p-value &lt; 2.2e-16</code></pre>
## W = 0.5602, p-value &lt; 2.2e-16</code></pre>
<p>The <strong>null hypothesis of the Shapiro-Wilk normality test is that the variable is normally distributed</strong>, so a p-value less than 0.05, at 95% confidence (as we see for both of our variables here) tells use that <em>our data does not fit a normal distribution</em>.</p>
<p>Therefore we have two options as we did with our t-test example in the previous lesson: transform the variables and see if that helps, or use a non-parametric test. Here, we will go ahead with the non-parametric Spearman correlation test.</p>
<div class="alert alert-info">
Expand Down
Loading

0 comments on commit 2abc027

Please sign in to comment.