# Subdividing a dataset

I know I can subdivide a dataset by socio-demographic factors such as gender, age, income level etc. and analyse the responses for each set separately and then compare the results.

For example, I am testing the relationship between Variable A (hours of study) and Variable B (exam marks), and I have a dataset made up of 400 students. I have subdivided the dataset by gender and have 220 male students and 180 female students. I can run Pearson correlation on hours of study and exam marks separately for male students and for female students.

While the above is fairly straight forward, my difficulty is in dividing my dataset by a factor that is not a socio-economic factor. I want to divide my dataset by two locations as follows:

• School (hours of study vs. exam marks)
• Home (hours of study vs. exam marks)

To do this, I included a simple statement in my questionnaire that asked "where do you generally do most of your assignments?". The answer is either "home" (coded as "1") or "school" (coded as "2").

This is a forced statement and I have deliberately made this nominal coding to avoid correlating it with the two variables I am testing. In my mind (which is not very statistically-orientated!), this statement functions like the socio-demograhic factors as above i.e. is a constant because I have deliberately coded it that way.

At the end of the day, and depending on my findings, I want to say something like "The relationship between hours of study and exam marks is stronger for students who completed their assignments in school".

Is this a risky approach?

• Actually, I can't feel where lies your apprehension. It is OK to construct any groups - not only sociodemographic. Perhaps you ought to make 3 groups: "Mostly at school" - "At school or at home" - "Mostly at home". Commented Sep 16, 2011 at 7:01
• @ttnphns. My apprehension is the fear of using a flawed method, so I thought of clarifying it; flawed methodology in the sense that there may be a four way correlation (study hours, exam marks, home and school). Thanks. Commented Sep 16, 2011 at 11:28
• @Adhesh Josh: To clarify a small but important point: study hours is one variable; exam marks is a second; and location (home vs. school) is a third. You have three, not four variables in this sentence. Commented Sep 17, 2011 at 12:35
• @rolando2 Thanks. I have deliberately coded "home" and "school" that way to avoid the above correlation. I just want to use them to divide my dataset. Commented Sep 17, 2011 at 21:26

I'm not sure what model you are running, but let's see if I can alleviate your fears.

You are looking at the relationship between reported hours of study and exam marks. You are looking at this relationship within four different groups.

1. Males who report mostly working at home.
2. Females who report mostly working at home.
3. Males who report mostly working at school.
4. Females who report mostly working at school.

You might say that you are stratifying or blocking by gender and location.

The sort of conclusion that you would like to make does not reference gender, so let's combine the groups.

1. Students who report mostly working at home.
2. Students who report mostly working at school.

Let's make an indicator variable for school and then regress exam marks on hours of study, location and their interaction.

$mark=\beta_0+\beta_1\times hours+\beta_2 \times school+\beta_3\times hours \times school$

If $\beta_1$ is significantly different from zero, you can say that there is a relationship between hours of study and exam marks.

If $\beta_2$ is significantly different from zero, you can say that students who work at school have higher/lower (higher if the sign of $\beta_2$ is positive) marks, on average, than students who work at home.

If $\beta_3$ is significantly different from zero, you could say that the relationship between hours of study and exam marks is stronger/weaker (stronger if $\beta_3$ has the same sign as $\beta_2$) for students who completed their assignments in school. But this is a bit unclear because people might use "strength" of a relationship to refer to $R^2$ rather than $\beta$, so I would try to say it more concretely.

I'm having trouble coming up with a good way to say it without implying causality, so here's a way that implies causality, just to give you an idea of what I mean by"concretely": "An additional hour of study has more/less of an impact on exam mark among students who report working mostly at school."

And plot all four of these groups on the same graph (maybe a color-coded scatterplot) if you haven't already.

• Thanks. I found my answer in your statement that I am stratifying or blocking my dataset by gender and location. From your answer and those of others, it appears that I am subdividing my dataset in an appropriate way. That is great! Commented Sep 17, 2011 at 11:04
• A color-coded scatterplot! Very interesting! I will ask a separate question. Commented Sep 17, 2011 at 11:38