BookmarkSubscribeRSS Feed
bd_user_10
Quartz | Level 8

Hi,

I am trying to calculate the Probability of Informed Trading (PIN) using the codes provided by WRDS. However, i am getting some warnings and error messages in running the codes. Here are samples of warnings and error messages:

 

ERROR: Execution Errors for _OBS_= 209 :
ERROR: There are references to missing variables when the program code is executed for _OBS_= 209
WARNING: Your program statements cannot be executed completely.
WARNING: In a total of 312 calls an error occurred during execution of the program statements. NLP attempted to recover by using a
shorter step size.

 

The codes that i am using are the followings:

 

options ls=132 ps=max nocenter nodate nonumber fullstimer;

 

proc sort data=buysell; by RIC; run;

 

/*--------------------------------------------------------------------*/
/* This is the procedure used to maximize the log-likelihood function specified below. */


/* This particular factorization of the log-likelihood function appears in the paper Easley, David, Robert F. Engle, Maureen O'Hara, and Liuren Wu, 2001, "Time-Varying Arrival Rates of Informed and Uninformed Trades", AFA 2002 Atlanta Meetings, Available at SSRN: http://ssrn.com/abstract=294870 */
/*--------------------------------------------------------------------*/

 

proc nlp data=buysell noprint out=work.pinest (keep = RIC ALPHA ETA MU);
by RIC;
max loglik;
decvar ALPHA, DELTA, ETA, MU;
M = min(buys,sells) + max(buys,sells) / 2.0 ;
x = eta / (mu + eta) ;
bounds 0.0 < eta mu, 0.0 <= alpha delta <= 1.0 ;

 

loglik = -2.0 * eta + M * log(x) + (buys + sells) * log(mu + eta) +
log( alpha * (1.0 - delta) * exp(-1.0 * mu) * (x ** (sells - M )) +
alpha * delta * exp(-1.0 * mu) * (x ** (buys - M)) +
(1.0 - alpha) * (x ** (buys + sells - M)) ) ;

 

run;

 

proc sort data = work.pinest nodupkey;
by RIC;
run;

 

data work.pinest; set work.pinest;
PIN = alpha * mu / (alpha * mu + 2.0 * eta) ;
label pin = 'Probability of informed trading' ;
format pin 5.3 ;
run;

 

I have no clues how to resolve the issue. Can someone please help? I have added sample data in the attached data section. Thanks.

2 REPLIES 2
ballardw
Super User

Have you looked at observation 209 in your data set?

If either mu or eta have a missing value then x = eta / (mu + eta) ; is performing a divide by missing value as (mu + eta) would be missing.

 

If eta=0 then x would be 0 and the LOG(x) is undefined in the LOGLIK calculation.

Similar log( alpha * (1.0 - delta) * exp(-1.0 * mu) * (x ** (sells - M )) is undefined if delta=1: 1-delta would be 0 and the 0 is multiplied by the other bits so the result is 0 and Log(0) again

bd_user_10
Quartz | Level 8
Hi ballardw,
Thanks for your reply! Please excuse me for being a novice here. There are no missing values in the main dataset. Missing values are generated while the program code is executed. Is there any way to drop those newly generated missing values while the program code is executed?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 695 views
  • 0 likes
  • 2 in conversation