[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I calculate linear regression?



PureBytes Links

Trading Reference Links

Aaron

Are you aware of the fact that this function considers the Independent
values to be y-values and the Dependent values to be x-values?  If you are
aware of this, then delete this message now.

Otherwise, what you want to do is create 2 parallel arrays of 20 values.  In
the Dependent array, put an x-value which indicates the position of the
corresponding y-value (not clear, I know, see example array).  Then in the
Independent array, put your data1 and data4 values.

Example:
1   data1[9]
1   data2[9]
2   data1[8]
2   data2[8]
3   data1[7]
3   data2[7]
4   data1[6]
4   data2[6]
.
.
.


Inputs : Ser1(Close of Data4), Ser2(Close of Data1);

Array: Xarray [20](0);
Array: Yarray [20](0);

For value2 = 1 to 10
begin
  Xarray[value2*2-1] = Ser1[10-value2];
  Xarray[value2*2] = Ser2[10-value2];
  Yarray[value2*2-1] = value2;
  Yarray[value2*2] = value2;
end;
Value1 = LinRegForecast_a(Yarray, Xarray, 20, 10);


The last parameter should be either 10 or 11 depending on whether you want
to calculate for the current bar or the next bar.

Kent


-----Original Message-----
From: Aaron Talsky <counsel1@xxxxxxxx>
To: omega-list@xxxxxxxxxx <omega-list@xxxxxxxxxx>
Date: Friday, May 12, 2000 2:50 PM
Subject: How do I calculate linear regression?


Anybody know how to calculate a 2 series linear regression?

The omega description left me clueless.  I took a stab with the following
code, but it does NOT work....what am I doing wrong?

TIA.





Inputs : IndPrice(Close of Data4), DepPrice(Close of Data1);

Array: IndPriceArray [10](0);
Array: DepPriceArray [10](0);

For Value2 = 1 to 10
begin
  IndPriceArray [Value2] = (IndPrice[Value2]);
  DepPriceArray [Value2] = (DepPrice[Value2]);
    end;
Value1 = LinRegForecast_a(IndPriceArray, DepPriceArray, 10, 0);