Do you want to get informed about new posts via Email?

Topic of confusion with calculating an auto correlation coefficient?

Author: mikesblack

Creation Date: 4/4/2010 11:55 AM

I alluded to this in my last post; however perhaps it requires it's own topic/ post.

Auto correlation formula=

Summation (y-avg(y))* (y-1-(avg(y))/ Summation ((y-avg(y)(y-avg(y))

given y= Close, look back 100

Simple enough; however the issue is being able to use the average of today's bar and not the moving average while calculating the differences of the closes of last 100 bars. OR

Sum of Close( [Bar-100....Bar]-SMA.Series(Close,100))

( I can post the following to another topic thread, but it is related.)

2. In the Standard deviation formula, is the calculation of mean squared deviation from the moving average of present or the moving average of days past?

Sorry if the question/s seems awkward. Please let me know if I need to clarify. Thank you

Auto correlation formula=

Summation (y-avg(y))* (y-1-(avg(y))/ Summation ((y-avg(y)(y-avg(y))

given y= Close, look back 100

Simple enough; however the issue is being able to use the average of today's bar and not the moving average while calculating the differences of the closes of last 100 bars. OR

Sum of Close( [Bar-100....Bar]-SMA.Series(Close,100))

( I can post the following to another topic thread, but it is related.)

2. In the Standard deviation formula, is the calculation of mean squared deviation from the moving average of present or the moving average of days past?

Sorry if the question/s seems awkward. Please let me know if I need to clarify. Thank you

Sorry Fellas, I hope that you understand my question. Please let me know if I need to clarify. BTW I hope you guys had a nice Easter. :)

It boils down to understanding how to fix average on the present bar while summing the deviations from the past bars. I really appreciate your help.

It boils down to understanding how to fix average on the present bar while summing the deviations from the past bars. I really appreciate your help.

QUOTE:What is the average of today's bar if it isn't the moving average?

issue is being able to use the average of today's bar and not the moving average

Maybe the illustrations herewill help?

Yes, Let me state it this way as I ended up confusing myself re reading my question.

Auto correlation formula=

Summation (y-avg(y))* (Close-1-(avg(y))/ Summation ((y-avg(y)(y-avg(y))

Forget the details of the formula. What I want you to focus on is the Summation operation of y- avg(y) for the individual deviations.

Given a time line: t-100,t-99,t-98,...t, t+1,t+2 etc., At time t(present) I will be able to calculate an average , SMA.Series(y,100). For simplicity let's call that average TA.

Now I want to calculate a sum of ((y, t-100)- TA) through (Y t-TA).

So there will be 100 deviations in the summation, based on**today's average but history's Ys**.

When I started to write this formula I simply used the Sum of Close-(SMA.Series(Close,100)for the past 100 bars.

Perhaps you can see my dilemma as the sum of the deviations (Close- Avg) were calculated on an average that was moving and not the average I needed to calculate on, the present. I was calculating a sum from history's average and history's Close.

Moving on to Standard deviation, I want to know if the Squared deviations in the formula are being calculated from past variables and a fixed average or does it calculate the way I was writing about?

I sure hope that makes better sense. Sorry that I might be making this confusing.

Auto correlation formula=

Summation (y-avg(y))* (Close-1-(avg(y))/ Summation ((y-avg(y)(y-avg(y))

Forget the details of the formula. What I want you to focus on is the Summation operation of y- avg(y) for the individual deviations.

Given a time line: t-100,t-99,t-98,...t, t+1,t+2 etc., At time t(present) I will be able to calculate an average , SMA.Series(y,100). For simplicity let's call that average TA.

Now I want to calculate a sum of ((y, t-100)- TA) through (Y t-TA).

So there will be 100 deviations in the summation, based on

When I started to write this formula I simply used the Sum of Close-(SMA.Series(Close,100)for the past 100 bars.

Perhaps you can see my dilemma as the sum of the deviations (Close- Avg) were calculated on an average that was moving and not the average I needed to calculate on, the present. I was calculating a sum from history's average and history's Close.

Moving on to Standard deviation, I want to know if the Squared deviations in the formula are being calculated from past variables and a fixed average or does it calculate the way I was writing about?

I sure hope that makes better sense. Sorry that I might be making this confusing.

this may help. an implementation of the Correlation Coeff (not auto correlation, but similar issues with using a moving average)

CODE:

Please log in to see this code.

ALGLib has probably all the statistical function that you could ever need. Why redo what's already done? I've already compiled it and put it here, drop it in your WL install folder, and add "using alglib;"

For more info and docs, see here: http://www.alglib.net/.

You'll have to do some data massaging to pass the data with the proper types, so maybe that's enough trouble to add the functions that you need to be compatible with DataSeries.

For more info and docs, see here: http://www.alglib.net/.

You'll have to do some data massaging to pass the data with the proper types, so maybe that's enough trouble to add the functions that you need to be compatible with DataSeries.