data=readtable('bidaskspread.csv');
%% we have data in the form of it, i=sec id and t=date
%% It can handle missing dates. 
%% I.e., it doesn't have to have a date and a missing value. There could be jumps in dates

alldates=unique(data.Date); %% we need the max of dates
T=size(alldates,1);
secids=unique(data.ID); %% that's how we need how many i's we have
N=size(secids,1);
%% x's

close=data.Close;
country=data.Country;
ba=data.BA;
trms=data.TRMS;
trms2=data.TRMS2;
avol=data.aVol;
sz=data.Size;

x=[avol,sz,trms2,trms];
y=ba;

FE=1; %% fixed effect. 1 FE 0 Pooled

lag=8;  %% lag for the NW s.e.

[beta,tstat,V_T,numobs,numgroup,rsquared]=panel_reg(data.Date,data.ID,y,x,FE,lag);

 
