120 likes | 273 Views
Nonlinear Model by Gauss. An example Exercise 20(g) at the ending of Chapter 3 (page 112). new; library optmum; @ Data Generation Process @ beta1=2; alpha=0.5; x1=Rndn(100,1); u=2.5*Rndn(100,1); Y=alpha+EXP(beta1*x1)+u; T=rows(y); @ Sample Number @. C1=0.4; @ alpha @
E N D
Nonlinear Model by Gauss An example Exercise 20(g) at the ending of Chapter 3 (page 112)
new; • library optmum; • @ Data Generation Process @ • beta1=2; alpha=0.5; • x1=Rndn(100,1); u=2.5*Rndn(100,1); • Y=alpha+EXP(beta1*x1)+u; • T=rows(y); @ Sample Number @
C1=0.4; @ alpha @ • C2=1.5; @ beta 1@ • PRMTR_IN=C1~C2; • PRMTR_IN=PRMTR_IN'; • @ OLS estimation @ • @==================================================@ • {xout,fout,gout,cout}=optmum(&lik_fcn,PRMTR_in); • PRM_FNL=TRANS(xout); @ Estimated coefficients, constrained@
"Calculating Hessian..... Please be patient!!!!"; • hout0=hessp(&lik_fcn,xout); • hout=inv(hout0); • grdn_fnl=gradfd(&TRANS,xout); • Hsn_fnl=grdn_fnl*hout*grdn_fnl'; • SD_fnl =sqrt(diag(Hsn_fnl)); @Standard errors of the estimated coefficients@ • cls; • print "SSE is "; fout; • print "Estimated parameters are:"; prm_fnl'; • print "Standard errors of parameters are:"; sd_fnl'; • end;
PROC LIK_FCN(PRMTR1); • local prmtr,ppr,qpr,pr_vl,pr_val,likv,lik,pr_tr,prob_t,prob_dd,A,EN, • i,PAI,e,prob_,pr_trf,pro_,VAR,u1, • phi0,phi1,a1,a2,r0,r1,r2,r3,Lanta,b1,b2,b3,b4,T0,Id,d1,d2,d3,d4,g1,g2,g3,v,f1,f2,f3,f4,lage,beta1,beta2,beta3,sigma,alpha,SSE; • PRMTR=TRANS(PRMTR1); • LOCATE 15,1; PRMTR'; • /* DEFINE PARAMETERS */ • alpha=PRMTR[1,1]; • beta1=PRMTR[2,1];
SSE=0.0; • i=1; • DO UNTIL i>T; • e=(y[i,1]-alpha-EXP(beta1*x1[i,1])); • SSE=SSE+e^2; • i= i+1; • ENDO; • LOCATE 2,35;"SSE=";;SSE; • RETP(SSE); • ENDP;
Homework (option) • Use gauss program to estimate the model specification of “Q.20(h)”. • Download the program for “Q.20 (g)” from my personal web site. • Rewrite this program by yourself • Alpha=0.5; beta=0.8 and c=2.0