*! version 1.0.0 (STB-10: sqv6) * SMOOTHED PARTIAL RESIDUAL PLOTS FOR LOGISTIC REGRESSION * Options: Cubic spline or lowess smooth; smooth selection * Hilbe 9-30-92 capture program drop lpartr program define lpartr version 3.0 local varlist "req ex" local options " Smooth(integer 4) Lowess BWidth(real .8) GEN WITH(string) *" local in "opt" local if "opt" parse "`*'" local main `varlist' local force `with' parse "`main'", parse(" ") local lhs `1' mac shift local rhs `*' local i=0 qui { logistic `lhs' `rhs' `force' `in' `if' tempvar RES FIT PR esti lpredict `RES' `in' `if', resid while "`1'" != "" { cap drop `FIT' cap drop `PR' local i=`i'+1 gen `FIT' = _b[`1'] * `1' `in' `if' gen `PR' = `RES' + `FIT' `in' `if' label var `PR' "Partial residual [`1']" if "`lowess'"~= "" { estimates hold esti if "`gen'"!= "" { noi ksm `PR' `1', low xlab ylab bw(`bwidth') gen(PR`i') } else { noi ksm `PR' `1', low xlab ylab bw(`bwidth') } estimates unhold esti } else { if "`smooth'"!="" { noi gr `PR' `1', s(o) c(s) bands(`smooth') xlab ylab t1(Cubic Spline, bandwidth = `smooth') } else if "`smooth'"=="" { noi gr `PR' `1', s(o) c(s) bands(4) xlab ylab t1(Cubic Spline, bandwidth = 4) } } mac shift } } end