Lesson 4 part

This commit is contained in:
Dusty.P 2018-04-30 23:03:13 -08:00
parent 99092a5dc4
commit 87034894c2

View File

@ -150,7 +150,7 @@ Notes:
Notes: Notes:
```{r Correlation} ```{r Correlation}
cor.test(pf$age, pf$friend_count)
``` ```
Look up the documentation for the cor.test function. Look up the documentation for the cor.test function.
@ -158,13 +158,13 @@ Look up the documentation for the cor.test function.
What's the correlation between age and friend count? Round to three decimal places. What's the correlation between age and friend count? Round to three decimal places.
Response: Response:
*** -0.027
### Correlation on Subsets ### Correlation on Subsets
Notes: Notes:
```{r Correlation on Subsets} ```{r Correlation on Subsets}
with( , cor.test(age, friend_count)) with(pf[pf$age <= 70,], cor.test(age, friend_count))
``` ```
*** ***
@ -172,13 +172,17 @@ with( , cor.test(age, friend_count))
### Correlation Methods ### Correlation Methods
Notes: Notes:
*** http://www.statisticssolutions.com/correlation-pearson-kendall-spearman/
## Create Scatterplots ## Create Scatterplots
Notes: Notes:
```{r} ```{r}
library(ggplot2)
ggplot(aes(x = www_likes_received, y = likes_received), data = pf) +
geom_point()#alpha = 1/20, position = position_jitter(h = 0)) +
#xlim(13, 90) +
#coord_trans(y = "sqrt")
``` ```
*** ***
@ -187,23 +191,28 @@ Notes:
Notes: Notes:
```{r Strong Correlations} ```{r Strong Correlations}
ggplot(aes(x = www_likes_received, y = likes_received), data = pf) +
geom_point() +
xlim(0, quantile(pf$www_likes_received, 0.95)) +
ylim(0, quantile(pf$likes_received, 0.95)) +
geom_smooth(method = 'lm', color = 'red')
``` ```
What's the correlation betwen the two variables? Include the top 5% of values for the variable in the calculation and round to 3 decimal places. What's the correlation betwen the two variables? Include the top 5% of values for the variable in the calculation and round to 3 decimal places.
```{r Correlation Calcuation} ```{r Correlation Calcuation}
with(pf, cor.test(www_likes_received, likes_received))
``` ```
Response: Response:
*** 0.948
Variable is a superset of another
### Moira on Correlation ### Moira on Correlation
Notes: Notes:
*** Highly corelated can mean that variables are dependent on the same thing or are similar.
### More Caution with Correlation ### More Caution with Correlation
Notes: Notes: