Home Â» How to Perform Logistic Regression in Excel

# How to Perform Logistic Regression in Excel

Logistic regression isÂ a method that we use to fit a regression model when theÂ responseÂ variable is binary.

This tutorial explains how to perform logistic regression in Excel.

### Example: Logistic Regression in Excel

Use the following steps to perform logistic regression in Excel for a dataset that shows whether or not college basketball players got drafted into the NBA (draft: 0 = no, 1 = yes) based on their average points, rebounds, and assists in the previous season.

Step 1: Input the data.

First, input the following data:

Step 2: Enter cells for regression coefficients.

Since we have three explanatory variables in the model (pts, rebs, ast), we will create cells for three regression coefficients plus one for the intercept in the model. We will set the values for each of these to 0.001, but we will optimize for them later.

Next, we will have to create a few new columns that we will use to optimize for these regression coefficients including the logit, elogit,Â  probability, and log likelihood.

Step 3: Create values for the logit.

Next, we will create the logit column by using the the following formula:

Step 4: Create values forÂ elogit.

Next, we will create values forÂ elogitÂ by using the following formula:

Step 5: Create values for probability.

Next, we will create values for probability by using the following formula:

Step 6: Create values for log likelihood.

Next, we will create values for log likelihood by using the following formula:

Log likelihood = LN(Probability)

Step 7: Find the sum of the log likelihoods.

Lastly, we will find the sum of the log likelihoods, which is the number we will attempt to maximize to solve for the regression coefficients.

Step 8: Use the Solver to solve for the regression coefficients.

If you havenâ€™t already install the Solver in Excel, use the following steps to do so:

• Click File.
• Click Options.
• ClickÂ Solver Add-In, then clickÂ Go.
• In the new window that pops up, check the box next toÂ Solver Add-In, then clickÂ Go.

Once the Solver is installed, go toÂ the AnalysisÂ group on theÂ DataÂ tab and clickÂ Solver. Enter the following information:

• Set Objective:Â Choose cell H14 that contains the sum of the log likelihoods.
• By Changing Variable Cells:Â Choose the cell range B15:B18 that contains the regression coefficients.
• Make Unconstrained Variables Non-Negative:Â Uncheck this box.
• Select a Solving Method:Â Choose GRG Nonlinear.

Then clickÂ Solve.

The Solver automatically calculates the regression coefficient estimates:

By default, the regression coefficients can be used to find the probability that draft = 0. However, typically in logistic regression weâ€™re interested in the probability that the response variable = 1. So, we can simply reverse the signs on each of the regression coefficients:

Now these regression coefficients can be used to find the probability that draft = 1.

For example, suppose a player averages 14 points per game, 4 rebounds per game, and 5 assists per game. The probability that this player will get drafted into the NBA can be calculated as:

P(draft = 1) = e3.681193 + 0.112827*(14) -0.39568*(4) â€“ 0.67954*(5) / (1+e3.681193 + 0.112827*(14) -0.39568*(4) â€“ 0.67954*(5)) =Â 0.57.

Since this probability is greater than 0.5, we predict that this player wouldÂ get drafted into the NBA.