# Correlation Coefficient when one variable includes value of another variable

Problem

I have two variables, let's say, Variable A and B. Variable A contains marks of all subjects and variable B contains marks of a specific subject. Number of student (sample) is 50. I have to calculate correlation between A and B using Pearson / Spearman depending on normality test.

What I have found?

I have read Article 1, Article 2 and some research papers regarding Correlation coefficient, specially this one. However, I have not got the answer of this question explicitly.

Including value of B in A and excluding value of B from A shows different results.

My Question

For each student, since A value (total marks) contains value of B (specific subject marks), should I exclude B value from A for each of the student at the time of correlation coefficient calculation?

• In other words, you have something like $A = Drama + Algebra + Virology + English$ that you want to compare to $B = English$?
– Dave
Oct 2 '19 at 18:47
• Can you clarify Variable A and Variable B? Is Variable A the sum of all the students' marks at different points in time and Variable B is just one student's marks at the same points in time? Oct 2 '19 at 18:47
• @SabbirAhmed Then you're not comparing $A$ and $B$. Yes, there a dependence between $A$ and $B$, but that's okay for correlation. What can get you in trouble is if observations of $A$ depend on other observations of $A$, such as if you're tracking how a particular student does over time, but that does not appear to be the case here. Just calculate $cor(A,B)$.
– Dave
Oct 2 '19 at 19:03
• Agree with @Dave. But, it also depends on the question you care about. If the question is "how much does a student's scores in other subjects correlate to their score in English?" then you should do $cor(A - B, B)$ Oct 2 '19 at 19:06
• @SabbirAhmed Is your goal to see how $English$ correlated with $Drama + Algebra + Virology$? Then you would do $cor(A-B,B)$. If you are interested in how $English$ is correlated with $Drama + Algebra + Virology + English$, the you want $cor(A,B)$.
– Dave
Oct 2 '19 at 19:12

The setup: there are 50 students, each measured on their scores in Drama class, Algebra class, Virology class, and English class. Call variable $$A$$ the sum of all four scores: $$A = Drama + Algebra + Virology + English$$. Call variable $$B$$ the English score.
We are potentially interested in two correlation problems. First is how the score in English class correlates with the overall score. In this case, we want to calculate $$cor(A,B)$$. Second is how the score in English class correlates with the scores in the other classes. In this case, we want to calculate $$cor(A-B,B)$$.
It is fine that the $$A$$ and $$B$$ variables are related (dependent). In fact, we kind of count on there being a relationship if we're bothering to calculate correlation!