probit
Explains a yes/no outcome, with a slightly different curve.
What we have
- the same factor notation as
regress
Coming later
predictandmarginsafterwards
How you write it
probit depvar indepvars [if]
Square brackets mean optional. A vertical bar means choose one.
What it does
Does the same job as logit, using the normal ("bell curve") shape instead of the logistic one. The two curves are so similar that the two models nearly always agree about which columns matter and in which direction.
Choose on convention: economists often reach for probit, epidemiologists for logit, mostly because logit gives odds ratios and probit does not.
Try it
Every example below was run after sysuse vira.sample02, clear.
. generate poor = mpce < 2500
The same thing in pandas and in R
pandas
import numpy as np
import pandas as pd
def stata_missing(value):
"""Stata counts a missing value as larger than any number."""
if isinstance(value, pd.Series):
if pd.api.types.is_numeric_dtype(value):
return value.astype("float64").fillna(np.inf)
return value.fillna("")
if value is None or (isinstance(value, float) and np.isnan(value)):
return np.inf
return value
df["poor"] = (stata_missing(df["mpce"]) < 2500)
R
library(dplyr)
stata_missing <- function(x)
if (is.numeric(x)) ifelse(is.na(x), Inf, x) else ifelse(is.na(x), "", x)
df <- df %>% mutate(poor = (stata_missing(mpce) < 2500))
# This R was run in a real R (4.6.1) and gave the same numbers.
. probit poor age
Probit regression Number of obs = 6,000
LR chi2 = 17.07
Prob > chi2 = 0.0000
Pseudo R2 = 0.0028
------------------------------------------------------------------------------
poor | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | -.0040628 .00098438 -4.13 0.000 -.0059922 -.0021335
_cons | -.6453022 .04899524 -13.17 0.000 -.7413311 -.5492733
------------------------------------------------------------------------------
The same thing in pandas and in R
pandas
import statsmodels.formula.api as smf
model = smf.probit("poor ~ age", data=df).fit()
R
model <- glm(poor ~ age, family = binomial(link = "probit"), data = df) summary(model) # This R was run in a real R (4.6.1) and gave the same numbers.