Simple question about printing out results

In the below, an input of the procedure ols is printr. And it is set to 1 before the procedure.

Why do I need printr and it in the procedure??

new;
cls;
library pgraph;
pqgwin many;

/* step 1:DGP */
b1 = 1;
b2 = 2;
b0 = 0|0;
k = 2;
sig2 = 4;
Tru_b = b1|b2;
T = 2000;
x2 = rndu(T,1)*5;
emat = rndn(T,1)*sqrt(sig2);
ymat = b1 + x2*b2 + emat;
/* step 2:Estimation (OLS) */
X=ones(T,1)~x2;
Y=ymat;
printr = 1;
{bhat,Yhat,residual,sig2hat,stde,t_val,p_val,F_val,R2,R2_,SC,AIC} = ols1(Y,X,printr);

title("Y and fitted Y");
xy(T,Ymat~Yhat);
title("Error term and Residuals");
xy(T,emat~residual);
end;

proc(12) = ols1(Y,X,printr);
local k,T,bhat,Yhat,ehat,sig2hat,varbhat,stde,p_val,t_val,R,R2_,L,gam,F_val,mY,TSS,RSS,R2,SC,AIC;
T=rows(Y);
k=cols(X);
bhat =inv(X'*X)*X'*Y;
Yhat = X*bhat;
ehat = Y - Yhat;
sig2hat = ehat'ehat/(T-k);
varbhat = sig2hat*invpd(X'X);
stde = sqrt(diag(varbhat));
t_val = (bhat-b0)./stde;
p_val = cdftc(t_val,T-k);
mY = meanc(Y);
TSS = Y'Y - T*mY^2;
RSS = ehat'ehat;
R2 = 1-RSS/TSS;
R2_ = 1 - (T-1)*RSS/(TSS*(T-k));
SC = ln(RSS/T) - k/T*ln(T);
AIC = ln(RSS/T) - 2*k/T;

/* Test H0: all coefficients are zero. Refer to the section 4 for details */
R = eye(k);
L = k; @ # of restrictions @
gam = zeros(k,1);
F_val = (R*bhat - gam)'invpd(R*invpd(X'X)*R')*(R*bhat-gam)/(L*sig2hat);

if printr == 1;
/* Results */
"Parameter Estimates S.E. t-value p-value"
seqa(1,1,k)~bhat~stde~t_val~p_val;

"S.E. of regression" sqrt(sig2hat);
"F-value" F_val;
"p-value(F)" cdffc(F_val,L,T-k);
"R2" R2;
"Adjusted R2" R2_;
"SC" SC;
"AIC" AIC;

endif;

retp(bhat,Yhat,ehat,sig2hat,stde,t_val,p_val,F_val,R2,R2_,SC,AIC);
endp;

 

 

 

 

 

 

 

 

 

 

1 Answer



0



The procedure you posted allows the user to control whether the parameter estimates, standard error and some other statistics are printed to the screen when the procedure is run.

You pass it a 1 if you want it to print this output to the GAUSS program input/output window or a 0 if you do NOT want the statistics displayed.

Since you have the source code, you could remove the need to pass in the 'printr' input. It is not part of the GAUSS standard package or a GAUSS application module, so it would not cause you problems there.

aptech

1,773

Your Answer

1 Answer

0

The procedure you posted allows the user to control whether the parameter estimates, standard error and some other statistics are printed to the screen when the procedure is run.

You pass it a 1 if you want it to print this output to the GAUSS program input/output window or a 0 if you do NOT want the statistics displayed.

Since you have the source code, you could remove the need to pass in the 'printr' input. It is not part of the GAUSS standard package or a GAUSS application module, so it would not cause you problems there.


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.