Add ANOVA for adherence and gender + country.
parent
c96307b430
commit
1294ee40a0
|
@ -58,3 +58,30 @@ print("-------------------------------------")
|
|||
print(tbl_session_outcomes/len(df_session_counts))
|
||||
|
||||
# %%
|
||||
VARIABLES_TO_TRANSLATE = {
|
||||
"Gebruikersnaam": "username",
|
||||
"Geslacht": "gender",
|
||||
"Geboortedatum": "date_of_birth"
|
||||
}
|
||||
baseline_inactive.rename(columns=VARIABLES_TO_TRANSLATE, copy=False, inplace=True)
|
||||
now = pd.Timestamp('now')
|
||||
baseline_inactive = baseline_inactive.assign(date_of_birth = lambda x: pd.to_datetime(x.date_of_birth),
|
||||
age = lambda x: now - x.date_of_birth)
|
||||
|
||||
# %%
|
||||
df_session_counts
|
||||
|
||||
# %%
|
||||
df_adherence = baseline_inactive[["username", "gender", "age", "startlanguage"]].merge(df_esm_preprocessed[["username", "participant_id"]].drop_duplicates(), how="left", on="username")
|
||||
|
||||
# %%
|
||||
df_esm_preprocessed_adherence = df_esm_preprocessed.merge(df_session_counts.reset_index(), how="left", on=["participant_id", "device_id", "esm_session"])
|
||||
#df_esm_finished = df_esm_preprocessed_adherence[df_esm_preprocessed_adherence["session_response"]=="esm_finished"]
|
||||
|
||||
# %%
|
||||
df_adherence = df_adherence.merge(df_esm_preprocessed_adherence[df_esm_preprocessed_adherence["session_response"] == "esm_finished"].groupby("participant_id").count()["session_response"], how="left", on="participant_id")
|
||||
|
||||
# %%
|
||||
lm_adherence = ols('session_response ~ C(gender, Sum) + C(startlanguage, Sum)', data=df_adherence).fit()
|
||||
table = sm.stats.anova_lm(lm_adherence, typ=2) # Type 2 ANOVA DataFrame
|
||||
print(table)
|
||||
|
|
Loading…
Reference in New Issue