/* ** maxlik10.e - Biochemical Oxygen Demand Model (decaying exponential) ** ** The data are taken from Douglas M. Bates and Donald G. Watts, ** Nonlinear Regression Analysis and Its Applications, page 270. ** */ library maxlik,pgraph; #include maxlik.ext; #include pgraph.ext; maxset; @ -- procedure to compute log-likelihood -- @ z0 = { 8.3 1, 10.3 2, 19.0 3, 16.0 4, 15.6 5, 19.8 7 }; proc lnlk(b,z); local dev,s2; dev = z[.,1] - b[1]*(1 - exp(-b[2]*z[.,2])); s2 = dev'dev/rows(dev); retp(lnpdfn2(dev,s2)); endp; proc grd(b,z); local dev,s2,m,r; r = exp(-b[2]*z[.,2]); m = 1 - r; dev = z[.,1] - b[1]*m; s2 = dev'dev/rows(dev); dev = dev / s2; retp((dev.*m)~(b[1]*dev.*z0[.,2].* r)); endp; start = { 20, .24 }; output file = maxlik10.out reset; _max_GradProc = &grd; _max_Options = { newton }; call maxprt(maxlik(z0,0,&lnlk,start)); output off;