Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typos fixed in RM2 chapters #87

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions book/00-foreword.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Foreword {-}

<div class="small_right"><img src="images/logos/logo-quant-fun.png"
alt="ADS Hex Logo" /></div>

### Welcome to the Fundamentals of Quantitative Analysis {-}

This book has been written and designed to help you learn core data skills through R and RStudio. These skills will lead to you being able to manipulate and analyse quantitative data - a key component of any accredited Psychology programme. In addition to this book the team will support you with helpful skills demonstration videos, and we would encourage you to use Teams to ask any questions that you have.

The ability to work with quantitative data is a key skill for Psychologists and by using R as our tool, for working with data, we can also promote reproducible research practices. Although at first it may seem like writing a programming script is more time-consuming than other point-and-click approaches, this is not the case! Once you have written a script that does what you need it to do, you can easily re-run your analysis without having to go through each step again manually which is a) easier and b) less likely to result in errors if you do something slightly different or forget one of the steps.

Crucially, with an analysis script other researchers can also see how you got from the raw data to the statistics you report in your final paper. Sharing analysis scripts online on sites such as the [Open Science Framework](https://osf.io/){target="_blank"} is now seen as an important open science practice. Even if you don't continue with quantitative research, in the future, the skills you develop on this course will allow you to evaluate quantitative research and to understand what goes on behind the scenes with data before the conclusions are presented, allowing you to become much more confident and competent consumers and users of research.

### How to use this book and the accompanying videos {-}

Within the book itself, for many of the initial chapters, we will provide the code you need to use. We would always strongly encourage you to type out the code yourself, as this is good practice for learning to code, but remember you can copy and paste from the book if you need to. Typing the code will seem much slower at first and you will make errors, lots of them, but you will learn much more quickly this way so do try to write the code yourself where you can.

We also provide the solutions to many of the activities. No-one is going to check whether you tried to figured out an activity yourself rather than going straight to the solution but remember this, if you copy and paste without thinking, you will learn nothing. Learning data skills and the knowledge that underpins those skills is much like learning a language - the more you practice and the more you use it, the better you become.

Additionally, a number of the chapters of this book have an associated video or videos. These videos are there to support you as you get comfortable in your data skills. However, it is important that you use them wisely. You should always try to work through each chapter of the book (or if you prefer each activity) on your own first, and only then watch the video if you get stuck, or for extra information.

Finally, this book is a living document. What that means is that on occasion we will make updates to the book such as fixing typos and including additional detail or activities. When substantial changes are made, we will create new support materials such as an accompanying video. However, it would be impossible to record a new video every time we make a minor change to an activity, therefore, sometimes there may be slight differences between the videos and the content of this book. Where there are differences between the book and the video, the book should always be considered the definitive version.

### Intended Learning Outcomes {-}

By the end of this course students will be able to:

* Clean and wrangle data into appropriate forms for analysis
* Visualise data using a range of plots
* Conduct and interpret a core set of statistical tests (t-test, correlation, ANOVA, regression)



577 changes: 577 additions & 0 deletions book/01-programming-basics.md

Large diffs are not rendered by default.

322 changes: 322 additions & 0 deletions book/02-intro-to-r.md

Large diffs are not rendered by default.

378 changes: 378 additions & 0 deletions book/03-loading-data.md

Large diffs are not rendered by default.

811 changes: 811 additions & 0 deletions book/04-wrangling-1.md

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions book/05-wrangling-2.knit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@



































































2 changes: 1 addition & 1 deletion book/14-anova.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ What are your options if the data don't meet the assumptions and it's really not

### Activity 10: Write-up {#anova-a10}

The below code replicates the write-up in the paper, although has changed the Welch t-test to the pairwise comparisons from `emmeans`.
The below code replicates the write-up in the paper, although has changed the Welch t-test to the pairwise comparisons from `emmeans`. Paste this to the **white space** of your .rmd file

```{r writeup1, eval = FALSE}
Second, and critically, for the 7-day diary postintervention, there was a significant difference between groups in overall intrusion frequency in daily life, F(`r mod_output$num.Df`, `r mod_output$den.Df`) = `r mod_output$statistic %>% round(2)`, p = `r mod_output$p.value %>% round(3)`, ηp2 = .`r mod_output$ges %>% round(2)`. Planned comparisons demonstrated that relative to the no-task control group, only those in the reactivation-plus-Tetris group, t(`r mod_contrasts$df[1]`) = `r mod_contrasts$statistic[1] %>% round(2)`, p = `r mod_contrasts$adj.p.value[1] %>% round(2)`, d = `r mod_contrasts$eff_size[1] %>% round(2)`, experienced significantly fewer intrusive memories; this finding replicated Experiment 1. The reactivation-plus-Tetris group had significantly fewer intrusive thoughts than the reactivation-only group, t(`r mod_contrasts$df[5]`) = `r mod_contrasts$statistic[5] %>% round(2)`, p = `r mod_contrasts$adj.p.value[5] %>% round(2)`, d = `r mod_contrasts$eff_size[5] %>% round(2)`. Further, there were no significant differences between the reactivation-plus-Tetris group and the Tetris-only group, t(`r mod_contrasts$df[4]`) = `r mod_contrasts$statistic[4] %>% round(2)`, p = `r mod_contrasts$adj.p.value[4] %>% round(2)`, d = `r mod_contrasts$eff_size[4] %>% round(2)`, the no-task control group and the reactivation-only group, t(`r mod_contrasts$df[3]`) = `r mod_contrasts$statistic[3] %>% round(2)`, p = `r mod_contrasts$adj.p.value[3] %>% round(2)`, or between the no-task control group and the Tetris-only group, t(`r mod_contrasts$df[2]`) = `r mod_contrasts$statistic[2] %>% round(2)`, p = `r mod_contrasts$adj.p.value[2] %>% round(2)`
Expand Down
15 changes: 8 additions & 7 deletions book/16-regression.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,16 @@ pwr.f2.test(u = 1, v = 35, f2 = NULL, sig.level = .05, power = .8)
```

`r hide("Explain the pwr.f2.test function")`
**u** - Numerator degrees of freedom. This the number of coefficients you have in your model (minus the intercept)
**v** - Denominator degrees of freedom. This is calculated as v=n-u-1, where n is the number of participants
**f2** - The effect size - here we are solving the effect size, so this parameter is left as NULL
**sig.level** - The significance level of your study
**power** - The power level of your study

- **u** - Numerator degrees of freedom. This the number of coefficients you have in your model (minus the intercept)
- **v** - Denominator degrees of freedom. This is calculated as v=n-u-1, where n is the number of participants
- **f2** - The effect size - here we are solving the effect size, so this parameter is left as NULL
- **sig.level** - The significance level of your study
- **power** - The power level of your study
`r unhide()`
<br>

* Based on the power analysis, what is the minimum effect size we were able to detect rounded to 2 decimal places? `r fitb(".22", "0.22")`
* Based on the power analysis, what is the minimum effect size we were able to detect rounded to 2 decimal places? `r fitb("0.22")`
* According to Cohen's guidelines, this would be a `r mcq(c("Small", answer = "Medium", "Large"))` effect.

There is no formula to calculate our observed f^2^, we must do it manually using the formula from the lecture.
Expand All @@ -266,7 +267,7 @@ mod_p <- pf(f[1], f[2], f[3], lower=FALSE)
Now, copy and paste the below code into **white-space** and knit the document.

```{r writeup1, eval = FALSE}
A simple linear regression was performed with engagement (M = `r descriptives$mean_weeks %>% round(2)`, SD = `r descriptives$sd_anx %>% round(2)`) as the outcome variable and statistics anxiety (M = `r descriptives$mean_anx %>% round(2)`, SD = `r descriptives$sd_anx %>% round(2)`) as the predictor variable. The results of the regression indicated that the model significantly predicted course engagement (F(`r mod_summary$fstatistic[2]`, `r mod_summary$fstatistic[3]`) = `r mod_summary$fstatistic[1] %>% round(2)`, p < .001, Adjusted R2 = `r mod_summary$adj.r.squared %>% round(2)`, f2 = .63), accounting for `r (mod_summary$adj.r.squared %>% round(2))*100`% of the variance. Anxiety was a significant predictor (β = `r mod$coefficients[2] %>% round(2)`, p < `r mod_p %>% round(3)`.
A simple linear regression was performed with engagement (M = `r descriptives$mean_weeks %>% round(2)`, SD = `r descriptives$sd_weeks %>% round(2)`) as the outcome variable and statistics anxiety (M = `r descriptives$mean_anx %>% round(2)`, SD = `r descriptives$sd_anx %>% round(2)`) as the predictor variable. The results of the regression indicated that the model significantly predicted course engagement (F(`r mod_summary$fstatistic[2]`, `r mod_summary$fstatistic[3]`) = `r mod_summary$fstatistic[1] %>% round(2)`, p < .001, Adjusted R2 = `r mod_summary$adj.r.squared %>% round(2)`, f2 = .3), accounting for `r (mod_summary$adj.r.squared %>% round(2))*100`% of the variance. Anxiety was a significant predictor (β = `r mod$coefficients[2] %>% round(2)`, p < `r mod_p %>% round(3)`.
)
```

Expand Down
Binary file modified book/_main.rds
Binary file not shown.
39 changes: 39 additions & 0 deletions book/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "Fundamentals of Quantitative Analysis"
author: "Emily Nordmann & Phil McAleer"
date: "2023-10-16"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
csl: include/apa.csl
link-citations: yes
description: |
This book is designed for Masters Level students who have no prior training in data skills and/or statistical analysis.
url: https://psyteachr.github.io/quant-fun-v2
github-repo: psyteachr/quant-fun-v2
cover-image: images/logos/logo.png
apple-touch-icon: images/logos/apple-touch-icon.png
apple-touch-icon-size: 180
favicon: images/logos/favicon.ico
---



# Overview {-}

<div class="small_right"><img src="images/logos/logo-quant-fun.png"
alt="ADS Hex Logo" /></div>

**Book Name:** Fundamentals of Quantitative Analysis

**Summary:** Materials for the University of Glasgow School of Psychology & Neuroscience Research Methods modules for MSc students.

**Authors:** Emily Nordmann, Wil Toivo & Phil McAleer

**Aim:** This course covers data skills such as R Markdown, data wrangling with tidyverse, and data visualisation with ggplot2. It also introduces statistical concepts such as Null Hypothesis Significance Testing (NHST), alpha, power, effect size, and sample size, as well as demonstrating how to perform numerous analyses based around the general linear model including correlations, t-tests, ANOVAs and Regression.

**Contact:** This book is a living document and will be regularly checked and updated for improvements. Should you have any issues using the book or queries, please contact [Phil McAleer](mailto:[email protected]).

**R Version:** This book has been written with R version 3.5.1 (2018-07-02)


77 changes: 14 additions & 63 deletions book/packages.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ @Manual{R-base
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2021},
year = {2018},
url = {https://www.R-project.org/},
}

Expand All @@ -23,14 +23,6 @@ @Manual{R-dplyr
url = {https://CRAN.R-project.org/package=dplyr},
}

@Manual{R-faux,
title = {faux: Simulation for Factorial Designs},
author = {Lisa DeBruine},
year = {2021},
note = {R package version 1.1.0},
url = {https://github.com/debruine/faux},
}

@Manual{R-forcats,
title = {forcats: Tools for Working with Categorical Variables (Factors)},
author = {Hadley Wickham},
Expand All @@ -48,18 +40,11 @@ @Manual{R-ggplot2
}

@Manual{R-glossary,
title = {glossary: Glossary of Statistical and Coding Terms},
title = {glossary: Glossaries for Markdown and Quarto Documents},
author = {Lisa DeBruine},
year = {2021},
note = {R package version 0.0.0.9001},
}

@Manual{R-knitr,
title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
author = {Yihui Xie},
year = {2021},
note = {R package version 1.36},
url = {https://yihui.org/knitr/},
year = {2023},
note = {R package version 1.0.0},
url = {https://CRAN.R-project.org/package=glossary},
}

@Manual{R-purrr,
Expand All @@ -74,10 +59,12 @@ @Manual{R-readr
title = {readr: Read Rectangular Text Data},
author = {Hadley Wickham and Jim Hester},
year = {2021},
note = {R package version 2.0.2},
note = {R package version 2.1.0},
url = {https://CRAN.R-project.org/package=readr},
}

<<<<<<< HEAD
=======
@Manual{R-rvest,
title = {rvest: Easily Harvest (Scrape) Web Pages},
author = {Hadley Wickham},
Expand All @@ -86,6 +73,7 @@ @Manual{R-rvest
url = {https://CRAN.R-project.org/package=rvest},
}

>>>>>>> 03a3c27782d66dbf91fee4a90e9e67e21e78e9f0
@Manual{R-stringr,
title = {stringr: Simple, Consistent Wrappers for Common String Operations},
author = {Hadley Wickham},
Expand All @@ -98,7 +86,7 @@ @Manual{R-tibble
title = {tibble: Simple Data Frames},
author = {Kirill Müller and Hadley Wickham},
year = {2021},
note = {R package version 3.1.5},
note = {R package version 3.1.6},
url = {https://CRAN.R-project.org/package=tibble},
}

Expand All @@ -123,27 +111,19 @@ @Manual{R-tinytex
LaTeX Documents},
author = {Yihui Xie},
year = {2021},
note = {R package version 0.34},
note = {R package version 0.35},
url = {https://github.com/yihui/tinytex},
}

@Manual{R-webexercises,
title = {webexercises: Create Interactive Web Exercises in R Markdown (Formerly
webex)},
author = {Dale Barr and Lisa DeBruine},
year = {2021},
note = {R package version 1.0.0},
year = {2023},
note = {R package version 1.1.0},
url = {https://github.com/psyteachr/webexercises},
}

@Manual{R-xml2,
title = {xml2: Parse XML},
author = {Hadley Wickham and Jim Hester and Jeroen Ooms},
year = {2020},
note = {R package version 1.3.2},
url = {https://CRAN.R-project.org/package=xml2},
}

@Book{bookdown2016,
title = {bookdown: Authoring Books and Technical Documents with {R} Markdown},
author = {Yihui Xie},
Expand All @@ -163,35 +143,6 @@ @Book{ggplot22016
url = {https://ggplot2.tidyverse.org},
}

@Manual{glossary2021,
title = {{glossary}: Glossary of Statistical and Coding Terms {markr}},
author = {Lisa DeBruine and Dale Barr and Philip McAleer and Helena Paterson},
year = {2021},
url = {https://psyteachr.github.io/markr/},
}

@Book{knitr2015,
title = {Dynamic Documents with {R} and knitr},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2015},
edition = {2nd},
note = {ISBN 978-1498716963},
url = {https://yihui.org/knitr/},
}

@InCollection{knitr2014,
booktitle = {Implementing Reproducible Computational Research},
editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},
title = {knitr: A Comprehensive Tool for Reproducible Research in {R}},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
year = {2014},
note = {ISBN 978-1466561595},
url = {http://www.crcpress.com/product/isbn/9781466561595},
}

@Article{tidyverse2019,
title = {Welcome to the {tidyverse}},
author = {Hadley Wickham and Mara Averick and Jennifer Bryan and Winston Chang and Lucy D'Agostino McGowan and Romain François and Garrett Grolemund and Alex Hayes and Lionel Henry and Jim Hester and Max Kuhn and Thomas Lin Pedersen and Evan Miller and Stephan Milton Bache and Kirill Müller and Jeroen Ooms and David Robinson and Dana Paige Seidel and Vitalie Spinu and Kohske Takahashi and Davis Vaughan and Claus Wilke and Kara Woo and Hiroaki Yutani},
Expand All @@ -211,6 +162,6 @@ @Article{tinytex2019
volumne = {40},
number = {1},
pages = {30--32},
url = {http://tug.org/TUGboat/Contents/contents40-1.html},
url = {https://tug.org/TUGboat/Contents/contents40-1.html},
}

Loading