Skip to content

Commit

Permalink
fixed file path as suggested (#5710)
Browse files Browse the repository at this point in the history
* Create statsmodels.md 'MarioSuperFui'

* Create logit.md

* Delete docs/content/python/concepts/statsmodels directory

* Update logit.md

* Updated file path logit.md

* Removed logit.md

* logit.md in the correct filepath directory

* Formatted logit.md using Prettier

* Fix formatting with Prettier

* Delete logit.md

* Minor changes

--------
  • Loading branch information
MarioSuperFui authored Dec 27, 2024
1 parent 913853b commit b64ea94
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
70 changes: 70 additions & 0 deletions content/python/concepts/statsmodels/terms/logit/logit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
Title: 'Logit'
Description: 'Returns the log-odds of a binary outcome using logistic regression.'
Subjects:
- 'Python'
- 'Statistics'
Tags:
- 'Logit'
- 'Logistic Regression'
- 'Statsmodels'
CatalogContent:
- 'learn-statistics'
- 'paths/data-science-inf'
---

**Logit** is a term used in statistics, specifically in the context of logistic regression. It represents the log-odds of a binary outcome, mapping probabilities from the 0 to 1 range to the entire real number line. The **`.Logit()`** function is a key part of many statistical models, particularly in binary classification tasks.

## Syntax

```pseudo
statsmodels.api.Logit(endog, exog)
```

- `endog`: The dependent (binary) variable, which must be a binary outcome (0 or 1).
- `exog`: The independent variables (features or predictors).

## Example

This example demonstrates how to use the `.Logit()` function in the `statsmodels` library to perform logistic regression:

```py
import statsmodels.api as sm

# Example data
X = sm.add_constant([[1], [2], [3], [4], [5]]) # Adding a constant for the intercept
y = [0, 0, 1, 1, 1]

# Fitting the logistic regression model
model = sm.Logit(y, X)
result = model.fit()

# Output the results
print(result.summary())
```

> **Note:** The dependent variable (`y`) must contain only binary values (0 or 1) for the logistic regression to be valid.
This example produces a summary of the logistic regression model's results, showing coefficients, standard errors, p-values, and other statistics relevant to evaluating the model fit:

```shell
Logit Regression Results
==============================================================================
Dep. Variable: y No. Observations: 5
Model: Logit Df Residuals: 3
Method: MLE Df Model: 1
Date: Tue, 24 Dec 2024 Pseudo R-squ.: 1.000
Time: 12:28:45 Log-Likelihood: -5.0138e-10
converged: False LL-Null: -3.3651
Covariance Type: nonrobust LLR p-value: 0.009480
==============================================================================
coef std err z P>|z| [0.025 0.975]
------------------------------------------------------------------------------
const -110.4353 2.23e+05 -0.000 1.000 -4.38e+05 4.38e+05
x1 44.2438 9.07e+04 0.000 1.000 -1.78e+05 1.78e+05
==============================================================================

Complete Separation: The results show that there iscomplete separation or perfect prediction.
In this case the Maximum Likelihood Estimator does not exist and the parameters
are not identified.
```
2 changes: 2 additions & 0 deletions documentation/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Lists
Logic
Logical
Logistic Regression
Logit
Loops
Map
Machine Learning
Expand Down Expand Up @@ -315,6 +316,7 @@ SQL Server
Stacks
Static Site
Statistics
Statsmodels
Storage
Stringr
Strings
Expand Down

0 comments on commit b64ea94

Please sign in to comment.