/* ** maxlik1.e - A Tobit model ** */ library maxlik; #include maxlik.ext; maxset; proc lpr(x,z); local s,m,u; s = x[4]; if s <= 1e-4; retp(error(0)); endif; m = z[.,2:4]*x[1:3,.]; u = z[.,1] ./= 0; retp(u.*lnpdfn2(z[.,1]-m,s) + (1-u).*(ln(cdfnc(m/sqrt(s))))); endp; x0 = { 1, 1, 1, 1 }; __title = "tobit example"; __output = 5; output file = maxlik1.out reset; {x,f,g,cov,ret} = maxlik("tobit",0,&lpr,x0); call maxprt(x,f,g,cov,ret); output off;