* Assessing Teaching Methods with Probability Models * * Keywords: * probability, linear, logistic, logit, probit, log log, gumbel, economics teaching, * psi, personalized system of instructors * * Description: * We use a set of probability models to assess whether a new method of * teaching economics, the Personalized System of Instructors, significantly * influences performance in later economics courses * * Author(s): * Noel Roy * Skif Pankov * * Source: * William H. Greene, Econometric Analysis - 7th Edition * Pearson International Edition, Chapter 17, Example 17.3 (page 734) * * Reading the datafile and retrieving variables' names read (TableF14-1.shd) / names * Estimate the probability models in Table 17.1. * Linear Model (saving estimated coefficients): ols grade gpa tuce psi / coef=b * Logistic Model (saving estimated coefficients): logit grade gpa tuce psi / coef=bl cov=vl gen1 k=$k * Probit Model (saving estimated coefficients): probit grade gpa tuce psi /coef=bp cov=vp gen1 llfprob=$llf * Estimating Gumbel model by nl command with logden option; the OLS * estimates b are used as starting values nl 1 /ncoef=4 logden start=b coef=beta * The likelihood function exp(-exp(-x'Beta)) for the Gumbel model eq (grade-1)*exp(b1*gpa+b2*tuce+b3*psi+b4) + grade*log(1-exp & (-exp(b1*gpa+b2*tuce+b3*psi+b4))) end * Calculating the marginal effects (labelled "Slope" in Table 17.1) of the * Gumbel model. genr one=1 * Calculating value of x at the sample means ?stat gpa tuce psi one / mean=xbar * Cross multiplying vector of means by Beta matrix bxbar=beta'xbar * Calculating the Gumbel density function f(xbar'Beta) (obtained by * differentiating Prob(Y=1|x) ) matrix scale=exp(-exp(bxbar))*exp(bxbar) print scale * Drop the constant term from Beta copy beta beta13 /frow=1;3 /trow=1;3 matrix slope=scale*beta13 print slope delete one * Replicating Figure 17.2 using the graph command by first generate the * probability functions and sorting the data in ascending order using the * sort command with gpa as the sort variable. Including the OBS variable * (i.e. a time trend variable) to allow for unsorting the data back to its * original order. ?stat tuce / mean=meantuce genr withpsi=ncdf(bp:4+bp:1*gpa+bp:2*meantuce+bp:3*1) genr wopsi=ncdf(bp:4+bp:1*gpa+bp:2*meantuce) sort gpa withpsi wopsi obs graph withpsi wopsi gpa /lineonly * Unsorting the data sort obs gpa * Calculating the standard errors of the estimates * Logit Model * Calculate Beta'x matrix blx=bl'xbar * Calculating the Logstic Probabilities Prob(GRADE=1|x) matrix pl=1/(1+exp(-blx)) * Logistic density function=P(Beta x) (1-P(Beta x)) matrix fl=pl*(1-pl) * Asymptotic covariance matrix of the marginal effects Gamma_hat matrix gl=fl(iden(k)+(1-2*pl)*bl*xbar') matrix vgammal=gl*vl*gl' * Calculating the standard errors from the diagonal elements matrix slopesel=sqrt(diag(vgammal)) matrix slopetl=fl*bl/slopesel print slopesel slopetl * Doing the same for the Probit Model matrix bpx=bp'xbar matrix pp=ncdf(bpx) ?distrib bpx /pdf=fp beg=1 end=1 matrix gp=fp*(iden(k)-bpx*bp*xbar') matrix vgammap=gp*vp*gp' matrix slopesep=sqrt(diag(vgammap)) matrix slopetp=fp*bp/slopesep print slopesep slopetp * Allowing for the fact that PSI is binary * Xbar when PSI=0 matrix xbar0 = xbar matrix xbar0(3)=0 * Xbar when PSI=1 matrix xbar1 = xbar matrix xbar1(3)=1 * Logit model * Redo calculations with PSI=0 matrix blx0=bl'xbar0 matrix pl0=1/(1+exp(-blx0)) matrix fl0=pl0*(1-pl0) * Ditto for PSI=1. matrix blx1=bl'xbar1 matrix pl1=1/(1+exp(-blx1)) matrix fl1=pl1*(1-pl1) * Calculate the "marginal effict" for a change in PSI from 0 to 1. matrix delfl = pl1-pl0 * Calculating asy var deltaF as per (23-26). matrix sedelfl=sqrt(fl1**2*xbar1'vl*xbar1+fl0**2*xbar0'vl*xbar0) matrix trdelfl=delfl/sedelfl print delfl sedelfl trdelfl * Doing same with Probit Model matrix bpx0=bp'xbar0 matrix pp0=ncdf(bpx0) ?distrib bpx0 / pdf=fp0 beg=1 end=1 matrix bpx1=bp'xbar1 matrix pp1=ncdf(bpx1) ?distrib bpx1 / pdf=fp1 beg=1 end=1 matrix delfp = pp1-pp0 matrix sedelfp=sqrt(fp1**2*xbar1'vp*xbar1+fp0**2*xbar0'vp*xbar0) matrix trdelfp=delfp/sedelfp print delfp sedelfp trdelfp stop