/* DENPLOT.GPR: procedure to compute univariate kernel density estimator at a vector of points, and then plot results calls kden.g to compute kernel density estimate at points to be plotted John Rust, University of Maryland, October 2006 inputs: x vector of points to compute kernel density at for plotting data vector of data points used to compute kernel density implicit global inputs kerneltyp: type of kernel density to use in the density estimation epanechnikov gaussian */ load qmc,smc; data=qmc[.,2]; x=seqa(-10,.1,161); nden=zeros(161,1); sig=meanc(smc[.,2]); i=1; do until i>rows(x); nden[i]=exp(-((x[i]-meanc(data))^2)/(2*sig*sig))/(sqrt(2*pi)*sig); i=i+1; endo; kde=kden(x,data); library pgraph; graphset; _pdate=""; _pmsgstr=""; _pmsgctl=0; #IFUNIX let v = 100 100 640 480 0 0 1 6 15 0 0 2 2; wxy = WinOpenPQG(v,"XY Plot","XY"); call WinSetActive(wxy); #ENDIF _pmsgstr="Number of obs "$+ftos(rows(data),"lf",6,0)$+"\000"$+ "Mean "$+ftos(meanc(data),"lf",6,3)$+"\000"$+ "Std deviation "$+ftos(stdc(data),"lf",6,3)$+"\000"$+ "Maximum value "$+ftos(maxc(data),"lf",6,3)$+"\000"$+ "Minimum value "$+ftos(minc(data),"lf",6,3); _pmsgctl=(.5~5.4~.15~0~2~4~0)| (.5~5.2~.15~0~2~4~0)| (.5~5.0~.15~0~2~4~0)| (.5~4.8~.15~0~2~4~0)| (.5~4.6~.15~0~2~4~0); _pline=(1~3~-2.5~0~-2.5~.5~1~4~3); _plegstr="Finite sample distribution\000Normal Approximation"; _plegctl=2~4~.5~3.8; title("Full information semiparametric 2-step estimator for q]2[\LTrue value of q]2[=-2.5, 500 monte carlo draws"); xy(x,kde~nden); #IFUNIX call WinSetActive(1); #ENDIF data=qmc[.,1]; x=seqa(-10,.1,161); nden=zeros(161,1); sig=meanc(smc[.,1]); i=1; do until i>rows(x); nden[i]=exp(-((x[i]-meanc(data))^2)/(2*sig*sig))/(sqrt(2*pi)*sig); i=i+1; endo; kde=kden(x,data); library pgraph; _pdate=""; _pmsgstr=""; _pmsgctl=0; #IFUNIX let v = 100 100 640 480 0 0 1 6 15 0 0 2 2; wxy = WinOpenPQG(v,"XY Plot","XY"); call WinSetActive(wxy); #ENDIF _pmsgstr="Number of obs "$+ftos(rows(data),"lf",6,0)$+"\000"$+ "Mean "$+ftos(meanc(data),"lf",6,3)$+"\000"$+ "Std deviation "$+ftos(stdc(data),"lf",6,3)$+"\000"$+ "Maximum value "$+ftos(maxc(data),"lf",6,3)$+"\000"$+ "Minimum value "$+ftos(minc(data),"lf",6,3); _pmsgctl=(.5~5.4~.15~0~2~4~0)| (.5~5.2~.15~0~2~4~0)| (.5~5.0~.15~0~2~4~0)| (.5~4.8~.15~0~2~4~0)| (.5~4.6~.15~0~2~4~0); _pline=(1~3~-0.5~0~-0.5~.5~1~4~3); _plegstr="Finite sample distribution\000Normal Approximation"; _plegctl=2~4~.5~3.8; title("Full information semiparametric 2-step estimator for q]1[\LTrue value of q]1[=-0.5, 500 monte carlo draws"); xy(x,kde~nden); #IFUNIX call WinSetActive(1); #ENDIF