0
$\begingroup$

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.

Reproducible example:

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)

I get:

# 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?

$\endgroup$
  • $\begingroup$ What else is there? $\endgroup$ – user2974951 Sep 26 '18 at 6:09
  • $\begingroup$ It seems to me like this is "cheating", because since there are so many points with heart rate equal to ~60, adding 20 points with heartrate = 150 will not have any effect and I can either mark them as "active" or "inactive" and I would not be able to detect a difference in the way I described above. $\endgroup$ – Omry Atia Sep 26 '18 at 6:22
  • $\begingroup$ I don't understand, why would you mark the 150 values in the same category as the 60 values? The two are clearly different? $\endgroup$ – user2974951 Sep 26 '18 at 7:15
  • $\begingroup$ I am just trying to see what would happen if I made a mistake - would this method be able to detect it? $\endgroup$ – Omry Atia Sep 26 '18 at 7:18
  • $\begingroup$ I don't understand... could you expand your question adding exactly what you want to do and why, what are you trying to show, what conclusions are you asking about, how would adding these values affect mean and sd? $\endgroup$ – user2974951 Sep 26 '18 at 7:48
1
$\begingroup$

I have used your data files

transfer.sh/xuf6M/HR.csv
transfer.sh/kW6lb/Steps.csv

and in order to match the different time stamps I took averages over 3 minute intervals.


This can be turned into the following graphs:

example plots

You could say then:

  • No activity: HR of 80 or lower only occur below 5 steps per minute
  • Low activity: HR of 80-100 do not occur much in activities with above 20 steps per minute
  • Medium activity: HR of 100-140 occur in activities with above 20 steps per minute
  • High activity or anomalies: HR above 140 seem to not occur in activities with above 20 steps. These might be other activities than walking that are harder than walking (e.g. running, cycling)

So in this way you calibrate heart rates according to stepsizes. And you should not consider the heart rates above > 150 as inactive just because you did not measure steps during that period. Logically you should have $$HR_{\text{no activity}} < HR_{\text{low activity}} < HR_{\text{medium activity}} < HR_{\text{high activity}}$$


In your case using confidence intervals seems not right to me. You could mathematically express something like the average heart rate for a certain activity and express something like a confidence interval for it, but the question is whether it makes sense (aside from your question about the proper categorization of activity and it's influence on the confidence intervals). (1) The heart rates do not follow an ordinary distribution for which you can express the confidence intervals of the mean/average (e.g. using a t-distribution for the mean when the data is Gaussian distributed) (2) The average/mean heart rate may not be the relevant parameter.


Possibly plots like below may help you as well:

multiple days

Here the points are connected and the lines are a path in time (succeeding points in time are connected). So you can see that the high >140 heart-rates are due to the day 1 and day 2. You can also see that these points are in a loop with some walking or running, so it seems that there has been some mixture of walking and other activities.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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