SHARE
TWEET

Untitled

a guest Jun 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for j in range(len(unique_firms)):
  2.  
  3.     for i in range(j+1,len(unique_firms)):
  4.  
  5.         firm1=unique_firms[i]
  6.         firm2=unique_firms[j]
  7.  
  8.         ix_firm1_dft=dft.firm==firm1
  9.         firm1_dft=dft.loc[ix_firm1_dft,['ticker','date','Forecast_error^2']]
  10.  
  11.         ix_firm2_dft=dft.firm==firm2
  12.         firm2_dft=dft.loc[ix_firm2_dft,['ticker','date','Forecast_error^2']]
  13.  
  14.         firms_dft=pd.merge(firm1_dft, firm2_dft, how='inner', on=['ticker','date'])
  15.  
  16.         di=firms_dft['Forecast_error^2_x']-firms_dft['Forecast_error^2_y']
  17.  
  18.         dbar=di.mean()
  19.  
  20.         gammas=statsmodels.tsa.stattools.acovf(di, unbiased=True)
  21.  
  22.         h=int(np.floor(np.power(len(di),1/3)+1))
  23.         denom=np.sqrt(gammas[0]+2*np.sum(gammas[1:h+1]))
  24.  
  25.         stat=dbar/denom
  26.         pval=2*(1-stats.norm.cdf(np.abs(stat)))
  27.         results[i,j]=stat
  28.         pvals[i,j]=pval
  29.         break
  30.     break
  31.      
  32. NameError: name 'statsmodels' is not defined
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top