# Re: st: Knot optimized logistic regression

 From Maarten buis <[email protected]> To [email protected] Subject Re: st: Knot optimized logistic regression Date Sat, 30 Jan 2010 16:28:07 +0000 (GMT)

```I have been looking at the likelihood function obtained
from a grid search again, and things seem even more hopeless
then I said. In the example below you see a stronger example
of the multi-modality of the likelihood function than the
example I showed before. More serious is that the maximum
seems to involve an sudden change in direction in the
likelihood function (net of the inherit discreteness that is
the result of a grid search), meaning that at the maximum
the first and second derivatives are probably not defined.
This means that you can't compute the standard errors for
the knot location parameter using this estimator since the
standard errors are a function of the second derivatives.

*----------------- begin example -----------------------
sysuse auto, clear

sum mpg, detail
local begin = r(p5)
local end = r(p95)
local step = (`end'-`begin')/199
local j = 1
set obs 200
gen double ll = .
gen double k = .
forvalues i = `begin'(`step')`end' {
capture drop sp*
mkspline sp1 `i' sp2  = mpg, marginal
logit foreign price sp*, iter(50)
if e(converged) {
sum ll, meanonly
if e(ll) > r(max) {
est store result
local k = `i'
}
replace ll = e(ll) in `j'
replace k = `i' in `j'
}
local `j++'
}

//strong bimodility of the likelihood function
twoway line ll k

local begin = 16.5
local end = 17.5
local step = (`end'-`begin')/199
local j = 1
forvalues i = `begin'(`step')`end' {
capture drop sp*
mkspline sp1 `i' sp2  = mpg, marginal
logit foreign price sp*, iter(50)
if e(converged) {
sum ll, meanonly
if e(ll) > r(max) {
est store result
local k = `i'
}
replace ll = e(ll) in `j'
replace k = `i' in `j'
}
local `j++'
}

// abrupt change at the maximum
// so first and second derivatives are probably not defined
twoway ll k
*---------------------- end example -------------------------

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------

--- On Fri, 29/1/10, Dan MacNulty <[email protected]> wrote:

> From: Dan MacNulty <[email protected]>
> Subject: Re: st: Knot optimized logistic regression
> To: [email protected]
> Date: Friday, 29 January, 2010, 22:15
> Maarten,
> Thanks for the helpful suggestions. I'd like to try your
> splogit_lf program, but can you explain how I store the
> variable to be turned into a spline in the global sp? Dan
>
> Maarten buis wrote:
> > --- On Fri, 29/1/10, Dan MacNulty wrote:
> >
> >> The location of the knot is the key research
> question. My initial approach was to use AIC to select the
> best-fit model from among a set of models each with a
> different fixed knot. However, a reviewer has criticized
> this approach, arguing that I should have estimated the knot
> as a parameter because it affords a better measure of
> uncertainty about the knot location.
> >>
> >
> > The only thing I can think of is that you might try to
> go Bayesian, as
> > adding a weakly informative prior on such a parameter
> can sometimes  stabablize the model.
> > One alternative you could do that might convince the
> reviewer, or at least the editor, is to show how the
> likelihood changes over the values for your knot locations,
> which will show that it a quite irregularly shaped
> likelihood function with which most maximization algorithms
> will have great difficulty (hopefully it shows multiple
> modes, some plateas, etc).
> >
> > Good luck,
> > Maarten
> >
> > --------------------------
> > Maarten L. Buis
> > Institut fuer Soziologie
> > Universitaet Tuebingen
> > Wilhelmstrasse 36
> > 72074 Tuebingen
> > Germany
> >
> > http://www.maartenbuis.nl
> > --------------------------
> >
> >
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/help.cgi?search
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> >
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```