# [R] calculating logit parameters (odd ratio is exactly one or zero)

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Dec 13 22:30:29 CET 2011

```
On 13.12.2011 04:36, wim nursal wrote:
> Dear Uwe and David,
>
> Yes, definitely i was wrong.  The expression in R should be:
>
> glm(cbind(FD, 12 - FD) ~ Fsize, family=binomial, data=subFS)
> ----
> Call:  glm(formula = cbind(FD, 12 - FD) ~ Fsize, family = binomial,
>      data = subFS)
>
> Coefficients:
> (Intercept)        Fsize
>       0.6381      -0.1203
>
> Degrees of Freedom: 29 Total (i.e. Null);  28 Residual
> Null Deviance:      193.3
> Residual Deviance: 179.9        AIC: 245.1
> ----
>
> (the direction of Fsize is as expected).
>
> I am not sure with your second statement mentioning that "R can deal with
> perfect separation".

Oh, that was wrong. I meant to write

"*Neither* R nor any other software can deal with perfect separation ..."

Uwe

> Despite of convergence issue, does R take into
> account zero or infinite odds value or leave them to calculate the
> parameters? How? I need to know the basic of this calculation since so far
> I haven't found any literature discuss this problem and the way to handle
> this (well, someone need to understand this as well :) )
> David, i'm thinking to use LDA as well but i cannot comment this time.
>
> Thanks for any clarification.
>
> Best,
> Wim
>
> Research Officer
> CIFOR-Indonesia
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Tue, Dec 13, 2011 at 4:08 AM, David Winsemius<dwinsemius at comcast.net>wrote:
>
>>
>> On Dec 12, 2011, at 3:51 PM, Uwe Ligges wrote:
>>
>>   1. The formula you used is not for a logistic but an ordinal regression
>>> (since you are using the default gaussian family rather than
>>> family="binomial" or whatever.
>>>
>>
>> this this then produce one version of the "Armitage linear test of trend"?
>>
>>
>>
>>> 2. R (nor any other software) can deal with perfect separation (nor
>>> quasi-separation) of classes, since the problem is not well defined in such
>>> a case as you found out already. R will give a warning in that case, that
>>> the Fisher Scoring does not converge.
>>>
>>> LDA will give perfect results in such a case (well, unless the within
>>> class covariance matrix is singular).
>>>
>>> Best,
>>> Uwe Ligges
>>>
>>>
>>>
>>> On 12.12.2011 11:46, wim nursal wrote:
>>>
>>>> Dear statistician experts,
>>>>
>>>> Sorry if this is a trivial question, or the old same question (i don't
>>>> know
>>>> what is the efficient key word for this issue).
>>>> In order to understand the calculation of parameter of logistic
>>>> regression,
>>>>   I did an exercise through spreadsheet following the procedural example
>>>> from a literature, or the available spreadsheet (with calculation
>>>> formula).
>>>> I ended up with infinity (divided by zero) when the odd ratio is exactly
>>>> 1
>>>> (FD=12) or invalid number when odd ratio is zero (MFD = 0) after log.
>>>> I am wondering  how R through GLM function (particularly logit or
>>>> logistic
>>>> regression) treats the odds ratios or log odd ratios that is exatcly one
>>>> or
>>>> zeros.
>>>>
>>>> The sample data is like this:
>>>> #HH Fsize FD
>>>> 1 1.29472 0
>>>> 2 1.6184 0
>>>> 3 2.4276 1
>>>> 4 2.4276 2
>>>> 5 20.23 2
>>>> 6 1.6184 3
>>>> 7 1.820 3
>>>> 8 0.4046 3
>>>> 9 6.069 4
>>>> 10 2.6299 4
>>>> 11 0.72828 5
>>>> 12 2.4276 5
>>>> 13 6.069 7
>>>> 14 4.8552 7
>>>> 15 2.32645 7
>>>> 16 1.6184 8
>>>> 17 1.0115 8
>>>> 18 1.0115 8
>>>> 19 5.2598 9
>>>> 20 2.023 10
>>>> 21 0.6069 10
>>>> 22 1.2138 11
>>>> 23 0.8092 11
>>>> 24 1.4161 11
>>>> 25 0.6069 11
>>>> 26 3.440 11
>>>> 27 1.2138 12
>>>> 28 1.2138 12
>>>> 29 0.4046 12
>>>> 30 1.2138 12
>>>>
>>>> Fsize is the farm size (acre or hectare).  Food deficit (FD) is the
>>>> number
>>>> of months (last year from the survey took place) that an household had
>>>> bought food-grains (minimum = 0 month, maximum = 12 months or whole year
>>>> deficit).
>>>> Even though I "jitter"-ed the minimum or maximum FD value only (eg.
>>>> FD=0+1e-6 or FD=12-1e-6), nothing changed to the result.
>>>>
>>>> The formula I used is like this:
>>>> ------------------------------**------------------------------**--
>>>> glm(FD ~ Fsize, data = subFS)
>>>> --
>>>> Coefficients:
>>>> (Intercept)        Fsize
>>>>      7.7913      -0.3092
>>>>
>>>> Degrees of Freedom: 29 Total (i.e. Null);  28 Residual
>>>> Null Deviance:      463
>>>> Residual Deviance: 425.5        AIC: 170.7
>>>> ------------------------------**------------------------------**--
>>>>
>>>> I appreciate for any clarification.
>>>>
>>>> Best wishes,
>>>> Wim
>>>>
>>>>
>>>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help