Skip to content

Instantly share code, notes, and snippets.

@sachinsdate
Last active October 30, 2021 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachinsdate/e6185c1cc62da896dab0ca6684edbc54 to your computer and use it in GitHub Desktop.
Save sachinsdate/e6185c1cc62da896dab0ca6684edbc54 to your computer and use it in GitHub Desktop.
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

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