Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A logistic Regression Model for estimating Vaccine Efficacy
import pandas as pd
import numpy as np
from patsy import dmatrices
import statsmodels.api as sm
#Use Pandas to load the data set into a Dataframe
df = pd.read_csv('vaccine_trial_simulation_study.csv', header=0)
#Print the top 10 rows
df.head(10)
#Form the regression equation
expr = 'INFECTED ~ INTERVAL_BETWEEN_DOSES + VACCINATED'
#We'll use Patsy to carve out the X and y matrices
y_train, X_train = dmatrices(expr, df, return_type='dataframe')
#Build and train a Logit model
logit_model = sm.Logit(endog=y_train, exog=X_train)
logit_results = logit_model.fit()
#Print the model summary
print(logit_results.summary())
@rcsmit
Copy link

rcsmit commented Oct 30, 2021

Thank you for your tutorial https://timeseriesreasoning.com/contents/estimation-of-vaccine-efficacy-using-logistic-regression/

How do I get the confidence bounds from the summary in Python?

@rcsmit
Copy link

rcsmit commented Oct 30, 2021

I succeeded to do also the last part in Python :)

https://gist.github.com/rcsmit/8a34cd87b88bc4e712eb52aff8c2e2cd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment