? READ the data using procedures that are familiar to you. IMPORT the healthcare data $ CREATE ; xi = the independent variable to be used $ CREATE ; yi = the dependent variable to be used $ create ; xi=educ ; yi=hhninc $ NAMELIST ; x = one,xi $ ? Use zero and zero for starting values. ? GHG is used to decide when to stop the iterations Matrix ; c = [0/0] ; ghg=[1] $ ? Define a procedure that we can use over and over again. Procedure ? First and second derivatives, scalar part only. Create ; gi = 1 - yi*exp(c(1) + c(2)*xi) ; hi = gi - 1 $ ? This line computes the first derivative vector and the ?(negative of) the second derivatives matrix Matrix ; H = -X'[hi]X ; Hinv = ; g = X'gi ; c = c + Hinv*g $ ? This line computes the next coefficient vector. Matrix ; list ; ghg = g'[Hinv]g $ EndProc $ ? This executes the procedure. We use the standard stopping rule. Execute ; while ghg > 1.d-8 $ ? Display the results. Matrix ; Stat(c, Hinv, x)$ ? Conditional mean function dsta;rhs=educ$ calc ; edbar=11.321 ; list ; ey = 1/exp(c(1) + c(2)*edbar) $ calc ; g1 = -ey ; g2 = -edbar*ey $ matrix ; g=[g1/g2] ; ve = g'[hinv]g $ calc ; list ; sde = sqr(ve)$ wald ; start = c ; labels = c1,c2 ; var=hinv ; fn1 = 1/exp(c1+c2*edbar)$ ? Slope at the means. calc ; list ; dededuc = -c(2) * ey $ calc ; g1 = -c(2)*ey ; g2 = ey - c(2)*edbar*ey $ matrix ; g=[g1/g2] ; list ; vpe=g'[hinv]g $ calc ; list ; sdpe=sqr(vpe)$ wald ; start = c ; labels = c1,c2 ; var=hinv ; fn1 = -c2/exp(c1+c2*edbar)$ ? Mean of slopes vs. slope at means. Almost identical. create ; slopei = -c(2) / exp(c(1)+c(2)*educ) $ calc ; list ; xbr(slopei) ; dededuc $ ? Linear regression Regress ; lhs = hhninc ; Rhs = one, educ $ ? 3 estimates of covariance matrix. ? Inverse of actual second derivatives is Hinv ? Inverse of expected second derivatives. ? THe expected value of hi is 1 in the program, so this estimator is Matrix ; EHinv = $ ? BHHH is the outer produce of the squares. Create ; gi2 = gi*gi $ Matrix ; BHHH = $ Matrix ; Stat (c,hinv,x) ; Stat(c, EHinv,x) ; Stat(c,bhhh,x) $ ? Test of hypothesis That gamma equals zero. ? Wald is the simple t test based on the results. Calc ; list ; waldtest = c(2)^2/hinv(2,2) $ ? Likelihood ratio test. Create ; lambdai = exp(c(1)+c(2)*educ) ; logli = log(lambdai)-lambdai*yi $ Calc ; lambdai0= 1/xbr(yi) $ Create ; logli0 = log(lambdai0) - lambdai0*yi $ Calc ; List ; lrtest = 2*(sum(logli) - sum(logli0)) $ ? LM test Create ; gi0 = 1 - yi*lambdai0 ; hi0 = gi0 - 1 $ Matrix ; g0=X'gi0 ; H0 = -X'[HI0]X ; List ; LMtest = g0'g0 $