Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VectorPosse committed Jan 21, 2025
1 parent d0c988c commit 1009173
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 65 deletions.
26 changes: 10 additions & 16 deletions 06-correlation-web.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ Please write up your answer here.

:::


*****

We are interested in the association between `race` and `involact`. If redlining plays a role in driving people toward FAIR plan policies, we would expect there to be a relationship between the racial composition of a ZIP code and the number of FAIR plan policies obtained in that ZIP code.
We are interested in the association between `race` and `involact`. If redlining plays a role in driving people toward FAIR plan policies, we would expect there to be a relationship between the racial composition of a ZIP code and the rate of FAIR plan policies obtained in that ZIP code.

##### Exercise 5(a) {-}

Expand Down Expand Up @@ -176,7 +175,7 @@ Create the same kind of graph as above, but for `involact`. (Again, go back and
::: {.answer}

```{r}
# Add code here to create a plot of race
# Add code here to create a plot of involact
```

:::
Expand Down Expand Up @@ -263,7 +262,7 @@ In between 0 and 1 (or -1), we often use words like weak, moderately weak, moder

A correlation is positive when low values of one variable are associated with low values of the other value. Similarly, high values of one variable are associated with high values of the other. For example, exercise is positively correlated with burning calories. Low exercise levels will burn a few calories; high exercise levels burn more calories, on average.

A correlation is negative when low values of one variable are associated with high values of the other value, and vice versa. For example, tooth brushing is negatively correlated with cavities. Less tooth brushing may result in more cavities; more tooth brushing is associated with fewer calories, on average.
A correlation is negative when low values of one variable are associated with high values of the other value, and vice versa. For example, tooth brushing is negatively correlated with cavities. Less tooth brushing may result in more cavities; more tooth brushing is associated with fewer cavities, on average.


## Conditions for correlation
Expand Down Expand Up @@ -320,12 +319,10 @@ Create a scatterplot of `income` against `race`. (Put `income` on the y-axis and

##### Exercise 8(b) {-}

Check the three conditions for the relationship between `income` and `race`. Which condition is pretty seriously violated here?
Check the three conditions for the relationship between `income` and `race`. Which condition(s) are seriously violated here?

::: {.answer}

Please write up your answer here.

1.
2.
3.
Expand All @@ -346,16 +343,14 @@ Create a scatterplot of `theft` against `fire`. (Put `theft` on the y-axis and `

##### Exercise 9(b) {-}

Check the three conditions for the relationship between `theft` and `fire`. Which condition is pretty seriously violated here?
Check the three conditions for the relationship between `theft` and `fire`. Which condition(s) are seriously violated here?

::: {.answer}

1.
2.
3.

Please write up your answer here.

:::

##### Exercise 9(c) {-}
Expand Down Expand Up @@ -387,13 +382,13 @@ The lesson learned here is that you should never try to interpret a correlation

When two variables are correlated---indeed, associated in any way, not just in a linear relationship---that means that there is a relationship between them. However, that does not mean that one variable *causes* the other variable.

For example, we discovered above that there was a moderate correlation between the racial composition of a ZIP code and the new FAIR policies created in those ZIP codes. However, being part of a racial minority does not cause someone to seek out alternative forms of insurance, at least not directly. In this case, the racial composition of certain neighborhoods, though racist policies, affected the availability of certain forms of insurance for residents in those neighborhoods. And that, in turn, caused residents to seek other forms of insurance.
For example, we discovered above that there was a moderate correlation between the racial composition of a ZIP code and the new FAIR policies created in those ZIP codes. However, being part of a racial minority does not cause someone to seek out alternative forms of insurance, at least not directly. In this case, the racial composition of certain neighborhoods, through racist policies, affected the availability of certain forms of insurance for residents in those neighborhoods. And that, in turn, caused residents to seek other forms of insurance.

In the Chicago example, there is still likely a causal connection between one variable (`race`) and the other (`involact`), but it is indirect. In other cases, there is no causal connection at all. Here are a few of my favorite examples.

##### Exercise 10 {-}

Ice cream sales are positively correlated with drowning deaths. Does eating ice cream cause you to drown? (Perhaps the myth about swimming within one hour of eating is really true!) Does drowning deaths cause ice cream sales to rise? (Perhaps people are so sad about all the drownings that they have to go out for ice cream to cheer themselves up?)
Ice cream sales are positively correlated with drowning deaths. Does eating ice cream cause you to drown? (Perhaps the myth about swimming within one hour of eating is really true!) Do drowning deaths cause ice cream sales to rise? (Perhaps people are so sad about all the drownings that they have to go out for ice cream to cheer themselves up?)

See if you can figure out the real reason why ice cream sales are positively correlated with drowning deaths.

Expand Down Expand Up @@ -513,9 +508,7 @@ ggplot(bdims, aes(y = sho_gi, x = che_gi)) +

Is there a possible lurking variable here, though? You may wonder about `sex`. (In this data set, the `sex` variable is presumed to be biological sex assigned at birth.)

Before we go any further, go back to the help file and the `glimpse` output above and note that `sex` is coded as an integer (a whole number).

We'll use the `mutate` and `as_factor` commands---illustrated in Chapters 3 and 5---to make a new factor variable.
Before we go any further, go back to the help file and the `glimpse` output above and note that `sex` is coded as an integer (a whole number). We'll use the `mutate` and `as_factor` commands---illustrated in Chapters 3 and 5---to make a new factor variable.

```{r}
bdims <- bdims |>
Expand Down Expand Up @@ -568,7 +561,7 @@ Please write up your answer here.

*****

In the previous example, sex was a lurking variable, but it did not radically alter the nature of the association. What about the examples in these next two exercises?
In the previous example, sex was a lurking variable, but it did not radically alter the nature of the association. What about the examples in these next two sets of exercises?

##### Exercise 15(a) {-}

Expand Down Expand Up @@ -701,6 +694,7 @@ There is not much correlation between bill depth and bill length, but if anythin
cor(penguins$bill_depth_mm, penguins$bill_length_mm,
use = "complete.obs")
```

Now split by species:

```{r}
Expand Down
26 changes: 10 additions & 16 deletions chapter_downloads/06-correlation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ Please write up your answer here.

:::


*****

We are interested in the association between `race` and `involact`. If redlining plays a role in driving people toward FAIR plan policies, we would expect there to be a relationship between the racial composition of a ZIP code and the number of FAIR plan policies obtained in that ZIP code.
We are interested in the association between `race` and `involact`. If redlining plays a role in driving people toward FAIR plan policies, we would expect there to be a relationship between the racial composition of a ZIP code and the rate ofFAIR plan policies obtained in that ZIP code.

##### Exercise 5(a)

Expand Down Expand Up @@ -186,7 +185,7 @@ Create the same kind of graph as above, but for `involact`. (Again, go back and
::: {.answer}

```{r}
# Add code here to create a plot of race
# Add code here to create a plot of involact
```

:::
Expand Down Expand Up @@ -273,7 +272,7 @@ In between 0 and 1 (or -1), we often use words like weak, moderately weak, moder

A correlation is positive when low values of one variable are associated with low values of the other value. Similarly, high values of one variable are associated with high values of the other. For example, exercise is positively correlated with burning calories. Low exercise levels will burn a few calories; high exercise levels burn more calories, on average.

A correlation is negative when low values of one variable are associated with high values of the other value, and vice versa. For example, tooth brushing is negatively correlated with cavities. Less tooth brushing may result in more cavities; more tooth brushing is associated with fewer calories, on average.
A correlation is negative when low values of one variable are associated with high values of the other value, and vice versa. For example, tooth brushing is negatively correlated with cavities. Less tooth brushing may result in more cavities; more tooth brushing is associated with fewer cavities, on average.


## Conditions for correlation
Expand Down Expand Up @@ -330,12 +329,10 @@ Create a scatterplot of `income` against `race`. (Put `income` on the y-axis and

##### Exercise 8(b)

Check the three conditions for the relationship between `income` and `race`. Which condition is pretty seriously violated here?
Check the three conditions for the relationship between `income` and `race`. Which condition(s) are seriously violated here?

::: {.answer}

Please write up your answer here.

1.
2.
3.
Expand All @@ -356,16 +353,14 @@ Create a scatterplot of `theft` against `fire`. (Put `theft` on the y-axis and `

##### Exercise 9(b)

Check the three conditions for the relationship between `theft` and `fire`. Which condition is pretty seriously violated here?
Check the three conditions for the relationship between `theft` and `fire`. Which condition(s) are seriously violated here?

::: {.answer}

1.
2.
3.

Please write up your answer here.

:::

##### Exercise 9(c)
Expand Down Expand Up @@ -397,13 +392,13 @@ The lesson learned here is that you should never try to interpret a correlation

When two variables are correlated---indeed, associated in any way, not just in a linear relationship---that means that there is a relationship between them. However, that does not mean that one variable *causes* the other variable.

For example, we discovered above that there was a moderate correlation between the racial composition of a ZIP code and the new FAIR policies created in those ZIP codes. However, being part of a racial minority does not cause someone to seek out alternative forms of insurance, at least not directly. In this case, the racial composition of certain neighborhoods, though racist policies, affected the availability of certain forms of insurance for residents in those neighborhoods. And that, in turn, caused residents to seek other forms of insurance.
For example, we discovered above that there was a moderate correlation between the racial composition of a ZIP code and the new FAIR policies created in those ZIP codes. However, being part of a racial minority does not cause someone to seek out alternative forms of insurance, at least not directly. In this case, the racial composition of certain neighborhoods, through racist policies, affected the availability of certain forms of insurance for residents in those neighborhoods. And that, in turn, caused residents to seek other forms of insurance.

In the Chicago example, there is still likely a causal connection between one variable (`race`) and the other (`involact`), but it is indirect. In other cases, there is no causal connection at all. Here are a few of my favorite examples.

##### Exercise 10

Ice cream sales are positively correlated with drowning deaths. Does eating ice cream cause you to drown? (Perhaps the myth about swimming within one hour of eating is really true!) Does drowning deaths cause ice cream sales to rise? (Perhaps people are so sad about all the drownings that they have to go out for ice cream to cheer themselves up?)
Ice cream sales are positively correlated with drowning deaths. Does eating ice cream cause you to drown? (Perhaps the myth about swimming within one hour of eating is really true!) Do drowning deaths cause ice cream sales to rise? (Perhaps people are so sad about all the drownings that they have to go out for ice cream to cheer themselves up?)

See if you can figure out the real reason why ice cream sales are positively correlated with drowning deaths.

Expand Down Expand Up @@ -523,9 +518,7 @@ ggplot(bdims, aes(y = sho_gi, x = che_gi)) +

Is there a possible lurking variable here, though? You may wonder about `sex`. (In this data set, the `sex` variable is presumed to be biological sex assigned at birth.)

Before we go any further, go back to the help file and the `glimpse` output above and note that `sex` is coded as an integer (a whole number).

We'll use the `mutate` and `as_factor` commands---illustrated in Chapters 3 and 5---to make a new factor variable.
Before we go any further, go back to the help file and the `glimpse` output above and note that `sex` is coded as an integer (a whole number). We'll use the `mutate` and `as_factor` commands---illustrated in Chapters 3 and 5---to make a new factor variable.

```{r}
bdims <- bdims |>
Expand Down Expand Up @@ -578,7 +571,7 @@ Please write up your answer here.

*****

In the previous example, sex was a lurking variable, but it did not radically alter the nature of the association. What about the examples in these next two exercises?
In the previous example, sex was a lurking variable, but it did not radically alter the nature of the association. What about the examples in these next two sets of exercises?

##### Exercise 15(a)

Expand Down Expand Up @@ -711,6 +704,7 @@ There is not much correlation between bill depth and bill length, but if anythin
cor(penguins$bill_depth_mm, penguins$bill_length_mm,
use = "complete.obs")
```

Now split by species:

```{r}
Expand Down
Loading

0 comments on commit 1009173

Please sign in to comment.