2
$\begingroup$

I have a dataset as below Dataset. This is for predicting for the patient after taking the Rizatriptan (medicine) whether the they can relief the pain (stop headache) or not (Yes/No). By using spss, we can find the b0 = -2.490 and b1= 0.165Intercept and Coefficient. I want to know the way how we can calculate to find b0 and b1 by mathematics or by hand. Thank you in advance.

$\endgroup$
2
$\begingroup$

If you tread dose as continuous than the estimation necessarily involves an iterative algorithm. However, if you include dose as a categorical variable, then you have a so called saturated model, whose coefficients have a closed form solution. Here is an example using Stata:

. // enter the data
. clear

. input dose relieved freq

          dose   relieved       freq
  1.       0    0         65
  2.       0    1          2
  3.       25   0         68
  4.       25   1          7
  5.       50   0        101
  6.       50   1         29
  7.       100  0        105
  8.       100  1         40
  9. end

.
. // estimate the model, and display the results as odds ratios
. logit relieved i.dose [fw=freq], or nolog

Logistic regression                             Number of obs     =        417
                                                LR chi2(3)        =      28.59
                                                Prob > chi2       =     0.0000
Log likelihood = -186.66276                     Pseudo R2         =     0.0711

------------------------------------------------------------------------------
    relieved | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        dose |
         25  |   3.345588   2.744499     1.47   0.141     .6701979    16.70098
         50  |   9.331683   6.981748     2.99   0.003     2.153331    40.43981
        100  |   12.38095   9.181196     3.39   0.001     2.894267    52.96262
             |
       _cons |   .0307692   .0220893    -4.85   0.000     .0075342    .1256599
------------------------------------------------------------------------------

.
. // the exp(constant) is the odds of relieved for the baseline category:
. di 2/65       //  odds of relieved with 0 dose
.03076923

.
. // the exp(coefficient) is the odds ratio, i.e. a ratio of odds:
. di (7/68)  /  /// odds of relieved with 2.5 dose
>    (2/65)     //  odds of relieved with 0 dose
3.3455882

.
. // estimate the model, and display the results as raw coefficients
. logit relieved i.dose [fw=freq], nolog

Logistic regression                             Number of obs     =        417
                                                LR chi2(3)        =      28.59
                                                Prob > chi2       =     0.0000
Log likelihood = -186.66276                     Pseudo R2         =     0.0711

------------------------------------------------------------------------------
    relieved |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        dose |
         25  |   1.207643   .8203339     1.47   0.141    -.4001823    2.815467
         50  |   2.233415   .7481767     2.99   0.003      .767016    3.699815
        100  |   2.516159   .7415581     3.39   0.001     1.062732    3.969586
             |
       _cons |   -3.48124   .7179029    -4.85   0.000    -4.888304   -2.074176
------------------------------------------------------------------------------

.
. // the constant is the ln(odds) of relieved for the baseline category:
. di ln(2/65)       //  odds of relieved with 0 dose
-3.4812401

.
. // the coefficient is the ln(odds ratio), i.e. the logarithm of a ratio of odds:
. di ln((7/68)  /  /// odds of relieved with 2.5 dose
>       (2/65))    //  odds of relieved with 0 dose
1.2076425
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.