Last active
October 30, 2021 11:42
-
-
Save sachinsdate/e6185c1cc62da896dab0ca6684edbc54 to your computer and use it in GitHub Desktop.
A logistic Regression Model for estimating Vaccine Efficacy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I succeeded to do also the last part in Python :)
https://gist.github.com/rcsmit/8a34cd87b88bc4e712eb52aff8c2e2cd