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

Re: [amibroker] r-squared and regression analysis



PureBytes Links

Trading Reference Links




Anthony,
 
What I was doing was simply citing what the help file gave as an 
example of using the correlation function to establish a trend of closing prices 
over a period of time. 
 
Your explanation probably reflects my poor understanding of the cum(1) 
function. When you write R2 = Correlation(cum(1),C,14)^2, does this mean 
you are correlating all the closing prices over the last 14 days (in other 
words, closing price as a function of time)? If so, how does this statement 
differ from R2 = Correlation(C,ref(C,-pds),pds)^2? 
 
In your next R2 statement, you wrote R2 = (P, C, periods)^2, where P 
had been assigned to the closing price of the NDX index. So, it looks 
like you are correlating the price of the index with the closing price of 
something else. I don't know what all the other stuff about alpha and beta have 
to do with that. I guess I'm having difficulty understanding your second R2 
statement. Can you enlighten me a bit? Thanks a lot.
 
AV
 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Anthony Faragasso 
  
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Friday, February 14, 2003 8:49 
  PM
  Subject: Re: [amibroker] r-squared and 
  regression analysis
  Al,Here is Metastocks:The following is the 
  formula for Metastocks r-squared:r_squared 
  =Pwr(Corr(Cum(1),C,14,0),2)AFL 
  Translation:R_squared=correlation(cum(1),C,14)^2;********************************************The 
  formula I posted is from my Alpha and Beta indicators located in 
  thelibrary.<A 
  href="">http://www.amibroker.com/library/formula.php?id=157//Alpha 
  AND Beta Indicators//Ver.1.00, 2/10/02//coded by Anthony 
  Faragasso//e-mail: ajf1111@xxxxxxxx//Insert your 
  Stock_index,Composite_index, S&P,etc.//as the **Base 
  Market**.MaxGraph=5;/***Base 
  Market************/Mkt="^ndx";//Must be enclosed in 
  "....."Quotations.P=Foreign(Mkt,"C",1);/**************************/Periods=14;//Set 
  the period of 
  Observation//****Beta***********************/Beta=(( Periods * 
  Sum(ROC( C,1) * ROC(P,1),Periods )) -(Sum(ROC(C,1),Periods) * Sum(ROC( 
  P,1),Periods))) / ((Periods *Sum((ROC(P,1)^2 ),Periods)) - (Sum(ROC(P,1 
  ),Periods)^2 
  ));/******************************************///*****Alpha*********************/Alpha=(Sum(ROC( 
  C,1) ,Periods) - ( Beta ) * Sum( ROC( P,1) ,Periods ) )/ 
  Periods;/******************************************//***R-Squared*****************/R2=Correlation(P,C,Periods)^2;/************************************/Graph0=Beta;Graph0Style=1;Graph1=Alpha;//Graph1=(LastValue(Highest(Graph0))/LastValue(Highest(Graph1))) 
  *Graph1;Graph1Style=1;/**R_squared 
  graphing*****/Graph2=r2;Graph2Style=1;Graph2Color=7;/*************************/Title=Name()+"  
  "+"ALPHA"+EncodeColor(colorBlue)+"("+WriteVal(Alpha,format=1.2)+")"+""+EncodeColor(colorBlack)+"  
  BETA"+EncodeColor(colorRed)+"("+WriteVal(Beta,format=1.2)+")"+""+EncodeColor(colorBlack)+" 
  R_SQUARED"+EncodeColor(colorYellow)+"("+WriteVal(r2,format=1.2)+")";/**Notes***///You've 
  got to start with r-squared, which is an//indicator of the validity of the 
  beta AND alpha//measures. Because the r-squared measures just 
  how//closely the Stock OR fund tracks the//index with which it is 
  being compared.//An r-squared of 1.0 indicates//A perfect match. 
  AND, in that case, you can//trust that the beta AND alpha measures 
  are//valid, too. But, the lower the r-squared, the less//reliable beta 
  AND alpha measures are.//"[Betas and alphas on] a Stock or  fund 
  with an r-squared that's below//0.50 are completely 
  meaningless.//Assuming the r-squared is, say, 0.75 OR higher, you can 
  move on to the//beta.Avcinci wrote:> Anthony, 
  Shouldn't it be: R2 = Correlation(P,> ref(P,-periods),periods)^2; ? Al 
  V.>>      ----- Original Message 
  ----->      From: Anthony 
  Faragasso>      To: 
  amibroker@xxxxxxxxxxxxxxx>      Sent: Friday, 
  February 14, 2003 8:10 PM>      Subject: Re: 
  [amibroker] r-squared and regression 
  analysis>       /***Base 
  Market************/>      Mkt="^ndx";//Must be 
  enclosed in "....."Quotations.>      
  P=Foreign(Mkt,"C",1);//Base 
  market>>      Periods=14;//Set the 
  period of Observation>>      
  /***R-Squared*****************/>      
  R2=Correlation(P,C,Periods)^2;>>>>      
  "sidleysh " wrote:>>      >  
  Does anyone know how to construct r-squared in AB? 
  There>      is an 
  r->      > squared function in MetaStock, 
  and I desperately need it>      to 
  construct>      > and adaptive MA based on 
  the AT3 from T&A>      
  >>      
  >>      
  >                    
  Yahoo! Groups 
  Sponsor>                              
  ADVERTISEMENT>>>      
  >>      > Post AmiQuote-related messages 
  ONLY to:>      
  amiquote@xxxxxxxxxxxxxxx>      > (Web 
  page:>      <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)>      
  >>      > Check group FAQ 
  at:>      
  >>      <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html>      
  >>      > Your use of Yahoo! Groups is 
  subject to the Yahoo! Terms>      of 
  Service.>>>>      Post 
  AmiQuote-related messages ONLY to:>      
  amiquote@xxxxxxxxxxxxxxx>      (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)>>      
  Check group FAQ at:>      <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html>>      
  Your use of Yahoo! Groups is subject to the Yahoo! Terms 
  of>      
  Service.>>>                    
  Yahoo! Groups 
  Sponsor                        
  ADVERTISEMENT>> Post AmiQuote-related messages ONLY to: 
  amiquote@xxxxxxxxxxxxxxx> (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)>> 
  Check group FAQ at:> <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html>> 
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
  Service.Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT









Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.