## How to conduct a Binomial Distribution Test on Financial herding ratios

Occasional Contributor
Posts: 9

# How to conduct a Binomial Distribution Test on Financial herding ratios

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;
totalClients + (stvol ne 0);
end;
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;

Posts: 2,655

## Re: How to conduct a Binomial Distribution Test on Financial herding ratios

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

Regular Contributor
Posts: 152

## Re: How to conduct a Binomial Distribution Test on Financial herding ratios

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.

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