I´m fairly new to the tools of statistics and I need some help. I´m working in R. I have a list of students, their age, sex, test results(continuous variable) and education (a categorical variable. 0 if student has no education, 1 if student has education). This is stored in the data frame df.
I have assigned each student an age group depending on their age. The groups are 5-10,11-15, 16-20, 21-25. So now I have a new categorical variable with 4 levels.
I have done logistic regression for each age group. I did the test in R like this:
model1 = glm(education ~ test results + sex + age, data = df, family = binomial())
From the logistic regression result I compute the odds ratio (exp(coefficient)) for the test results variable. For each age group I got an odds ratio and confidence interval. There are some differences in the odds ratio between age groups. The odd ratio gets closer to 1 with higher age group. I interpret this in the following way; as the age of students is higher there is less effect from education on test result. My question is how can I test if the difference in odds ratios is significant, i.e. what test can I use in R ?
Here is a subset of the data:
student sex age testScore education ageGroup
1 1 10 0.12 1 1
2 1 8 0.08 1 1
3 2 16 0.85 0 3
4 2 20 0.12 0 3
5 1 22 1.02 0 4
6 2 18 0.98 1 3
7 1 19 0.46 1 3
8 1 16 0.83 0 3
9 2 12 0.26 1 2
10 2 14 0.46 0 2
I have been searching books and the web without success, can´t seem to find an example that I can relate to. Any suggestions would be appreciated.
sex
in the model and I guess you could investigate the interactioneducation ~ test results:age
. But, the easiest and most straightforward approach in terms of interpretation is to do a logistic model ofeducation ~ test results
for each age group. If you have a sample of data, or if you can create some fake data, similar to the actual ones, I'll be able to help you more. $\endgroup$age
on the dependent variableeducation
like you did above will tell you howage
affectseducation
whentest results
remain constant. This is not what you want to investigate here. $\endgroup$