selfesteem_data |> head() activity selfesteem
1 2 3
2 4 4
3 5 7
4 3 2
5 4 3
6 5 4
RQ: Are people’s Likert scale ratings of their own activity levels associated with their self-rated self-esteem, also from a Likert scale?
Here’s what the first six rows of the data looks like:
selfesteem_data |> head() activity selfesteem
1 2 3
2 4 4
3 5 7
4 3 2
5 4 3
6 5 4
Here’s how we might plot this data (if you’re not sure what part of the code does, delete it or comment it out and try running what’s leftover to see what changes):
selfesteem_data |>
mutate(
activity = factor(activity),
selfesteem = factor(selfesteem)
) |>
ggplot(aes(x = activity, fill = selfesteem)) +
geom_bar()
Our null hypothesis is that activity ratings and self-esteem ratings are not correlated—in other words, that they have a Spearman’s correlation \(r_S\) of 0.
Formally:
\[ H_0: r_S = 0 \]
# H0: r_S = 0Our alternative hypothesis is that there is a correlation between activity ratings and self-esteem ratings. Formally:
\[ H_1: r_S ≠ 0 \]
# H1: r_S != 0To test whether Spearman’s correlation coefficient is significantly different from zero, we use the function cor.test() and give it the following arguments:
method = 'spearman' to make sure we’re doing Spearman’s correlation(the order that you name the variables in does not matter for the test)
cor.test(
selfesteem_data$activity,
selfesteem_data$selfesteem,
method = 'spearman'
)
Spearman's rank correlation rho
data: selfesteem_data$activity and selfesteem_data$selfesteem
S = 2063, p-value = 0.002
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
0.54097
Note: If you get the following warning message, you can safely ignore it and just report your results as usual.
Warning message:
In cor.test.default(selfesteem_data$activity, selfesteem_data$selfesteem, :
cannot compute exact p-value with ties
| Type of constraint | What to check for Spearman’s correlation |
|---|---|
| Data requirements | Both variables represent rankings/orderings. |
Both variables represent rankings/orderings.
If it makes sense to sort both variables into some kind of order, then you can consider them appropriate for Spearman’s correlation.
glimpse(selfesteem_data)Rows: 30
Columns: 2
$ activity <dbl> 2, 4, 5, 3, 4, 5, 6, 4, 7, 4, 5, 7, 4, 1, 6, 1, 5, 4, 5, 5,…
$ selfesteem <dbl> 3, 4, 7, 2, 3, 4, 4, 3, 6, 4, 4, 4, 3, 4, 7, 3, 5, 4, 5, 4,…
In this case, both activity and selfesteem are ratings from a Likert scale, so they are definitely ordinal variables.
The correlation coefficient itself is the effect size measure for correlations.
Interpreting any correlation coefficients:
Do people who rate their own activity levels higher also tend to have higher self-esteem? To analyse this, we used Spearman’s correlation to test the association between people’s activity level ratings (on a seven-point Likert scale) and their self-esteem ratings (also on a seven-point Likert scale). Spearman’s correlation is an appropriate choice because both variables are ordinal.
Specifically, we tested \(H_0: r_S = 0\) against \(H_1: r_S \neq 0\). We found a medium positive correlation that was significantly different from zero (\(r_S\) = .54, \(p\) = .002). We therefore reject the null hypothesis and conclude that activity rankings and self-esteem rankings are significantly positively associated.
The most important thing: Your decision about the null hypothesis should be clear.
You can make sure your decision is clear either by