Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Re: xtmelogit convergence issues and log transforming IVs

From   Nick Cox <>
To   "''" <>
Subject   st: RE: Re: xtmelogit convergence issues and log transforming IVs
Date   Wed, 25 Jan 2012 19:38:26 +0000

I didn't look carefully enough at your previous. 

Your work-around treats prior convictions of 0 and prior convictions of 1 as identical, as both are mapped to 0. 

By the way, the dummy here is an irrelevance unless you use it later. -cond(priors == 0, 0, ln(priors)) is a way of doing your transformation directly. 

Also, dividing by ln(1.1) makes no difference to ln(1). I'd leave it out, as I have done just above, if only because explaining it will just be a distraction. 

More importantly, I am no criminologist but I think you would have a hard time defending this choice as sensible, either (social) scientifically or in any lay person's terms. 

In your shoes I would still go with ln(x + 1). 


-----Original Message-----
From: [] On Behalf Of William Hauser
Sent: 25 January 2012 19:20
Subject: st: Re: xtmelogit convergence issues and log transforming IVs

Nick and Maarten,
I appreciate the advice.  I think I prefer the intuitive
interpretation of logs.  I'm going to make the bold assumption that my
interpretation of log base 1.1 as a 10% change is correct since I
haven't been corrected  : )

I also especially appreciate the suggestion of splines and the
insightful example.  Splines are not something that's ordinarily used
in my field and I know little about it.  I think a log transformation
here makes for the most intuitive interpretation since the "knot(s)"
in the spline would be arbitrary.  That said, I have another research
endeavor using this dataset and I think the use of a linear spline
might be particularly useful - so Maarten's suggestion is, perhaps,
more helpful than he could have realized.

Thanks all,

Will Hauser

On Tue, Jan 24, 2012 at 3:24 PM, William Hauser <> wrote:
> Hi all,
> I'm working with a dataset consisting of court cases nested within judges
> nested within circuit.  The model is specified as 2 levels (cases<judges)
> with circuit represented as 19 dummy variables (20 circuits, 1 omitted as
> reference).  The outcome is dichotomous so I'm using the xtmelogit command.
>  Stata is version 12, intercooled.
> The problem is that the model simply will not converge unless I transform
> two of the predictor variables which are, in their untransformed form,
> highly overdispersed.  These variables represent the number of points the
> offender receives for their present offense and for their prior record if
> they have one (more on that shortly).
> Problem is, I'm not sure how to interpret the resulting odds ratios for the
> log transformed predictor variables (crime seriousness and prior record).
> Using the natural log, calculated as ln(xvar), I think the coefficient
> represents the change in odds for increasing x by a factor of ~2.7  (the
> value of e).  This would seem to be very unintuitive if correct.
>  Alternatively, I can use the log to base 1.10 of the x vars, calculated as
> ln(xvar)/ln(1.10), which I think might be interpreted as the odds ratio for
> a 10% change in x but I'm not at all sure.
> So, what is the correct/best transformation for this application and how do
> I interpret it?
> There is also the vexing issue the log of 0.  For crime seriousness there
> are no zeros since everyone committed a crime.  But for prior record there
> are those with no prior record.  One solution that seems to be roundly
> criticized is the addition of a constant such as .5 or 1 to all cases before
> logging.  Another solution is to keep the 0's as 0 and create a dummy coded
> as 1 for all cases with that 0 value (i.e. those that would've been
> undefined or ".").  The syntax for the latter solution looks like this,
> gen log_priors=(ln(prior_record)/ln(1.10)
> (a bunch of missing values result for all those cases where the offender has
> no prior record)
> replace log_priors=0 if prior_record==0
> gen no_priors=0
> replace no_priors=1 if prior_record==0
> Anyone know if this is an acceptable solution or if perhaps another
> transformation that is amenable to zeros is in order?

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index