Data Analysis for Psychology in R 3
Psychology, PPLS
University of Edinburgh
|
Linear Mixed Models (with Elizabeth Pankratz) |
Regression refresher, intro to group-structured data |
| Modelling group-structured data using random effects | |
| Interpreting LMMs and building maximal models | |
| Troubleshooting model fit, checking assumptions + diagnostics | |
| LMMs: Practice analysis | |
|
Factor Analysis working with multi-item measures (with Josiah King) |
measurement and dimensionality |
| exploring underlying constructs (EFA) | |
| testing theoretical models (CFA) | |
| reliability and validity | |
| recap & exam prep |
Labs:
Lecture consolidation:
Whether our measurement instrument actually measures the thing we think it measures.
| item | wording |
|---|---|
| 1. | I often find myself performing tasks that I had intended to do days before. |
| 2.* | I do not do assignments until just before they are to be handed in. |
| 3.* | When I am finished with a library book, I return it right away regardless of the date it is due. |
| 4. | When it is time to get up in the morning, I most often get right out of bed. |
| 5. | A letter may sit for days after I write it before mailing it. |
| 6. | I generally return phone calls promptly. |
| 7. | Even with jobs that require little else except sitting down and doing them, I find they seldom get done for days. |
| 8. | I usually make decisions as soon as possible. |
| 9. | I generally delay before starting on work I have to do. |
| 10.* | I usually have to rush to complete a task on time. |
| item | wording |
|---|---|
| 11. | When preparing to go out, I am seldom caught having to do something at the last minute. |
| 12. | In preparing for some deadline, I often waste time by doing other things. |
| 13.* | I prefer to leave early for an appointment. |
| 14.* | I usually start an assignment shortly after it is assigned. |
| 15. | I often have a task finished sooner than necessary. |
| 16. | I always seem to end up shopping for birthday or Christmas gifts at the last minute. |
| 17. | I prefer dogs to cats. |
| 18. | I usually accomplish all the things I plan to do in a day. |
| 19. | I am continually saying I'll do it tomorrow. |
| 20. | I usually take care of all the tasks I have to do before I settle down and relax for the evening. |
Face validity: The extent to which a measurement tool appears, on the surface, to measure what it claims to measure.
There’s a big problem with many questionnaires - they are very prone to biases.
If a respondent knows the intended construct, they can answer accordingly.
People try and come up with ‘subtle items’ for which it’s harder to ‘fake good’.
Some weird, archaic, but real examples:
In order to procrastinate, I spent some time trying to make a new measure of procrastination!
Version 1
| item | wording |
|---|---|
| J1 | I believe it is necessary to delay critical decisions until someone else can provide guidance. |
| J2 | It is better to put off exercising until I feel fully motivated and optimistic. |
| J3 | For work that requires creative thinking or imagination, it is better to wait until thoughts spontaneously arise |
| J4 | It is better to have a fully fledged out plan before starting a piece of work |
What aspects of “procrastination” does the MNOPQv1 measure miss?
It turns out, theory suggests that ‘procrastination’ typically involves:
How about now?
| item | domain | wording |
|---|---|---|
| J1 | Justification | I believe it is necessary to delay critical decisions until someone else can provide guidance. |
| J2 | Justification | It is better to put off exercising until I feel fully motivated and optimistic. |
| J3 | Justification | For work that requires creative thinking or imagination, it is better to wait until thoughts spontaneously arise |
| J4 | Justification | It is better to have a fully fledged out plan before starting a piece of work |
| A1 | Affect | I feel high levels of anxiety and self-reproach when I realize I have needlessly delayed a task. |
| A2 | Affect | I often choose a pleasurable, easy activity over a necessary, more difficult task. |
| A3 | Affect | Even when I know a delay will cause me pain later, I still struggle to begin the task now. |
| B1 | Behaviour | I often begin a task only hours before the final deadline. |
| B2 | Behaviour | I frequently find myself performing tasks that I intended to do several days earlier. |
| B3 | Behaviour | I regularly experience moments where I have to rush to complete a task on time. |
Content validity: The extent to which we have a representative sample of items to cover the content domains that our theory dictates exist.
| item | wording |
|---|---|
| J1 | I believe it is necessary to delay critical decisions until someone else can provide guidance. |
| J2 | It is better to put off exercising until I feel fully motivated and optimistic. |
| J3 | For work that requires creative thinking or imagination, it is better to wait until thoughts spontaneously arise |
| J4 | It is better to have a fully fledged out plan before starting a piece of work |
| A1 | I feel high levels of anxiety and self-reproach when I realize I have needlessly delayed a task. |
| A2 | I often choose a pleasurable, easy activity over a necessary, more difficult task. |
| A3 | Even when I know a delay will cause me pain later, I still struggle to begin the task now. |
| B1 | I often begin a task only hours before the final deadline. |
| B2 | I frequently find myself performing tasks that I intended to do several days earlier. |
| B3 | I regularly experience moments where I have to rush to complete a task on time. |
I have my measure of “procrastination”.
Convergent validity: The degree to which scores on a measurement tool are related to scores on other measures of the same construct.
Discriminant validity: The extent to which scores on a measurement tool do not correlate strongly with measures of unrelated constructs.

| item | wording |
|---|---|
| J1 | I believe it is necessary to delay critical decisions until someone else can provide guidance. |
| J2 | It is better to put off exercising until I feel fully motivated and optimistic. |
| J3 | For work that requires creative thinking or imagination, it is better to wait until thoughts spontaneously arise |
| J4 | It is better to have a fully fledged out plan before starting a piece of work |
| A1 | I feel high levels of anxiety and self-reproach when I realize I have needlessly delayed a task. |
| A2 | I often choose a pleasurable, easy activity over a necessary, more difficult task. |
| A3 | Even when I know a delay will cause me pain later, I still struggle to begin the task now. |
| B1 | I often begin a task only hours before the final deadline. |
| B2 | I frequently find myself performing tasks that I intended to do several days earlier. |
| B3 | I regularly experience moments where I have to rush to complete a task on time. |
I measure a bunch of people on my “procrastination scale”.
Criterion validity: The degree to which scores on a measurement tool correlate with some independent, external standard (or ‘criterion’). Very often this is the prediction of some future event.
All measurement is befuddled by error McNemar (1946, p.294)
How consistently our measurement instrument measures whatever it is measuring.
take two measurements - how close are they?
imagine we could see the “truth” - how much variance in our measurements is due to the true values?
\[
\text{Reliability} =
\frac{Var(\text{True Scores})}{Var(\text{True Scores})+Var(\text{Error})} =
\frac{Var(\text{True Scores})}{Var(\text{Observed Scores})}
\]
\[ \begin{align*} \rho_{XX'} &= \frac{Var(T_x)}{Var(X)} = \frac{Var(T_x)}{Var(T_x) + Var(e_x)} = 1 - \frac{Var(e_x)}{Var(X)} \\ \quad \\ &X\text{ is observed score on measure }X \\ &T_x\text{ is True score} \\ &e_x\text{ is error} \end{align*} \]
Observed_Score True_score Error
1 37.9 ?? ??
2 44.1 ?? ??
3 34.1 ?? ??
4 34.9 ?? ??
5 42.6 ?? ??
6 38.5 ?? ??
... ... ... ...
Error1 Observed_Score1 True_score Observed_Score2 Error2
1 ?? 44 ?? 43.4 ??
2 ?? 37 ?? 36.9 ??
3 ?? 38.3 ?? 38.3 ??
4 ?? 36.7 ?? 33.6 ??
5 ?? 43.8 ?? 44.1 ??
6 ?? 39.7 ?? 38.9 ??
... ... ... ... ... ...
Error1 Observed_Score1 True_score Observed_Score2 Error2
1 ?? 44 43.7 43.4 ??
2 ?? 37 36.9 36.9 ??
3 ?? 38.3 38.3 38.3 ??
4 ?? 36.7 35.2 33.6 ??
5 ?? 43.8 44 44.1 ??
6 ?? 39.7 39.3 38.9 ??
... ... ... ... ... ...
Error1 Observed_Score1 True_score Observed_Score2 Error2
1 0.3 44 43.7 43.4 -0.3
2 0.1 37 36.9 36.9 -0.1
3 0 38.3 38.3 38.3 0
4 1.6 36.7 35.2 33.6 -1.6
5 -0.2 43.8 44 44.1 0.2
6 0.4 39.7 39.3 38.9 -0.4
... ... ... ... ... ...
.. ... ... ... ... ...
. ... ... ... ... ...
VAR 0.49 26.249 25.817 26.366 0.49
There are various formulations of ICC, but the basic principle = ratio of variance between groups to total variance.
\[ \begin{align} ICC &= \frac{\sigma^2_{b}}{\sigma^2_{b} + \sigma^2_{e}} \\ \qquad \\ \textrm{Where:}& \\ \sigma^2_{b} &= \textrm{variance between group} \\ \sigma^2_{e} &= \textrm{variance within groups (residual variance)} \end{align} \]
in R: ICC() function from the psych package
also referred to as “internal consistency”
We have a sample of all possible items we might use for measuring X
each item represents same Truth, to same degree (let’s assume)
cov(item1, item2) is an estimate of var(T)
cov(item2, item3)cov(item3, item4), cov(item1, item3) …So let’s take the average covariance, and call that “truth”
\[
\begin{align*}
\alpha=\frac{k}{k-1}\left( \frac{\sum\limits_{i\neq}\sum\limits_j\sigma_{ij}}{\sigma^2_X} \right) = \frac{k^2 \,\,\,\overline{\sigma_{ij}}}{\sigma^2_X} \\
k \text{ is the number of items in scale X} \\
\sigma^2_X \text{ is the variance of the sum scores} \\
\sigma_{ij} \text{ is the covariance between items }i\text{ and }j \\
\end{align*}
\] 
\[
\begin{align}
&= \frac{\text{average covariance}}{\text{total score variance}}\\
\quad \\
&= \frac{\text{true variance}}{\text{total score variance}} \\
\end{align}
\]
In R: the alpha() function from the psych package
\[
\begin{align*}
\omega_{total} = \frac{ \left( \sum\limits_{i=1}^{k}\lambda_i\right)^2 }{ \left(\sum\limits_{i=1}^{k}\lambda_i \right)^2 + \sum\limits_{i=1}^{k}\theta_{ii} } \\
k \text{ is the number of items in scale}\\
\lambda_i \text{ is the factor loading for item }i\\
\theta_{ii}\text{ is the error variance for item }i\\
\end{align*}
\] 
\[
\small
\begin{align}
&= \frac{\text{factor loadings}^2}{\text{factor loadings}^2 + \text{error}}\\
\quad \\
&= \frac{\text{variance explained by factors}}{\text{variance explained by factors} + \text{error variance}}\\
\quad \\
&= \frac{\text{true variance}}{\text{true variance} + \text{error variance}} \\
\end{align}
\]
in R: the omega() from function from the psych package.
When we calculate a correlation using estimated quantities (e.g., a score from a set of items), they will be:
\(r_{xy}\) = 0.24, 95% CI [0.04, 0.42]
With estimates of each measures reliability, we can “correct” correlations
\[ r^*_{xy} = \frac{r_{xy}}{\sqrt{ \rho^2_{xx'} \rho^2_{yy'}}} \]
\(r^*_{xy}\) is the correlation between \(x\) and \(y\) after correcting for attenuation
\(r_{xy}\) is the correlation before correcting for attenuation
\(\rho^2_{xx'}\) is the reliability of \(x\)
\(\rho^2_{yy'}\) is the reliability of \(y\)
At very least just think about reliability!
\(r_{xy}\) = 0.24, 95% CI [0.04, 0.42]
\(r^*_{xy}\) = 0.8, 95% CI [0.13, 1\(^1\)]
Reliability and Validity are properties of the sample, not of the scale/measurement tool
where would you put:
if we have time and want some R coding..
half of you saw this:

the other half of you saw this:

“AI Receptivity Scale”
This is the survey of the questionnaire items that we created last week. The survey is completely optional, and completely anonymous. It is purely for practical experience and demonstration of scale development and exploratory factor analysis, and your responses (as well as your choice of whether or not to respond) will have absolutely no consequences on your course outcome.