*! version 0.8.1 2009-01-09 *! Distribution free estimation of heteroskedastic binary response models program define dfbr version 10 syntax varlist [if][, {Sieve|Local} BANDwidth(real 0.0) BASis(varlist)] /* * Sanity checks */ if ("`sieve'" != "") + ("`local'" != "") > 1 { di as err "Only one of sieve or local may be used" exit 198 } if `bandwidth' < 0 { di as error "bandwidth must be positive (`bandwidth')" exit 198 } /* * Set up dependent variable and regressors */ local y: word 1 of `varlist' local x: word 2 of `varlist' local xbeta = "`x'" local i = 3 local xp: word 3 of `varlist' while "`xp'" ~= "" { local xbeta "`xbeta' * {`x'} + `xp'" local i = `i' + 1 local x = "`xp'" local xp: word `i' of `varlist' } /* * Local nonlinear least squares */ if "`local'" != "" { di as txt "Method: Local Nonlinear Least Squares (LNLLS)" if (`bandwidth' > 0.0) { di as txt "Bandwidth: `bandwidth'" } else { local bandwidth = _N^(-1/3) di as txt "Bandwidth: `bandwidth' (default: n^(-1/3))" } nl (`y' = normal((`xbeta')/`bandwidth')) `if', nolog } /* * Sieve nonlinear least squares (default) */ else { di as txt "Method: Sieve Nonlinear Least Squares (SNLLS)" if ("`basis'" != "") { tokenize `basis' di as txt "Sieve basis: 1 `basis'" } else { tokenize `varlist' macro shift di as txt "Sieve basis: 1 `*' (default)" } local series = "{g_const}" while "`1'" != "" { local series "`series' + {g_`1'} * `1'" macro shift } nl (`y' = normal((`xbeta') * exp(`series'))) `if', nolog } di as txt "Coefficient on `x' normalized to 1." end