Logistic Regression Example 1 Solution

Download as xlsx, pdf, or txt
Download as xlsx, pdf, or txt
You are on page 1of 7

Y X1 X2

Meet spec? Machine age Average # of shifts per week


0 78 8
0 73 5
0 73 8
0 71 7
0 68 5
0 59 4
0 57 7
0 49 5
0 35 4
0 27 7
1 59 3
1 57 4
1 44 5
1 38 5
1 36 2
1 36 4
1 22 5
1 22 6
1 15 4
1 10 6
Step 1 - Sort the data
Step 2 - Calculate a logit for each data record
Step 3 - Calculate e^L for each data record
Step 4 - Calculate P(X) for each data record
Step 5 - Calculate LL, the Log-likelihood function
SUMMARY OUTPUT

Regression Statistics
Multiple R 0.707626
R Square 0.500734
Adjusted R 0.441997
Standard E 0.383201
Observatio 20

ANOVA
df SS MS F Significance F
Regression 2 2.503669 1.251835 8.524988 0.002728
Residual 17 2.496331 0.146843
Total 19 5

Coefficients
Standard Error t Stat P-value Lower 95%Upper 95%Lower 95.0%
Upper 95.0%
Intercept 1.687445 0.319872 5.27538 6.184E-05 1.012575 2.362316 1.012575 2.362316
Machine a -0.012525 0.004376 -2.86207 0.010795 -0.021758 -0.003292 -0.021758 -0.003292
Average # o-0.116473 0.056959 -2.044842 0.056673 -0.236647 0.003701 -0.236647 0.003701
Microsoft Excel 16.0 Answer Report
Worksheet: [Logistic regression example 1 solution.xlsx]Sheet2
Report Created: 11-10-2021 09:25:36
Result: Solver found a solution. All Constraints and optimality conditions are satisfied.
Solver Engine
Engine: GRG Nonlinear
Solution Time: 0.343 Seconds.
Iterations: 13 Subproblems: 0
Solver Options
Max Time Unlimited, Iterations Unlimited, Precision 0.000001, Use Automatic Scaling
Convergence 0.0001, Population Size 100, Random Seed 0, Derivatives Forward, Require Bounds
Max Subproblems Unlimited, Max Integer Sols Unlimited, Integer Tolerance 1%

Objective Cell (Max)


Cell Name Original Value Final Value
$G$2y*LN(p) + (1-y)*LN(1-p) -66.52350107 -6.654560484

Variable Cells
Cell Name Original Value Final Value Integer
$K$3b0= 0.1 12.482880927 Contin
$K$4b1= 0.1 -0.117031462 Contin
$K$5b2= 0.1 -1.46914597 Contin

Constraints
NONE
Y X1 X2 Propensity of thEvent log odds
Meet spec? Machine age Average # of shifts per L e^L
0 78 8 -8.3987408992 0.00022515063
0 73 5 -3.4061456785 0.03316879753
0 73 8 -7.813583587 0.00040420694
0 71 7 -6.1103746926 0.00221971894
0 68 5 -2.8209883663 0.05954705931
0 59 4 -0.2985592348 0.74188633505
0 57 7 -4.4719342185 0.01142519564
0 49 5 -0.59739058 0.55024558625
0 35 4 2.5101958637 12.3073403855
0 27 7 -0.9609903454 0.38251387747
1 59 3 1.1705867347 3.22388364817
1 57 4 -0.0644963099 0.93753957383
1 44 5 -0.0122332678 0.98784125445
1 38 5 0.6899555068 1.99362682852
1 36 2 5.3314563403 206.738837124
1 36 4 2.3931644012 10.9480833153
1 22 5 2.5624589058 12.9676644107
1 22 6 1.0933129363 2.98414399332
1 15 4 4.8508251124 127.845833525
1 10 6 2.4976904856 12.1543907798
-11.855790893 394.870820767

Scenario 1 Scenario 2 Scenario 3


X1 = Machine age 40 40 12
X2 = Avg no of weekly shifts 7 4 7
L = b0+b1x1+b2x2 -2.48239935708876 1.9250385515 0.79448159116
e^L 0.083542536548854 6.8554129472 2.21329330852
P(X) = e^L/(1+e^L) 0.07710129850088 0.8726992449 0.68879280415

This machine is not This machine is This machine is


likely to meet likely to meet likely to meet
Answer - specification specification specification
Probability of the event Log likelihood Solver decision variables
p(X) = e^L / (1 + e^L) y*LN(p) + (1-y)*LN(1-p) b0= 12.48288 Intercept
0.000225099951722 -0.000225125290518 b1= -0.117031 Coeff for X1
0.032103948171563 -0.03263058194644 b2= -1.469146 Coeff for X2
0.000404043621299 -0.000404125268917
0.002214802705072 -0.002217259008071
0.0562004856566 -0.05784151426574
0.425909727932245 -0.554968626617229
0.011296135086366 -0.011360421000381
0.35494091460614 -0.438413361120073
0.924853504078709 -2.58831579166413
0.276679955047421 -0.323903492317792
0.763251054409661 -0.270168265894588
0.483881509567818 -0.725915217180099
0.496941721194557 -0.699282520939091
0.66595702895433 -0.406530131612917
0.995186263609429 -0.004825359735738
0.916304567552126 -0.087406472245345
0.928406069147051 -0.074286067391836
0.749005055621393 -0.289009545659403
0.99223878667519 -0.007791488289656
0.923979755753216 -0.079065116938457
0.997473923442846
-6.65456048438642

Scenario 4 Scenario 5
Coeff for X1
Coeff for X2

You might also like