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(brms) | |
library(patchwork) | |
## Define amount of data | |
items <- 30 | |
chains <- 5 | |
raters <- 30 | |
## Define parameter values |
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
# Assuming you have a matrix (CorMat_S) with a structure like a correlation matrix | |
# Load the libraries (NB probably some superfluous ones, I haven't double-checked) | |
pacman::p_load( | |
# General utility functions | |
tidyverse, | |
# Plotting | |
ggplot2, | |
scales, | |
ggstance, |
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 |
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
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
# 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
# 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 | |
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
# 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
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 <- " |
NewerOlder