0
$\begingroup$

I've got two groups (independent variable), one continuous dependent variable, and one 4-level ordinal variable (socioeconomic status).

I would like to compare the two groups but (within each group) I'd like to see the scores for each level of the ordinal variable (socioeconomic status).

Could someone point me in the right direction? Many thanks!

$\endgroup$
1
  • $\begingroup$ It's not clear what you mean by "see the scores" for each level of the ordinal variable..? Do you want to control/adjust for this other variable? Or just descriptively see the scores between the groups? $\endgroup$ Aug 17, 2018 at 19:33

1 Answer 1

0
$\begingroup$

From your description the following example data (created in R) should represent the correct structure:

> example_data <- data.table(
    continuous_dependent=c(13, 24, 42, 29, 19, 12, 30, 38),
    ordinal=ordered(factor(c(1, 3, 3, 4, 4, 1, 2, 2))),
    groups=factor(c("g1", "g1", "g2", "g2", "g1", "g1", "g2", "g2"))
)
> example_data
   continuous_dependent ordinal groups
1:                   13       1 group1
2:                   24       3 group1
3:                   42       3 group2
4:                   29       4 group2
5:                   19       4 group1
6:                   12       1 group1
7:                   30       2 group2
8:                   38       2 group2

To to calculate the scores for each group and ordinal level you can then:

> dt[, score:=mean(continuous_dependent), by=list(groups, ordinal)]
   groups ordinal   Score
1: group1       1    12.5
2: group1       3    24.0
3: group2       3    42.0
4: group2       4    29.0
5: group1       4    19.0
6: group2       2    34.0
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.