forked from PsyTeachR/ug2-practical
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08-s01-lab08d.Rmd
More file actions
188 lines (110 loc) · 12.2 KB
/
08-s01-lab08d.Rmd
File metadata and controls
188 lines (110 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
## Test Yourself
This is a **formative** assignment meaning that it is purely for you to test your own knowledge, skill development, and learning, and does not count towards an overall grade. However, you are strongly encouraged to do the assignment as it will continue to boost your skills which you will need in future assignments. You will be instructed by the Course Lead on Moodle as to when you should attempt this assignment. Please check the information and schedule on the Level 2 Moodle page.
**Lab 8: APES Assignment**
In order to complete this assignment you first have to download the assignment .Rmd file which you need to edit for this assignment: titled `GUID_Level2_Semester1_Lab8.Rmd`. This can be downloaded within a zip file from the below link. Once downloaded and unzipped you should create a new folder that you will use as your working directory; put the .Rmd file in that folder and set your working directory to that folder through the drop-down menus at the top [Download the assignment zip file from here](data/08-s01/homework/ch8-assign-file.zip).
*NOTE*: in nearly all of the problems below, you will need to replace `NULL` with a value or a pipeline of code that computes a value. Please pay special attention as to what the question is asking for as the output, e.g. *value* or a *tibble*; when asked for a *value* as an output, make sure it is a single value and not a value stored in a tibble. Finally, when altering code inside the code blocks, please *do not* re-order or rename the code blocks (T1, T2, ... etc.). If you do, this may impact your grade!
It's also recommended that you "Knit" a report to be able to see what you've accomplished and spot potential errors. A great thing to do is close the whole programme, restart it, and then knit your code. This will test whether you have remembered to include essential elements, such as libraries, in your code.
**APES: Alpha, Power, Effect Size, and Sample Size**
In the lab we have been looking at the interplay between the four components of Alpha, Power, Effect Size, and Sample Size. This is a very important part of experimental design to understand as it will help you understand which studies are worth paying attention to and it will help you design your own studies in the coming years so that you know just how many people to run and what to make of the effect that you find. If you have not yet done so, we highly recommend reading the blog suggested as PreClass reading material and carrying out the activities in the inclass activity. These will help you will both the practicalities and the interpretation of the following assignment.
Remember that this assignment is formative but the knowledge gained from the practical activities in this lab will be super important to your future-self!
**Before starting let's check:**
1. The `.Rmd` file is saved in your working directory. For assessments we ask that you save it with the format `GUID_Level2_Semester1_Lab8.Rmd` where `GUID` is replaced with your `GUID`. Though this is a formative assessment, it may be good practice to do the same here.
**Libraries**
* You will need to use the `tidyverse` and `broom` libraries in this assignment, so load them in the `library` code chunk below.
* **Hint:** library(package)
```{r library, message=FALSE, warning=FALSE}
```
**Basic Calculations**
### Assignment Task 1 {#Ch8AssignQueT1}
* You set up a study so that it has a power value of $power = .87$. To two decimal places, what is the Type II error rate of your study?
Replace the `NULL` in the `T1` code chunk below with either a single value, or with mathematical notation, so that `error_rate` returns the actual value of the Type II error rate for this study. By mathematical notation we mean you to use the appropriate formula but insert the actual values.
```{r T1}
error_rate <- NULL
```
### Assignment Task 2 {#Ch8AssignQueT2}
* You run an independent t-test and discover a significant effect, t(32) = 3.26, p < .05. Using the appropriate formula, given in the inclass activity, calculate the effect size of this t-test.
Replace the `NULL` in the `T2` code chunk below with mathematical notation so that `effect1` returns the value of the effect size. Do not round the value.
```{r T2}
effect1 <- NULL
```
### Assignment Task 3 {#Ch8AssignQueT3}
* You run a dependent t-test and discover a significant effect, t(43) = 2.24, p < .05. Using the appropriate formula, given in the inclass activity, calculate the effect size of this t-test.
Replace the `NULL` in the `T3` code chunk below with mathematical notation so that `effect2` returns the value of the effect size. Do not round the value.
```{r T3}
effect2 <- NULL
```
**Using the Power function**
### Assignment Task 4 {#Ch8AssignQueT4}
* Replace the NULL in the `T4` code chunk below with a pipeline combining `pwr.t.test()`, `pluck()` and `ceiling()`, to determine how many participants are needed to sufficiently power a paired-samples t-test at $power = .9$ with $d = .5$? Assume a two-sided hypothesis with $\alpha = .05$. Ceiling the answer to the nearest whole participant and store this value in `participants`.
* **Hint:** Remember the quotes on the pluck
```{r T4}
participants <- NULL
```
### Assignment Task 5 {#Ch8AssignQueT5}
* Using a pipeline similar to Task 4, what is the minimum effect size that a one-sample t-test study (two-tailed hypothesis) could reliably detect given the following details : $\beta = .16, \alpha = 0.01, n = 30$. Round to two decimal places and replace the NULL in the `T5` code chunk below to store this value in `effect3`.
* **Hint:** Remember you are going to `round()` and not `ceiling()`
```{r T5}
effect3 <- NULL
```
### Assignment Task 6 {#Ch8AssignQueT6}
**Study 1**
* You run a between-subjects study and establish the following descriptives: Group 1 (M = 5.1, SD = 1.34, N = 32); Group 2 (M = 4.4, SD = 1.27, N = 32). Replace the `NULL` in the `T6` code chunk below with the following formula, substituting in the appropriate values, to calculate the t-value of this test. Calculate as Group1 minus Group2. Store the t-value in `tval`. Do not round `tval` and do not include the `t =` part of the formula.
$$ t = \frac {{\bar{x_{1}}} - \bar{x_{2}}}{ \sqrt {\frac {{s_{1}}^2}{n_{1}} + \frac {{s_{2}}^2}{n_{2}}}}$$
```{r T6}
tval <- NULL
```
### Assignment Task 7 {#Ch8AssignQueT7}
* Using the `tval` calculated in Task 6, calculate the effect size of this study and store it as `d1` in the `T7` code chunk below, replacing the `NULL` with the appropriate formula and values. Do not round `d1`.
* **Hint:** Think between-subjects
```{r T7}
d1 <- NULL
```
### Assignment Task 8 {#Ch8AssignQueT8}
Assuming $power = .8$, $\alpha =.05$ on a two-tailed hypothesis, based on the `d1` value in Task 7 and the smallest achievable effect size of this study, which of the below statements is correct.
1. The smallest effect size that this study can determine is d = .71. The detected effect size, `d1`, is larger than this and as such this study is potentially suitably powered
2. The smallest effect size that this study can determine is d = .17. The detected effect size, `d1`, is larger than this and as such this study is potentially suitably powered
3. The smallest effect size that this study can determine is d = .17. The detected effect size, `d1`, is smaller than this and as such this study is potentially suitably powered
4. The smallest effect size that this study can determine is d = .71. The detected effect size, `d1`, is smaller than this and as such this study is potentially not suitably powered
Replace the NULL in the `T8` code chunk below with the number of the statement that is a true summary of this study. It may help you to calculate and store the smallest achievable effect size of this study in `poss_d`.
* **Hint:** use poss_d to calculate the smallest possible effect size of this study to help you answer this question.
```{r T8}
poss_d <- NULL
answer_T8 <- NULL
```
### Assignment Task 9 {#Ch8AssignQueT9}
**Study 2**
Below is a paragraph from the results of Experiment 4 from *Schroeder, J., & Epley, N. (2015). The sound of intellect: Speech reveals a thoughtful mind, increasing a job candidate's appeal.* *Psychological Science*, *26*, *877-891*. We saw this paper in Lab 5 but you can find out more details at <a href="https://sites.trinity.edu/osl/data-sets-and-activities/t-test-activities", target = "_blank">Open Stats Lab</a>.
*Recruiters believed that the job candidates had greater intellect - were more competent, thoughtful, and intelligent - when they listened to pitches (M = 5.63, SD = 1.61, n = 21) than when they read pitches (M = 3.65, SD = 1.91, n = 18), t(37) = 3.53, p < .01, 95% CI of the difference = [0.85, 3.13], **d1 = 1.16**. The recruiters also formed more positive impressions of the candidates - rated them as more likeable and had a more positive and less negative impression of them - when they listened to pitches (M = 5.97, SD = 1.92) than when they read pitches (M = 4.07, SD = 2.23), t(37) = 2.85, p < .01, 95% CI of the difference = [0.55, 3.24], **d2 = 0.94**. Finally, they also reported being more likely to hire the candidates when they listened to pitches (M = 4.71, SD = 2.26) than when they read the same pitches (M = 2.89, SD = 2.06), t(37) = 2.62, p < .01, 95% CI of the difference = [0.41, 3.24], **d3 = 0.86**.*
Using the `pwr.t.test()` function, what is the minimum effect size that this paper could have reliably detected? Test at $power = .8$ for a two-sided hypothesis. Use the $\alpha$ stated in the paragraph and the smallest *n* stated; store the value as `effect4` in the `T9` code chunk below. Replace the `NULL` with your pipeline and round the effect size to two decimal places.
```{r T9}
effect4 <- NULL
```
### Assignment Task 10 {#Ch8AssignQueT10}
Given the value of `effect4` calculated in Task 9, and the stated alpha in the paragraph and the smallest n of the two groups, which of these statements is true.
1. This study has enough power to reliably detect effects at the size of d3 and larger.
2. This study has enough power to reliably detect effects at the size of only d1.
3. This study has enough power to reliably detect effects at the size of d2 and larger, but not d3.
4. This study does not have enough power to reliably detect effect sizes at d1 or lower.
Replace the NULL in the `T10` code chunk below with the number of the statement that is TRUE, storing the single value in `answer_t10`.
```{r T10}
answer_t10 <- NULL
```
### Assignment Task 11 {#Ch8AssignQueT11}
**Last but not least:**
Read the following statements.
a. In general, increasing sample size will increase the power of a study.
b. In general, smaller effect sizes require fewer participants to detect at $power = .8$.
c. In general, lowering alpha (from .05 to .01) will decrease the power of a study.
Now look at the below four summary statements of the validity of the statements a, b and c.
1. Statements a, b and c are all TRUE.
2. Statements a and c are both TRUE.
3. Statements b and c are both TRUE.
4. None of the statements are TRUE.
Replace the NULL in the `T11` code chunk below with the number of the statement that is correct, storing the single value in `answer_t11`.
```{r T11}
answer_t11 <- NULL
```
### The **`pwr`** package
An alternative solution to Task 9 would be to use the `pwr.t2n.test()` function from the `pwr` package [@R-pwr]. This would allow you to enter the `n` of both groups as there is an `n1` and an `n2` argument. Were you to use this, entering n1 = 18, n2 = 21, alpha = .01, the d drops just a little, changing the interpretation of Task 10. Feel free to try this analysis and see if you can figure out what would be the alternative answer to Task 10.
<span style="font-size: 22px; font-weight: bold; color: var(--blue);">Job Done - Activity Complete!</span>
Well done, you are finshed! Now you should go check your answers against the solution file which can be found at the end of this chapter. You are looking to check that the resulting output from the answers that you have submitted are exactly the same as the output in the solution - for example, remember that a single value is not the same as a coded answer. Where there are alternative answers, it means that you could have submitted any one of the options as they should all return the same answer. If you have any questions please post them on the forums.