Error G0063: operator missing

when I run following codes, it always shows operator missing, however if i separate the codes into parts, i can get the results i need. I'm wondering how to make it run smoothly without cutting codes into several pieces?

 

/********************************************* load the data **********************************************/
LOAD data[50,3]=main.txt;
r = data[.,1]; 
d = data[.,2]; 
dp = data[.,3];
dv=r~d~dp
/******************************* parameters **************************************************************/
q_nw = 2;
/*******************************************************************************************************************/
PROC(10)=VAR_REST(YY,XX,Q_NW); /* Restricted VAR */

LOCAL T,N,X,K,Y,Z,W_I,D,B,EHAT,EPSLON,AUX1,AUX2,R2,AR2,G,S_W,S_NW,J,GAMMA_J,AVCOVB_NW,SEB_NW,TSTATB_NW,PVALUES_NW,
BETA,T_BETA,P_BETA,VCOV_EHAT;

/* Definition of variables */

YY=LAGN(YY,-1);
YY=TRIMR(YY,0,1);
XX=TRIMR(XX,0,1);
T=ROWS(YY);/* number of observations*/
X=ONES(T,1)~XX; /* Number of forecasting variables (including a constant) */
K=COLS(X);
N=COLS(YY); /* N is the number of variables in the VAR  */

/* Calculations */
Y=RESHAPE(YY',1,N*T)';
Z=EYE(N).*.X; /* data matrix of the regressors (NTxNK) */
W_I=EYE(N*K); /* weighting matrix for first stage GMM (NKxNK) */
D=(1/T).*(EYE(N).*.(X'X));/* D matrix; equal to dgT(b)/db (NKxNK) */D=(1/T).*(EYE(N).*.(X'X));
B=(EYE(N).*.(INVPD(X'X)*X'))*Y; /* Simplified formula (applied to this case) for GMM estimator (NKx1) */
EHAT=Y-Z*B; /* stacked vector with residuals (NTx1) */
EPSLON=RESHAPE(EHAT,N,T); /* Auxiliar matrix. Transforms the vector of residuals into a matrix,
where each column corresponds to the t th observation, t =1,...,T (NxT) */
VCOV_EHAT=VCXS(EPSLON');
AUX1=(EPSLON'-MEANC(EPSLON')')'(EPSLON'-MEANC(EPSLON')');
AUX2=(YY-MEANC(YY)')'(YY-MEANC(YY)');
R2=1-DIAG(AUX1)./DIAG(AUX2);
AR2=ONES(N,1)-(ONES(N,1)-R2).*((T-1)/(T-K));
G=(EPSLON')*~X;
S_W=(1/T).*G'G;

/******************************************************************************************
 Newey-West standard errors 
******************************************************************************************/

S_NW=ZEROS(N*K,N*K); 
   J=1;
   DO WHILE J<=Q_NW-1;
      GAMMA_J=(1/T).*G[1:T-J,.]'G[1+J:T,.]+(1/T).*G[1+J:T,.]'G[1:T-J,.];
      S_NW=S_NW+(1-J/Q_NW).*GAMMA_J;                   
   J=J+1;
   ENDO;
S_NW=S_W+S_NW;

AVCOVB_NW=(1/T).*(INVPD(D)*S_NW*INVPD(D));
SEB_NW=SQRT(DIAG(AVCOVB_NW));
TSTATB_NW=B./SEB_NW;
PVALUES_NW=2*CDFNC(ABS(TSTATB_NW));

BETA=RESHAPE(B,N,K);
T_BETA=RESHAPE(TSTATB_NW,N,K);
P_BETA=RESHAPE(PVALUES_NW,N,K);

RETP(T,N,R2,AR2,B,BETA,T_BETA,P_BETA,AVCOVB_NW,VCOV_EHAT);
ENDP;
/******************************************* ANALYSIS***********************************/
rho = 1/(1+exp(meanc(dp))); "rho ="; rho; {T,N,R2,AR2,B,BETA,T_BETA,P_BETA,AVCOVB_NW,VCOV_EHAT}=VAR_REST(dv,dp,q_nw); "number of observations"; T; "number of variables in the VAR"; N; "R2 for VAR equations"; R2; "adjusted R2 for VAR equations"; AR2; "VAR coefficients"; B; "VAR coefficients"; BETA; "t-statistics for VAR coefficients"; T_BETA; "p-values for VAR coefficients"; P_BETA; "var-cov matrix for vAR coefficients"; AVCOVB_NW; avcovb=AVCOVB_NW[2 4 6,2 4 6]; "var-cov matrix for vAR slope coefficients"; AVCOVB; "var-cov matrix for vAR residuals"; VCOV_EHAT; b_r=beta[1,2]; b_d=beta[2,2]; phi=beta[3,2]; "b_r"; b_r; "b_d"; b_d; "phi"; phi;
 
b_ri = 1-rho*phi+b_d; b_di = -1+rho*phi+b_r; phi_i = (1+b_d-b_r)/rho; "implied b_r"; b_ri; "implied b_d"; b_di; "implied phi"; phi_i; jacob = 0~1~(-rho)|1~0~rho|(-1/rho)~(1/rho)~0;
varcov = jacob*avcovb*jacob'; "variance-covariance matrix for the implied coefficients"; varcov; tstat = (b_ri|b_di|phi_i)./sqrt(diag(varcov)); "t-statistics for implied coefficients"; tstat;
 
"---------------------------long-run coefficients-----------------------------------"; b_lr = b_r/(1-rho*phi); b_ld = b_d/(1-rho*phi); "b_lr"; b_lr; "b_ld"; b_ld; "b_lr-b_ld= "; b_lr-b_ld;
jacob = (1/(1-rho*phi))~0~((rho*b_r)/((1-rho*phi)^2))|0~(1/(1-rho*phi))~((rho*b_d)/((1-rho*phi)^2))
varcov = jacob*avcovb*jacob'; "variance-covariance matrix for the long-run coefficients"; varcov;
"null hypothesis: b_lr=0, b_ld=-1";
aux1 = b_lr|(b_ld+1);
tstat = aux1./sqrt(diag(varcov));
"t-statistics for the long-run coefficients"; tstat; "null hypothesis: b_lr=1, b_ld=0"; aux1 = (b_lr-1)|b_ld; tstat = aux1./sqrt(diag(varcov)); "t-statistics for the long-run coefficients"; tstat;

4 Answers



0



also how to make a loop if I want to redo following estimation by changing '5'  to 10, 15 and 20?

/* implied VAR(1) estimates */***********************/
b_lr = b_r*(1-(rho^5)*(phi^5))/(1-rho*phi); b_ld = b_d*(1-(rho^5)*(phi^5))/(1-rho*phi); b_ldp = (rho^5)*(phi^5); ident = b_lr-b_ld+b_ldp;
aux1 = -5*b_r*(rho^5)*(phi^(5-1))*(1-rho*phi)+rho*b_r*(1-(rho^5)*(phi^5)); aux2 = -5*b_d*(rho^5)*(phi^(5-1))*(1-rho*phi)+rho*b_d*(1-(rho^5)*(phi^5)); aux3 = (1-rho*phi)^2; aux_br = aux1/aux3; aux_bd = aux2/aux3;

"b_lr"; b_lr; 
"b_ld"; b_ld;
"b_ldp"; b_ldp;

jacob = ((1-(rho^5)*(phi^5))/(1-rho*phi))~0~aux_br|0~((1-(rho^5)*(phi^5))/(1-rho*phi))~aux_bd|0~0~5*(rho^5)*(phi^(5-1)); varcov = jacob*avcovb*jacob'; tstat = (b_lr|b_ld|b_ldp)./sqrt(diag(varcov));

"t-statistics for 5 years horizon coefficients"; tstat;
"R2 for VAR equations"; R2;


0



It seems that you are missing a semi-colon towards the top on the line that reads:

dv=r~d~p

Below is an image of the error that I receive from GAUSS:
operator_missing
There is also another line missing a semi-colon further down--the second line after "---------------------------long-run coefficients-----------------------------------";

aptech

1,338


0



thanks for helping on this issue.

I also did another analysis after "--------long-run coefficients--------------------------------", but Gauss keep running without showing any results, I must did something stupid again..

"---------------------------K-year decompositions-----------------------------------";

Ku = 20;

b_lrk = zeros(Ku,1);

b_ldk = zeros(Ku,1);

b_ldpk = zeros(Ku,1);

identk = zeros(Ku,1);

t_lrk1 = zeros(Ku,1);

t_ldk1 = zeros(Ku,1);

t_ldpk1 = zeros(Ku,1);

t_lrk2 = zeros(Ku,1);

t_ldk2 = zeros(Ku,1);

t_ldpk2 = zeros(Ku,1);

b_lrkd = zeros(Ku,1);

b_ldkd = zeros(Ku,1);

b_ldpkd = zeros(Ku,1);

t_lrkd = zeros(Ku,1);

t_ldkd = zeros(Ku,1);

t_ldpkd = zeros(Ku,1);

identkd = zeros(Ku,1);

K=1;

do while K<=Ku;

/* implied VAR(1) estimates */

b_lr = b_r*(1-(rho^K)*(phi^K))/(1-rho*phi);

b_ld = b_d*(1-(rho^K)*(phi^K))/(1-rho*phi);

b_ldp = (rho^K)*(phi^K);

ident = b_lr-b_ld+b_ldp;

aux1 = -K*b_r*(rho^K)*(phi^(K-1))*(1-rho*phi)+rho*b_r*(1-(rho^K)*(phi^K));

aux2 = -K*b_d*(rho^K)*(phi^(K-1))*(1-rho*phi)+rho*b_d*(1-(rho^K)*(phi^K));

aux3 = (1-rho*phi)^2;

aux_br = aux1/aux3;

aux_bd = aux2/aux3;

jacob = ((1-(rho^K)*(phi^K))/(1-rho*phi))~0~aux_br|0~((1-(rho^K)*(phi^K))/(1-rho*phi))~aux_bd|0~0~K*(rho^K)*(phi^(K-1));

varcov = jacob*avcovb*jacob';

tstat1 = (b_lr|b_ld|b_ldp)./sqrt(diag(varcov));

tstat2 = ((b_lr-1)|(b_ld+1)|(b_ldp-1))./sqrt(diag(varcov));

b_lrk[K,1] = b_lr;

b_ldk[K,1] = b_ld;

b_ldpk[K,1] = b_ldp;

identk[K,1] = ident;

t_lrk1[K,1] = tstat1[1,1];

t_ldk1[K,1] = tstat1[2,1];

t_ldpk1[K,1] = tstat1[3,1];

t_lrk2[K,1] = tstat2[1,1];

t_ldk2[K,1] = tstat2[2,1];

t_ldpk2[K,1] = tstat2[3,1];

Endo;



0



I made a new question to answer your question about the loop not ending which you can find here. It is generally better to start a new thread for a question about a different problem even if it is related, because it makes it easier for others in the future to find an answer to their problem if they encounter one like yours.

aptech

1,338

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy