Basic Statistics Functions
Author: gena1
Creation Date: 9/3/2009 11:49 AM
profile picture

gena1

#1
Hello Forum and WL support,

I am trying to find the functions that would take values from 2 different series.

INTERCEPT(REGRESSION)
COVARIENCE
SLOPE (REGRESSION)

The only function I found that works on two seriese was CORRELATION. I suppose I could "reverse" what I need from CORRELATION AND STDDEV.. Or try to write the function from scratch. I thought I should enquire here if anything like that already exists, before I start to reinvent the wheel.

Could anyone please point me to the easy way to get the calculations listed above.

Thank you
profile picture

Eugene

#2
Linear regression slope do exist in WL5 - look up LinearReg and LinearRegSlope on the Indicators list.

As to the others, maybe this post would be helpful?

Open Source .Net math libraries
profile picture

gena1

#3
Eugene,

Thank you for reply.

As I wrote in my post: "The only function I found that works on two series was CORRELATION"
Unfortunately the native LinearReg and LinearRegSlope functions that you refer to, can only analyze one series.

I just realized that this is .net area. Can I move this topic to wl4? if not, lease answer while keeping in mind that the question is for wl4.
Apology for inconvenience.
profile picture

Eugene

#4
Topics can't be moved. For WL4, you can try searching the old Code Library - that's all I can say. However, now I realize you're talking about massaging two different series of data... and that makes me wonder: correlation aside, what is it? For instance, what's the slope of two series?
profile picture

gena1

#5
QUOTE:
"what's the slope of two series?"


Beta of a stock ,for example, is a slope in "stock to market" liniar regression. It estimates change in stock per unit change in market.
This really statistics 101, and the topic was covered in evry finance/investment and a couple of accounting classes I took in collage. From what I hear, the only majors who do not use data analysis are the liberal arts. I am sort of in disbelieve that WL does not have anything native to cover this area. I still think that wl is a superb tool. I guess I will try to write it myself. Please let me know if anyone already wrote this function and would like to share it.
profile picture

Eugene

#6
Now I see, it's a matter of definitions. For instance, Beta is implemented for both WL4 and WL5 (Community.Indicators). Perform a forum search, and if nothing comes out, you'll need to create it from scratch.
profile picture

gena1

#7
Thanks Eugene.

The Beta function works
profile picture

sf631

#8
Similar question. I'm trying to calculate the slope of a rolling linear regression (ie the linear regression of the past n periods) for an indicator as part of a mean reversion strategy. I've implemented the LinRegSlope from Community.Indicators, which seemed to be exactly what I wanted, however it seems to be failing me.

Below is the code I have written, and it compiles & gives results. However the slope coefficients are tiny and do not seem to produce logical results. what I'd like is to have periods of time where there's a strong regression to the mean tendency with the indicator to produce a strongly positive Reversion Strength signal and for times where the regression is weak, to get a more neutral or negative one.

Thanks for any help



CODE:
Please log in to see this code.