Calculate the tendency of a set of samples I develop an application in which i constantly get samples of heart pulse.
I defined an interval of t seconds.
In each t seconds I have n samples.
In every interval, I want to calculate the tendency of those n samples. For example, lets say I have n = 5, and I have samples with values {70, 88, 95, 103, 115}. I want to recognize I have a growth in the heart pulse, and I want to have some measure for the rate of grows/decrease/almost no change.
I thought on two approaches for solving this problem.


*

*I calculate the linear approximation for the n samples using linear regression by applying least squares implemented by the normal equations. (I treat each sample as two coordinates vector with x coordinate as time and y coordinate as heart pulse). I get from the normal equations a linear function of the form y = mx+b and my measure for the tendency is the slope, i.e. the m value.

*The second approach is to calculate the correlation (pearson's correlation) between vector x and vector y when x is the time and y is the heart pulse.
I'm asking which approach do you think is better for my problem (determining the tendency of heart pulses). Or, do you have a better algorithm for solving this problem?
 A: Heart rates vary in a cyclic pattern that is driven by the respiratory rate. Inspiration causes decreased filling of the left atrium and the heart rate increase to maintain cardiac output. You need to detrend the respiratory influence.
Because the instantaneous heart rate is just the inverse of the RR interval, you do not need to wait for 15 or 20 seconds to calculate a rate. You can just use 1/RR-interval. Then you can calculate a probability that the HR is increasing by noticing when the RR interval has been below the detrended mean value for more than 8 RR intervals. (That's a simple binomial calculation. The probability that 8 successive intervals will be below the mean (actually the median) value is just 0.5^5 = 0.0315. You might be able to enhance this by taking into account how far below the median the RR intervals really were, but then you would also need to be careful how you interpreted the influence of PVCs with their much shorter RR-intervals. But if 3 successive RR intervals were below 0.0066 seconds (at a rate above 150/min) you would have a strong signal that the person had either "V-tach" or had paroxysmal atrial tachycardia.
(I'm only a masters-level statistician, epidemiologist actually, but am also a physician so I might know a bit about the domain-specific issues).)
A: The second approach based on a correlation won't tell you anything about the direction of the trend.  At its base it is the same as the first approach - fits a simple linear regression - but it is giving you one of the least useful bits of output from fitting that model.  So of the two, the first approach, based on linear regression, is definitely the best.  
However, it will still be highly flawed.  
First, the linear model seems unlikely to be appropriate.  What happens when the heart rate starts low, goes high, and returns to a low point?  Your regression will show a horizontal line.
Second, even if were, ordinary least squares as interpreted in a usual regression situation (with standard F statistics and standard errors of coefficient estimates etc) gives misleading estimates with time series data.  This is because classic regression modelling inference assumes the observations are independent and identically distributed, which is obviously not the case - each observation in a short time period such as this adds only limited extra information to what you got from the previous observation/s.
A recommendation on a better approach would depend more on what your underlying interest is in the trend or tendency.  A locally weighted scatterplot smoother to describe the trend may  be a possible solution if it is a matter of describing the trend in each time window - or it may not, depending on what you're interested in.
