Say I have heartrate data at every minute during the day. I suspect the person was exercising at different points during the day (based on some other data), and now I want to examine my hypothesis. I mark these periods as "Active" and the others as "Inactive", and calculate the mean and confidence interval of the heart rate. They are significantly different.
Now, there are much more "inactive" points than "active". The confidence interval takes this into account by dividing by the square root of
n, but is this enough?
To make this point a bit clearer, lets say most of the day the heart rate was 60, for 30 minutes it was 100 and for 15 more minutes it was 150. Now, I can mark the 150bpm as either "active" (and join them to the 100bpm), or inactive and join them to the 60 bpm. if I mark them as inactive, I would still arrive at the same conclusion since they would hardly affect the mean and sd.
Case 1: I WRONGLY classify the 150bpm as inactive (say I had another source of information which recognized this period as inactive):
df <- data_frame(HeartRate = c(rep(60, 300), rep(100, 10), rep(110, 10), rep(150,10)), IsActive = c(rep(FALSE, 300), rep(TRUE, 10), rep(TRUE, 10), rep(FALSE, 10)))
And calculate the mean and CI:
df %>% group_by(IsActive) %>% summarise(MeanHR = mean(HeartRate), low = (-1*qnorm(0.975) * sd(HeartRate)/sqrt(length(HeartRate)))/12, high = (qnorm(0.975) * sd(HeartRate)/sqrt(length(HeartRate)))/12)
# A tibble: 2 x 4 IsActive MeanHR low high <lgl> <dbl> <dbl> <dbl> 1 FALSE 62.9 -0.148 0.148 2 TRUE 105 -0.187 0.187
Case 2: I now classify the 150 bpm as active, and get the same statistical behaviour:
# A tibble: 2 x 4 IsActive MeanHR low high <lgl> <dbl> <dbl> <dbl> 1 FALSE 60 0 0 2 TRUE 120 -0.655 0.655
So although I initially classified the 150bpm as inactive, due to the size of the larger group this error gets "swallowed".
Would there be a way to correct for the fact that the 60 bpm appear many times?