Skip to content

Commit

Permalink
fix broken shiny links
Browse files Browse the repository at this point in the history
  • Loading branch information
dalejbarr committed Nov 29, 2023
1 parent beaef48 commit 2b9c7d8
Show file tree
Hide file tree
Showing 60 changed files with 629 additions and 599 deletions.
2 changes: 1 addition & 1 deletion 05-linear-mixed-effects-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -749,5 +749,5 @@ ggplot(sleep2, aes(x = days_deprived, y = Reaction)) +

## Multi-level app

[Try out the multi-level web app](https://shiny.psy.gla.ac.uk/Dale/multilevel){target="_blank"} to sharpen your understanding of the three different approaches to multi-level modeling.
[Try out the multi-level web app](https://rstudio-connect.psy.gla.ac.uk/multilevel){target="_blank"} to sharpen your understanding of the three different approaches to multi-level modeling.

2 changes: 1 addition & 1 deletion 06-linear-mixed-effects-one.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ One of the main selling points of the general linear models / regression framewo

Let's consider a situation where you are testing the effect of alcohol consumption on simple reaction time (e.g., press a button as fast as you can after a light appears). To keep it simple, let's assume that you have collected data from 14 participants randomly assigned to perform a set of 10 simple RT trials after one of two interventions: drinking a pint of alcohol (treatment condition) or a placebo drink (placebo condition). You have 7 participants in each of the two groups. Note that you would need more than this for a real study.

This [web app](https://shiny.psy.gla.ac.uk/Dale/icc){target="_blank"} presents simulated data from such a study. Subjects P01-P07 are from the placebo condition, while subjects T01-T07 are from the treatment condition. Please stop and have a look!
This [web app](https://rstudio-connect.psy.gla.ac.uk/icc){target="_blank"} presents simulated data from such a study. Subjects P01-P07 are from the placebo condition, while subjects T01-T07 are from the treatment condition. Please stop and have a look!

If we were going to run a t-test on these data, we would first need to calculate subject means, because otherwise the observations are not independent. You could do this as follows. (If you want to run the code below, you can download sample data from the web app above and save it as `independent_samples.csv`).

Expand Down
2 changes: 1 addition & 1 deletion 07-crossed-random-factors.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ For more technical details about convergence problems and what to do, see `?lme4

## Simulating data with crossed random factors

For these exercises, we will generate simulated data corresponding to an experiment with a single, two-level factor (independent variable) that is within-subjects and between-items. Let's imagine that the experiment involves lexical decisions to a set of words (e.g., is "PINT" a word or nonword?), and the dependent variable is response time (in milliseconds), and the independent variable is word type (noun vs verb). We want to treat both subjects and words as random factors (so that we can generalize to the population of events where subjects encounter words). You can play around with the web app (or [click here to open it in a new window](https://shiny.psy.gla.ac.uk/Dale/crossed){target="_blank"}), which allows you to manipulate the data-generating parameters and see their effect on the data.
For these exercises, we will generate simulated data corresponding to an experiment with a single, two-level factor (independent variable) that is within-subjects and between-items. Let's imagine that the experiment involves lexical decisions to a set of words (e.g., is "PINT" a word or nonword?), and the dependent variable is response time (in milliseconds), and the independent variable is word type (noun vs verb). We want to treat both subjects and words as random factors (so that we can generalize to the population of events where subjects encounter words). You can play around with the web app (or [click here to open it in a new window](https://rstudio-connect.psy.gla.ac.uk/crossed){target="_blank"}), which allows you to manipulate the data-generating parameters and see their effect on the data.

By now, you should have all the pieces of the puzzle that you need to simulate data from a study with crossed random effects. @Debruine_Barr_2020 provides a more detailed, step-by-step walkthrough of the exercise below.

Expand Down
4 changes: 2 additions & 2 deletions 08-generalized-linear-models.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ $$np(1 - p).$$

The app below allows you to manipulate the intercept and slope of a line in log odds space and to see the projection of the line back into response space. Note the S-shaped ("sigmoidal") shape of the function in the response shape.

```{r logit-app, echo=FALSE, fig.cap="**Logistic regression web app** <https://shiny.psy.gla.ac.uk/Dale/logit>"}
knitr::include_app("https://shiny.psy.gla.ac.uk/Dale/logit", "800px")
```{r logit-app, echo=FALSE, fig.cap="**Logistic regression web app** <https://rstudio-connect.psy.gla.ac.uk/logit>"}
knitr::include_app("https://rstudio-connect.psy.gla.ac.uk/logit", "800px")
```

### Estimating logistic regression models in R
Expand Down
Binary file modified docs/01-introduction_files/figure-html/basic-glm-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/01-introduction_files/figure-html/tryptych-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 26 additions & 26 deletions docs/02-correlation-regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ starwars %>%
```

```
##
## Correlation method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
## Correlation computed with
## • Method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
```

```
## # A tibble: 3 × 4
## term height mass birth_year
## <chr> <dbl> <dbl> <dbl>
## 1 height NA 0.134 -0.400
## 2 mass 0.134 NA 0.478
## 3 birth_year -0.400 0.478 NA
## 1 height NA 0.131 -0.404
## 2 mass 0.131 NA 0.478
## 3 birth_year -0.404 0.478 NA
```

You can look up any bivariate correlation at the intersection of any given row or column. So the correlation between `height` and `mass` is .134, which you can find in row 1, column 2 or row 2, column 1; the values are the same. Note that there are only `choose(3, 2)` = 3 unique bivariate relationships, but each appears twice in the table. We might want to show only the unique pairs. We can do this by appending `corrr::shave()` to our pipeline.
Expand All @@ -69,18 +69,18 @@ starwars %>%
```

```
##
## Correlation method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
## Correlation computed with
## • Method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
```

```
## # A tibble: 3 × 4
## term height mass birth_year
## <chr> <dbl> <dbl> <dbl>
## 1 height NA NA NA
## 2 mass 0.134 NA NA
## 3 birth_year -0.400 0.478 NA
## 2 mass 0.131 NA NA
## 3 birth_year -0.404 0.478 NA
```

Now we've only got the lower triangle of the correlation matrix, but the `NA` values are ugly and so are the leading zeroes. The **`corrr`** package also provides the `fashion()` function that cleans things up (see `?corrr::fashion` for more options).
Expand All @@ -95,9 +95,9 @@ starwars %>%
```

```
##
## Correlation method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
## Correlation computed with
## • Method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
```

```
Expand Down Expand Up @@ -193,16 +193,16 @@ starwars3 %>%
```

```
##
## Correlation method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
## Correlation computed with
## • Method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
```

```
## term height mass birth_year
## 1 height
## 2 mass .74
## 3 birth_year .45 .24
## 2 mass .73
## 3 birth_year .44 .24
```

Note that these values are quite different from the ones we started with.
Expand All @@ -219,16 +219,16 @@ starwars %>%
```

```
##
## Correlation method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
## Correlation computed with
## • Method: 'spearman'
## Missing treated using: 'pairwise.complete.obs'
```

```
## term height mass birth_year
## 1 height
## 2 mass .75
## 3 birth_year .16 .15
## 2 mass .72
## 3 birth_year .15 .15
```

Incidentally, if you are generating a report from R Markdown and want your tables to be nicely formatted you can use `knitr::kable()`.
Expand Down Expand Up @@ -261,13 +261,13 @@ starwars %>%
</tr>
<tr>
<td style="text-align:left;"> mass </td>
<td style="text-align:left;"> .75 </td>
<td style="text-align:left;"> .72 </td>
<td style="text-align:left;"> </td>
<td style="text-align:left;"> </td>
</tr>
<tr>
<td style="text-align:left;"> birth_year </td>
<td style="text-align:left;"> .16 </td>
<td style="text-align:left;"> .15 </td>
<td style="text-align:left;"> .15 </td>
<td style="text-align:left;"> </td>
</tr>
Expand Down
Binary file modified docs/02-correlation-regression_files/figure-html/bye-yoda-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/02-correlation-regression_files/figure-html/handw-log-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/02-correlation-regression_files/figure-html/pairs-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b9c7d8

Please sign in to comment.