Skip to content

Instantly share code, notes, and snippets.

View fusaroli's full-sized avatar

Riccardo Fusaroli fusaroli

View GitHub Profile
// contest model
data{
int N_choices; // amount of data points
int N_items; // unique stimuli
int N_raters; // unique raters
int y[N_choices]; // outcome
int item1[N_choices]; // which stimulus 1 in each trials
int item2[N_choices]; // which stimulus 2 in each trials
int rater[N_choices]; // which rater in each trials
real Period[N_items]; // item feature: period
@fusaroli
fusaroli / Lme4PowerAnalysis.R
Last active September 25, 2017 16:58
Power analysis for linear mixed effects model (lme4)
# TO DO: ADJUST TO OTHER PARAMETERS (E:G: WHAT IF THERE ARE STIMULUS EFFECTS? OR MORE FIX EFFS?)
createNewData <- function (J,K,model){
# J is the number of subjects
# K is the number of visits
# HP is the hyperparameter matrix from get Hyperparam
# TO DO: LOOP THROUGH ALL FE ROWS AND AUTOMATICALLY EXTRACT NAMES OF FIXED EFFECTS AND ESTIMATES
fe <- fixef(model)
Intercept <- fe[1] #intercept
bVisit <- fe[2] #visit
bDiagnosis <- fe[3] #diagnosis