/* SERIES.G: polynomial series/sieve estimator of unknown choice probabilities of two continuous variables John Rust, University of Maryland, October, 2006 Inputs: x vector of points to compute estimated probabilities at ydata vector of binary 0,1 outcomes that are the dependent variables xdata matrix of data (2 continuous variables) that are used to construct the independent variables for the series estimator qsav a string with the name that the estimated series parameter vector is stored under (saved to disk as an fmt file) */ proc (1)=series(x,ydata,xdata,qsav); local infile,inlist,outfile,vnames,iloc,ivar,dvar,dloc,cloc,rx,rd,ep,i,tmp,tmp1; local q,hll,x_a,x_b,dat; infile="series"; inlist="series_est.lst"; outfile="series.out"; rd=rows(ydata); x_a=xdata[.,1]; x_b=xdata[.,2]; let vnames=y const xa xb xa*xb xa**2 xb**2; saved(seriesdt(ydata,x_a,x_b),"series",vnames); {iloc,ivar,dvar,dloc,cloc}=select(inlist); q=zeros(rows(ivar),1); {q,hll}=max(dvar,dloc,ivar,iloc,cloc,q,infile,500,outfile,qsav,&evalblg); rx=rows(x); ep=zeros(rx,1); x_a=x[.,1]; x_b=x[.,2]; dat=seriesdt(zeros(rx,1),x_a,x_b); i=1; do until i > rx; ep[i]=1/(1+exp(dat[i,iloc]*q)); i=i+1; endo; save iloc; retp(ep); endp;