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
# 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 |
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
// 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 |
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
library(brms) | |
zero_one_inflated_beta2 <- custom_family( | |
"zero_one_inflated_beta2", dpars = c("mu", "phi","zero","one"), | |
links = c("logit", "log","logit","logit"), lb = c(NA, 0, 0, 0), | |
ub = c(NA, NA, 1, 1), type = "real" | |
) | |
stan_funs <- " |
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
# 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) |
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
## Load libraries | |
pacman::p_load(tidyverse,brms) | |
## Load data | |
data <- read_csv("data.csv") | |
## Define formulas | |
Model1_f <- bf(Outcome ~ Diagnosis + (1|ID)) | |
Model2_f <- bf(Outcome ~ Diagnosis + (1|p|ID), |
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
# Load libraries | |
library(brms) | |
library(tidyverse) | |
# Load data | |
data <- read_csv("temp_data.csv") | |
# Define model | |
Model2_Language_f <- bf(Outcome ~ 0 + language + language:Diagnosis + |
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
# Load libraries | |
library(brms) | |
library(tidyverse) | |
# Load data | |
data <- read_csv("temp_data.csv") | |
# Define model |
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
pacman::p_load(tidyverse, brms) | |
# Prepare the data | |
d <- Ass3 | |
#summary(d) | |
d$Diagnosis <- plyr::revalue(as.character(d$Diagnosis), | |
c("0"="Controls", "1"="Schizophrenia")) |
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
pacman::p_load(tidyverse, brms) | |
seed <- 1981 # Defining a seed so the results are always the same | |
samplesize <- 300 # Defining the amount of datapoints | |
n <- 1000 # Defining number of simulations | |
MaxScore <- 8 # Defining max rating | |
MinScore <- 1 # Defining min rating | |
## Regression to the mean? | |
Regression2Mean <- 0.7 # 1st to 2nd in the empirical data : 0.668444 |
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
library(tidyverse) | |
library(data.table) | |
temp <- read_delim("~/Downloads/temp.csv", delim = ";") | |
setDT(temp) | |
r <- ":acute interstitial pneumonitis:|:alveolar lung disease:|:alveolar proteinosis:|:alveolitis:|:alveolitis necrotising:|:autoimmune lung disease:|:bronchiolitis:|:combined pulmonary fibrosis and emphysema:|:diffuse alveolar damage:|:eosinophilia myalgia syndrome:|:eosinophilic granulomatosis with polyangiitis:|:eosinophilic pneumonia:|:eosinophilic pneumonia acute:|:eosinophilic pneumonia chronic:|:hypersensitivity pneumonitis:|:idiopathic interstitial pneumonia:|:idiopathic pneumonia syndrome:|:idiopathic pulmonary fibrosis:|:immune-mediated pneumonitis:|:interstitial lung disease:|:lung infiltration:|:lung opacity:|:necrotising bronchiolitis:|:obliterative bronchiolitis:|:pneumonitis:|:progressive massive fibrosis:|:pulmonary fibrosis:|:pulmonary necrosis:|:pulmonary toxicity:|:pulmonary vasculitis:|:small airways disease:|:transfusion-related acute lung injury:|:acute lung injury:|:acute respira |
OlderNewer