Skip to content

Instantly share code, notes, and snippets.

@fusaroli
Created June 10, 2019 20:18
Show Gist options
  • Save fusaroli/d426819db5aedded119773abb57446e6 to your computer and use it in GitHub Desktop.
Save fusaroli/d426819db5aedded119773abb57446e6 to your computer and use it in GitHub Desktop.
# Defining formulas
PitchMean_f <- bf(Pitch_MeanS ~ Diagnosis + (1|ID))
PitchMean_Language_f <- bf(Pitch_MeanS ~ 0 + language + language:Diagnosis + (1|ID))
PitchMean_Age_f <- bf(Pitch_MeanS ~ 0 + Diagnosis + AgeS:Diagnosis + (1|ID))
PitchMean_Gender_f <- bf(Pitch_MeanS ~ 0 + Gender + Gender:Diagnosis + (1|ID))
PitchMean_AgeGender_f <- bf(Pitch_MeanS ~ 0 + Gender + Gender:AgeS + Gender:Diagnosis + Gender:AgeS:Diagnosis + (1 | ID))
PitchMean_Full_f <- bf(Pitch_MeanS ~ 1 + Diagnosis * (Gender*AgeS + language) + (1 | ID))
# Fittig and saving models
PitchMean_SkepticModel_Trial <- brmsFun(Name="PitchMean_SkepticModel_Trial",formula=PitchMean_f,data=d_trial,prior=SkepticPrior)
PitchMean_SkepticModelLanguage_Trial <- brmsFun(Name="PitchMean_SkepticModelLanguage_Trial",formula=PitchMean_Language_f,data=d_trial)
PitchMean_SkepticModelAge_Trial <- brmsFun(Name="PitchMean_SkepticModelAge_Trial",formula=PitchMean_Age_f,data=d_trial)
PitchMean_SkepticModelGender_Trial <- brmsFun(Name="PitchMean_SkepticModelGender_Trial",formula=PitchMean_Gender_f,data=d_trial)
PitchMean_SkepticModelAgeGender_Trial <- brmsFun(Name="PitchMean_SkepticModelAgeGender_Trial",formula=PitchMean_AgeGender_f,data=d_trial)
PitchMean_SkepticModelFull_Trial <- brmsFun(Name="PitchMean_SkepticModelFull_Trial",formula=PitchMean_Full_f,data=d_trial)
# Model comparison
PitchMean_IC_Trial <- loo_compare(PitchMean_SkepticModel_Trial,PitchMean_SkepticModelLanguage_Trial,PitchMean_SkepticModelAge_Trial,PitchMean_SkepticModelAgeGender_Trial,PitchMean_SkepticModelGender_Trial,PitchMean_SkepticModelFull_Trial)
PitchMean_Weight_Trial <- loo_model_weights(PitchMean_SkepticModel_Trial,PitchMean_SkepticModelLanguage_Trial,PitchMean_SkepticModelAge_Trial,PitchMean_SkepticModelGender_Trial,PitchMean_SkepticModelAgeGender_Trial,PitchMean_SkepticModelFull_Trial)
## Repeated code, different variable
PitchSD_f <- bf(Pitch_SDS ~ Diagnosis + (1|ID))
PitchSD_Language_f <- bf(Pitch_SDS ~ 0 + language + language:Diagnosis + (1|ID))
PitchSD_Age_f <- bf(Pitch_SDS ~ 1 + Diagnosis + AgeS:Diagnosis + (1|ID))
PitchSD_Gender_f <- bf(Pitch_SDS ~ 0 + Gender + Gender:Diagnosis + (1|ID))
PitchSD_Full_f <- bf(Pitch_SDS ~ 1 + Diagnosis * (Gender*AgeS + language) + (1 | ID))
PitchSD_SkepticModel_Trial <- brmsFun(Name="PitchSD_SkepticModel_Trial",formula=PitchSD_f,data=d_trial,prior=SkepticPrior)
PitchSD_SkepticModelLanguage_Trial <- brmsFun(Name="PitchSD_SkepticModelLanguage_Trial",formula=PitchSD_Language_f,data=d_trial)
PitchSD_SkepticModelAge_Trial <- brmsFun(Name="PitchSD_SkepticModelAge_Trial",formula=PitchSD_Age_f,data=d_trial,prior=SkepticPrior)
PitchSD_SkepticModelGender_Trial <- brmsFun(Name="PitchSD_SkepticModelGender_Trial",formula=PitchSD_Gender_f,data=d_trial)
PitchSD_SkepticModelFull_Trial <- brmsFun(Name="PitchSD_SkepticModelFull_Trial",formula=PitchSD_Full_f,data=d_trial)
PitchSD_IC_Trial <- loo_compare(PitchSD_SkepticModel_Trial,PitchSD_SkepticModelLanguage_Trial,PitchSD_SkepticModelAge_Trial,PitchSD_SkepticModelGender_Trial,PitchSD_SkepticModelFull_Trial)
PitchSD_Weight_Trial <- loo_model_weights(PitchSD_SkepticModel_Trial,PitchSD_SkepticModelLanguage_Trial,PitchSD_SkepticModelAge_Trial,PitchSD_SkepticModelGender_Trial,PitchSD_SkepticModelFull_Trial)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment