I see this question has been asked before but I can't find a situation that applies to my specific circumstance.
I have the following code:
list_of_responses =['Respiratory','GI_System','Systemic_Other','EXP_TEST_COVMEN_PUI_MISC','MED_ALERT_CPR_SHOCK_SEPSIS','Lymph_Node_Neck','Ear','Mouth_Sores','Eye','Cough','Nasal_Congestion','SOB_WOB_Hyp_Desat','PNA','Abdominal_Pain','Nausea','Vomiting','Diarrhea','Rash','Fever','Weak_Fatigue','Bodyaches','Dizziness','Fussy','Poor_PO_Dehydration','Tachycardia','COVID_Exposure','COVID_Test','COVID_PUI','CP','ST','HA','Wheezing_Asthma','Loss_Taste_Smell']
for cc in list_of_responses:
reg_model = smf.logit("Covid_pos ~ cc + C(RACE_GROUP_N, Treatment(0)) + C(Age_Group_N, Treatment(0)) + C(Insurance_Type_Group, Treatment(0))",
data = df_merged2).fit()
reg_model_odds = pd.DataFrame(np.exp(reg_model.params), columns= ['OR'])
reg_model_odds['z-value']= reg_model.pvalues
reg_model_odds[['2.5%', '97.5%']] = np.exp(reg_model.conf_int())
reg_model_odds['OR'] = round(reg_model_odds['OR'], 2)
reg_model_odds['2.5%'] = round(reg_model_odds['2.5%'], 2)
reg_model_odds['97.5%'] = round(reg_model_odds['97.5%'], 2)
reg_model_odds["OR 95% CI"]= reg_model_odds['OR'].map(str)+' ('+reg_model_odds['2.5%'].map(str)+', '+reg_model_odds['97.5%'].map(str)+')'
reg_model_oddsOR=reg_model_odds["OR 95% CI"]
reg_model_oddsOR
When I run this code, I get the following error:
PatsyError: Number of rows mismatch between data argument and cc (5253 versus 1)
Covid_pos ~ cc + C(RACE_GROUP_N, Treatment(0)) + C(Age_Group_N, Treatment(0)) + C(Insurance_Type_Group, Treatment(0))
^^
I see in previous posts that it may be due to how the columns are formatted and the formula, but I think my columns appears to be properly formatted and the formula is correct. Not quite sure where I'm going wrong.
PatsyError: Number of rows mismatch between data argument and column (statsmodels)
This is what my data look like:
ID RACE_GROUP_N Age_Group_N... Covid_pos Asymptomatic Fever Cough ...
0 1 0 1 0 1 0
1 0 2 0 0 0 1
2 3 3 1 1 0 0
3 2 1 1 0 1 0
4 3 2 0 1 0 0
5 0 4 1 0 1 0