BookmarkSubscribeRSS Feed
Aleres
Calcite | Level 5


Hello good day,

I am wondering how I should go about conducting a binomial test on financial herding ratios that have been calculated using the following code:

data a (drop = market buyer seller tdate);
set TMP1.ttsetrades(where = (market = 'First Tier'));
timePeriod = intnx("WEEK", tdate, 0);
format timePeriod date9.;
run;

proc sort data=a;

by ticker timePeriod client;
run;

data b(drop=tvol sign);
do until (last.client);
     set a;
     by ticker timePeriod client;
     stvol = sum(stvol, tvol*sign);
     end;
run;

data herding(keep=timePeriod ticker buyingClients totalClients herding);
buyingClients = 0; totalClients = 0;
do until(last.timePeriod);
     set b;
     by ticker timePeriod;
     buyingClients + (stvol > 0);
     totalClients + (stvol ne 0);
     end;
herding = buyingClients/totalClients;
run;

I came across an article that utilised the binomial testing to indicate whether the herding ratios found were statistically significant in indicating buy/sell herding within a stock.

The authors of the article infer that herding was "associated to the observation of a high value or low value of h by evaluating the probability to observe a number of buying firms equal or larger  than the empirically detected one under the binomial null hypothesis." (Lillo et al. 2008)

They tested using a significance level of 5%, ratios that generated probability values less that 5% were inferred to indicate herding.

My research thus far in binomial testing has led me to the following code, if binomial testing on the ratios is possible can you tell me if the code below is correct, thanks.

proc freq data=herding;

     tables Herding / Binomial (p=0.50) alpha=0.05;

     exact binomial;

     weight freq;

run;

2 REPLIES 2
SteveDenham
Jade | Level 19

I would use this code, provided I knew where the variable 'freq' in the weight statement came from.  I don't see it in the data steps, and it is critical to the analysis.

Steve Denham

1zmm
Quartz | Level 8

If the numerator of your fraction is BuyingClients and if the denominator of your fraction is TotalClients, the following PROC FREQ syntax may get you what you want: proc freq data=herding;   tables BuyingClients / Binomial (p=0.50) alpha=0.05;   exact binomial;   weight TotalClients; run; However, note that TotalClients EXCLUDES those with STVOL=0.  If a sizable proportion of your clients do have STVOL=0, then even though the number of TotalClients exceeds the number of BuyingClients, your results may be inaccurate.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1519 views
  • 0 likes
  • 3 in conversation