drndr/statcodesearch huggingface dataset:
File: Vowel_Harmony_LDT_Naming.R

Comment: Linear mixed effect model (RTs) 1000/RT as preregistered
Category: Statistical Modeling
Code:
LDTword_LME = lmer(-1000/RT ~ primec + (1|item) + (1+primec|subject), data = byTrial, contrasts = list(primec = cc1), control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5))) summary(LDTword_LME)

Comment: Exploratory: Linear mixed effect model (RTs) with AuthorTest_Finnish
Category: Statistical Modeling
Code:
LDTword_LME_ARF = lmer(-1000/RT ~ primec*AR_Finnish + (1|item) + (1|subject), data = byTrial, contrasts = list(primec = cc1), control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5))) summary(LDTword_LME_ARF) plot(allEffects(LDTword_LME_ARF), x.var = "AR_Finnish")

Comment: Linear mixed effect model (RTs) nonwords
Category: Statistical Modeling
Code:
LDTword_LMEnw = lmer(-1000/RT ~ primec + (1|item) + (1+primec|subject), data = byTrialnw, contrasts = list(primec = cc1), control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5))) summary(LDTword_LMEnw)

Comment: Linear mixed effect model (RTs)
Category: Statistical Modeling
Code:
Nword_LME = lmer(-1000/RT ~ primec + (1|item) + (1+primec|subject), data = nbyTrial, contrasts = list(primec = cc1), control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5))) summary(Nword_LME)

Comment: Linear mixed effect model (RTs) with ART_English
Category: Statistical Modeling
Code:
Nword_LME_AR = lmer(-1000/RT ~ primec*AR_English + (1|item) + (1+primec|subject), data = nbyTrial, contrasts = list(primec = cc1), control=lmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5))) summary(Nword_LME_AR) plot(allEffects(Nword_LME_AR), x.var = "AR_English")
File: ML_target_independent_preprocessing.R

Comment: exclude features with zero or nearzero variance
Category: Data Variable
Code:
exclude_zero.var = nearZeroVar(data[, which(!colnames(data) %in% no.features)], freqCut = 95/5, uniqueCut = 10, saveMetrics = FALSE, allowParallel = TRUE) length(exclude_zero.var) exclude_zero.var = colnames(data[, which(!colnames(data) %in% no.features)])[exclude_zero.var] data = data %>% dplyr::select(-all_of(exclude_zero.var))
File: study2-rscript.R

Comment: Add the posterior_samples values as a column in the dataframe. Repeat it as many times as there are cell in the factorial design, namely 2. factor estimates
Category: Data Variable
Code:
post.data$b_GramGender2 <- rep(posterior_samples(model.study2)[['b_GramGender2']], 2)
File: analyse_final_Exp6_OSF.R

Comment: create dataset with only correct trials and only trials above 100 ms
Category: Data Variable
Code:
data.3SD <- data[data$corr == 1, ] data.3SD <- data.3SD[data.3SD$min2000 == 1, ] data.3SD <- data.3SD[data.3SD$plus100 == 1, ]
File: 220423_FinalModelEstimation.R

Comment: Function for showing parameter estimats with pvalues for polr models
Category: Statistical Modeling
Code:
showCoefWithPValue <- function(model) { coef <- coef(summary(model)) pvalue <- pnorm(abs(coef[, "t value"]), lower.tail = FALSE) * 2 coef <- cbind(coef, "pvalue" = pvalue) return(round(coef, 4)) }

Comment: Correlation between bulletin user type and avalanche awareness training
Category: Data Variable
Code:
cor.test(as.numeric(PartBkgr$BullUseType), as.numeric(PartBkgr$BackgrAvTraining), method = "spearman")
File: analysis_exp1.R

Comment: This additional analysis test the influence of trialbytrial blink duration on response error by computing individual Bayes factors the Bayes factor is calculated by examining the residuals of a null model and how they correlate with blinkdurations the procedure use a 'default' prior for calculating bayes factors for correlations code here:
Category: Statistical Test
Code:
source("BF_correlations.R") bf_null <- rep(NA, length(unique(d$Subject))) dur_slope <- rep(NA, length(unique(d$Subject))) for(i in 1:length(bf_null)){ d_i <- d[d$Subject==unique(d$Subject)[i] & d$cond1==1,] m0 <- lm(ResponseError~vel1, d_i) m1 <- lm(ResponseError~vel1 + cond1:bdur, d_i) dur_slope[i] <- coef(m1)[3] bf_null[i] <- 1/bf10JeffreysIntegrate(n=nrow(d_i), r=cor(residuals(m0), d_i$bdur)) }

Comment: median and range of BF supporting the null
Category: Statistical Test
Code:
round(median(bf_null[bf_null > 10^(1/2)]),digits=2) round(range(bf_null[bf_null > 10^(1/2)]),digits=2)
File: code.R

Comment: calculate number of days between symptoms
Category: Data Variable
Code:
mutate( ill_where_n=ifelse(sym_temp==1, 1, 0), ill_where_n=cumsum(ill_where_n), ill_where_n=ifelse(sym_temp==1, ill_where_n, NA), prev_day_ill=lag(sym_temp, 1), day_lag=lag(day_date, 1),

Comment: recode illness vars as NA if no specific symptoms during episode
Category: Data Variable
Code:
mutate_at(vars(ill_where_id, ill_where_n, ill_where_start, ill_where_end, ill_where_new), funs(ifelse(any_specif_sym==FALSE, NA,. ))) %>%
File: preflight.r

Comment: remove spaces, brackets, periods in column names
Category: Data Variable
Code:
names(df) <- gsub("\\s+", "", names(df)) names(df) <- gsub("\\(|\\)", "", names(df)) names(df) <- gsub("\\.", "", names(df)) cat(" Ã°ÂÂÂ Column names fixed (no spaces, brackets, periods)\n")
File: f_readRShare.R

Comment: initialization of the vectors with the names of the modueles/variables
Category: Data Variable
Code:
names.modules.df.w <- names.var.modules <- NULL

Comment: list of the directories included in the datadir directory
Category: Data Variable
Code:
my.dirlist <- list.dirs(path = datadir) if (length(my.dirlist) == 0) stop("There are no subdirectories in the directory that you selected.")

Comment: creates a list with the names of the variables included for each module
Category: Data Variable
Code:
names.var.modules <- vector("list", num.waves) names(names.var.modules) <- paste("Wave", waves) if(verbose) cat("Reading data from the selected modules within the waves. \n")

Comment: check which of the specified variables are actually present in the downloaded data
Category: Data Variable
Code:
which.var.ok <- variables.in.modules[[i.mod]] %in% names(new.data) if (any(!which.var.ok)) warning( "Some of the variables that you selected from module ", modules[i.mod], " in wave ", waves[i.wave], " are not included in the data set. \n The variables that could not be imported were: ", variables.in.modules[[i.mod]][!which.var.ok], ". Please check these variables, the other variables were exported. \n" ) new.data <- select(new.data, variables.in.modules[[i.mod]][which.var.ok]) } names(new.data)[-1] <- paste(names(new.data)[-1], modules[i.mod], sep = "...")
File: 2_data_prep_merge.R

Comment: Trim outliers Perform winsorizing (replacefor each individual seperatelyvalues below 5th percentile and values above 95th percentile with 5th and 95th percentile values respectively)
Category: Data Variable
Code:
for(i in min(all.df$person):max(all.df$person)){ all.df$zw.HR[all.df$person == i] <- Winsorize(all.df$z.HR[all.df$person==i]) }
File: lag.Y.R

Comment: Create a lag variable the data is lag within person and within days
Category: Data Variable
Code:
lag.Y = function(data){ Y_lag = rep(0,nrow(data)) subjno.i = unique(data$subjno) for (i in subjno.i){ n.i = which(data$subjno==i) Y_lag[n.i] = shift(data$Y[n.i],1) } return(Y_lag) }
File: MainTables.R

Comment: Personality models Extract standardized parameters and N from personality models
Category: Data Variable
Code:
Values_Analysis1_Model1_Pers <- Values_Personality[which(Values_Personality$analysis == "analysis1" & ((Values_Personality$study %in% c("S1", "S2") & Values_Personality$DV == "well_being") | (Values_Personality$study == "S3" & Values_Personality$DV == "affect_balance")) & Values_Personality$output %in% c("standardized", "N")), ] Values_Analysis1_Model2_Pers <- Values_Personality[which(Values_Personality$analysis == "analysis2" & ((Values_Personality$study %in% c("S1", "S2") & Values_Personality$DV == "well_being") | (Values_Personality$study == "S3" & Values_Personality$DV == "affect_balance")) & Values_Personality$output %in% c("standardized", "N")), ] Values_Analysis1_Model3_Pers <- Values_Personality[which(Values_Personality$analysis == "analysis3" & ((Values_Personality$study %in% c("S1", "S2") & Values_Personality$DV == "well_being") | (Values_Personality$study == "S3" & Values_Personality$DV == "affect_balance")) & Values_Personality$output %in% c("standardized", "N")), ]

Comment: Extract withinperson variances of interactions with close peers, family, and weak ties from unstandardized models
Category: Statistical Modeling
Code:
variances <- Values_Base$est[which(Values_Base$analysis == "analysis3" & ((Values_Base$study %in% c("S1", "S2") & Values_Base$DV == "well_being") | (Values_Base$study == "S3" & Values_Base$DV == "affect_balance")) & Values_Base$output == "unstandardized" & Values_Base$paramHeader == "Variances" & Values_Base$param %in% c("PEERS", "FAMILY", "WEAK_TIES") & Values_Base$BetweenWithin == "Within")] rows <- which(Values_Analysis1_Model3$paramHeader %in% c("S1|WB.ON", "S2|WB.ON", "S3|WB.ON") & Values_Analysis1_Model3$param %in% c("PEERS", "FAMILY", "WEAK_TIES")) # within-person effects variances <- Values_Personality$est[which(Values_Personality$analysis == "analysis3" & ((Values_Personality$study %in% c("S1", "S2") & Values_Personality$DV == "well_being") | (Values_Personality$study == "S3" & Values_Personality$DV == "affect_balance")) & Values_Personality$output == "unstandardized" & Values_Personality$paramHeader == "Variances" & Values_Personality$param %in% c("PEERS", "FAMILY", "WEAK_TIES") & Values_Personality$BetweenWithin == "Within")] rows <- which(Values_Analysis1_Model3_Pers$paramHeader %in% c("S1|WB.ON", "S2|WB.ON", "S3|WB.ON") & Values_Analysis1_Model3_Pers$param %in% c("PEERS", "FAMILY", "WEAK_TIES")) # within-person effects
File: duque_etal_2020_rcode.R

Comment: Model selection for four data sets First find bestfitting random effect model, then test for fixed effect predictors Process is backward by elimintating weakest terms sequentially, starting with full model, until only significant effects remain Nested model comparisons (likelihood ratio tests using anova command) are used to select best fitting models _ Pair Experiment 1 Random effects: selecting empty model
Category: Statistical Modeling
Code:
pair1_rand_full <- lmer(distance ~ (1 | group) + (1 + session0 | pair), data = pair_data1) # full random model;; fails to converge pair1_rand_full <- lmer(distance ~ (1 | group) + (1 + session0 | pair), data = pair_data1, control = lmerControl(optimizer = "bobyqa")) # full random model;; uses bobyqa optimizer pair1_rand2 <- lmer(distance ~ (1 + session0 | pair), data = pair_data1) # drops group ran.intercept;; fails to converge pair1_rand2 <- lmer(distance ~ (1 + session0 | pair), data = pair_data1, control = lmerControl(optimizer = "bobyqa")) # drops group ran.intercept;; uses bobyqa optimizer;; BEST pair1_rand3 <- lmer(distance ~ (1 | pair), data = pair_data1) # drops random slope
File: stan_AWB_adriana_pools5i_vary_mic.r

Comment: Pearson's correlation calculation
Category: Statistical Test
Code:
calc_r <- function(model_vector, data_vector, S_0, D_0, M_0, E_0, filename) { sst_mean <- mean(data_vector) sst_vector <- (data_vector - sst_mean) ^ 2 sst <- sum(sst_vector) ssr_vector <- (data_vector - model_vector) ^ 2 ssr <- sum(ssr_vector) r_sq <- 1 - (ssr / sst) cat(r_sq, file = paste(format(Sys.time(),"%Y_%m_%d_%H_%M"), filename, "r_sq", "S", S_0, "D", D_0, "M", M_0, "E", E_0, ".txt", sep = "_")) return(r_sq) } r_sq <- calc_r(CO2_flux_ratios_hat_median, data_vector, S_0, D_0, M_0, E_0, filename)
File: elsa_analyses.R

Comment: Data wrangling recode values for missing data (9, 1) in whole dataset as NA
Category: Data Variable
Code:
data <- data %>% mutate_all(~na_if(., -9)) data <- data %>% mutate_all(~na_if(., -1))

Comment: age recode values of 99 as missing
Category: Data Variable
Code:
data$indager.w2[data$indager.w2 == 99] <- NA data$age <- data$indager.w2
File: 06_sensitivity-tests.R

Comment: Fit models with trimmed weights Weighted regression model for SciPop Score (Goertz approach)
Category: Statistical Modeling
Code:
m3.scipopgoertz.trim.svyglm.fit <- svyglm(scipopgoertz ~ age + gender + education.comp + education.uni + sciprox.score + urbanity.log + languageregion.ger + languageregion.ita + polorientation + religiosity + interestscience + sciliteracy + trustscience + trustscientists, design = bar.design.scipopgoertz.trim, family = gaussian, na.action = na.omit)
File: plot.fix.e1.R

Comment: for each row assign fixation probability (1 or 0) to each picture based on the activation !! need a better decision criteria when the activations are the same;; !! right now it assigns '1' to both
Category: Data Variable
Code:
dt.act$max.act = apply(dt.act[,4:7], 1, max) dt.act = subset(dt.act, max.act != 0)
File: Simonsohn_twolines_tweaked.R

Comment: 4.4.4) Create data where u(x) is at sample means to get residuals based on rest of models to act as yobs Recall: columns 1 & 2 have y and u(x) in obs.data
Category: Data Variable
Code:
data.xufixed =data.obs data.xufixed[,2]=mean(data.obs[,2]) #Note, the 1st predictor, 2nd columns, is always the one hypothesized to be u-shaped

Comment: 6 RUN TWO LINE REGRESSIONS 6.1 First an interrupted regression at the midpoint of the flat region
Category: Statistical Modeling
Code:
rmid=reg2(f,xc=median(xflat),graph=0, axislabels=axislabels)
File: Stats_figures_JBT.R

Comment: Pairwise comparison of optimism scores for each cue and table Wilcoxon signedrank test
Category: Statistical Test
Code:
cue_diff_wilcox_ts = wilcox.paired.multcomp( opt_score ~ cue | id, subset(jbt_all, jbt_all$cjb_test == "ts"), p.method = "holm") cue_diff_wilcox_tunnel = wilcox.paired.multcomp( opt_score ~ cue | id, subset(jbt_all, jbt_all$cjb_test == "tunnel"), p.method = "holm")

Comment: round the numeric values (p that is not < 0.001)
Category: Data Variable
Code:
cue_diff_wilcox_ts$p.value[numeric_values] <- round(as.numeric(cue_diff_wilcox_ts$p.value[numeric_values]), 3) names(cue_diff_wilcox_ts) <- c("Cues compared","p-value")
File: 4_1_deidentification.R

Comment: new tibble with IDs and emails
Category: Data Variable
Code:
wos_emails <- tibble( "responseID" = wos$response_ID, "email" = wos$email ) aaas_emails <- tibble( "responseID" = aaas$response_ID, "email" = aaas$email )

Comment: drop rows with empty email fields
Category: Data Variable
Code:
wos_emails <- drop_na( wos_emails, email ) aaas_emails <- drop_na( aaas_emails, email )
File: 2H_Recode_helper.R

Comment: getmode() Get mode of a variable Input: numeric vector Output: single number
Category: Data Variable
Code:
getmode <- function(v) { uniqv <- unique(v) uniqv[which.max(tabulate(match(v, uniqv)))] }

Comment: For studyProgramme remove countries with only one programme
Category: Data Variable
Code:
if(varname == "studyProgram" & length(lev) == 1){ return(NA) }
File: ExperimentS1-Analyses.R

Comment: Model for Frequency DV
Category: Data Variable
Code:
mod1.1 <- lmer(frequency ~ ruleType + (1|sceneType) + (1|Participant), contrasts = my.contrasts, data = PD3a.Long) icc(mod1.1) summary(mod1.1) emmeans(mod1.1,list(pairwise~ruleType),adjust="satterthwaite") confint(mod1.1)
File: 02_analysis.R

Comment: Define functions Means, SDs, and two sample ttests comparing Swiss census data and the panel sample
Category: Statistical Test
Code:
census.msd <- function(v) { v <- reformulate(v) cbind( as.data.frame(svyby(v, ~t, dslong_dsgn, svymean, na.rm = T))[-c(1,3)], # M (exclude SE) sqrt(as.data.frame(svyby(v, ~t, dslong_dsgn, svyvar, na.rm = T)[[2]]))) %>% # SD (with a workaround) set_colnames(c("M", "SD")) %>% set_rownames(c("2019 (census)", "2019 (panel)")) }

Comment: RQ1: Examine predictors of change in SciPop Scores and subscale scores .. Visual inspection with Sankey plot Visualize withinsubject change in SciPop Score in Sankey plot
Category: Visualization
Code:
dslongpnl %>% group_by(t, scipopgoertz) %>% summarise(scipopgoertz_freq = n()) %>% merge(dslongpnl, by = c("scipopgoertz", "t")) %>% transform(scipopgoertz_lvls = factor(scipopgoertz, levels = c("5", "4.5", "4", "3.5", "3", "2.5", "2", "1.5", "1", "NA"))) %>% replace_na(list(scipopgoertz_lvls = "NA")) %>% ggplot(aes(x = t, stratum = scipopgoertz_lvls, alluvium = id, y = scipopgoertz_freq, fill = scipopgoertz_lvls, label = scipopgoertz_lvls)) + scale_x_discrete(expand = c(.1, .1)) + scale_fill_viridis_d() + geom_flow(width = .1) + geom_stratum(alpha = .5, width = .1) + geom_text(stat = "stratum", size = 4) + ggtitle("Sankey plot of within-subject change in SciPop Score") + theme_minimal() + theme(legend.position = "none", panel.grid = element_blank(), axis.text.y = element_blank(), axis.ticks.y = element_blank())

Comment: H1 analyses .. Descriptive analyses Plot means, SDs, skewness, kurtosis of alternative SciPop Scores
Category: Visualization
Code:
meantbl <- as.data.frame(matrix(0, nrow = 2)) groups <- quos(scipopgoertz, scipopbollenm, scipopbollencfa, scipopsartori75, scipopsartoricat) for (j in seq_along(groups)) { meantbl <- cbind(meantbl, group_by(dslongpnl, t) %>% summarise(mean = mean(!!groups[[j]], na.rm = T), sd = sd(!!groups[[j]], na.rm = T), skewness = skewness(!!groups[[j]], na.rm = T), kurtosis = kurtosis(!!groups[[j]], na.rm = T))) names(meantbl)[names(meantbl) == "mean"] <- paste0(quo_text(groups[[j]]), " (M)") names(meantbl)[names(meantbl) == "sd"] <- paste0(quo_text(groups[[j]]), " (SD)") names(meantbl)[names(meantbl) == "skewness"] <- paste0(quo_text(groups[[j]]), " (Skewness)") names(meantbl)[names(meantbl) == "kurtosis"] <- paste0(quo_text(groups[[j]]), " (Kurtosis)") meantbl <- select(meantbl, contains("scipop")) %>% set_rownames(c("2019", "2020")) }
File: PrepareData.R

Comment: save means and compute their higher order terms
Category: Statistical Modeling
Code:
dfs$x.mean <- mean( dfs$x, na.rm = TRUE ) dfs$y.mean <- mean( dfs$y, na.rm = TRUE ) dfs$x2.mean <- dfs$x.mean^2 dfs$xy.mean <- dfs$x.mean*dfs$y.mean dfs$y2.mean <- dfs$y.mean^2 dfs }
File: Analyses for revision

Comment: add column indicating if individual gave birth during testing (this will help with age classification)
Category: Data Variable
Code:
birthsanc <- read_excel("motherssanctuary.xlsx", col_types=c("text", "date")) bigdatasanctuary$Individual<-as.factor(bigdatasanctuary$Individual) birthsanc$Mother <- as.factor(birthsanc$Mother) bigdatasanctuary$mother <- ifelse(bigdatasanctuary$Individual %in% birthsanc$Mother, "yes", "no") bigdatasanctuary$birth <- birthsanc$Date[match(bigdatasanctuary$Individual, birthsanc$Mother)] bigdatasanctuary$birth <- as.Date(bigdatasanctuary$birth, format="YY-mm-dd") bigdatasanctuary$testbeforebirth <- ifelse(!is.na(bigdatasanctuary$birth) & bigdatasanctuary$birth > bigdatasanctuary$TestDate, "yes", "no") bigdatasanctuary$AgeAtTesting <- as.numeric(bigdatasanctuary$AgeAtTesting)
File: illustration.R

Comment: Step 1 compare the rising ridge asymmetric congruence model (RRCA) and the full thirdorder model (cubic)
Category: Statistical Modeling
Code:
rrca_comp <- compare2(rrca_myrsa, "RRCA", "cubic") rrca_comp

Comment: How much variance in the outcome can be explained by the full thirdorder polynomial model/the rising ridge leveldependent congruence model?
Category: Statistical Modeling
Code:
getPar(rrcl_myrsa, model="cubic", type="R2") getPar(rrcl_myrsa, model="RRCL", type="R2")
File: get_first_free_fi.R

Comment: get subsequent fixation index (+1) and retrieve row number using fi_pars and assign
Category: Data Variable
Code:
scope_start[i] <- fi_pairs$fistart[scope_start_fis[i] + 1] } return(scope_start) }
File: 01b_DataPrep_Study2.R

Comment: Exclude participants who completed less than 10 surveys
Category: Data Variable
Code:
dat <- dat[-which(dat$N < 10), ] dim(dat) # 36074 assessments length(unique(dat$id)) # 1177 participants (1109 participants excluded)
File: ComF_helpers.R

Comment: define function to compute colors and point sizes that yield 3d effect
Category: Visualization
Code:
points3d <- function(data, xname, yname, zname, cex.limit.close = 1.7, cex.limit.far = 1, col.limit.close = 0.1, col.limit.far = 0.8, adapted_eye = list(x=-12, y=-16, z=2) ){

Comment: for each row of the data, compute euclidean distance between the person's 3dim point and the plane
Category: Data Variable
Code:
distance <- abs( (data[,xname] - a$x) * n$x + (data[,yname] - a$y) * n$y + (data[,zname] - a$z) * n$z ) / sqrt(n$x^2 + n$y^2 + n$z^2)
File: af_testosterone_analysis.R

Comment: Calculate delta change in testosterone pivot data sets for delta values
Category: Data Variable
Code:
hormones_wide <-hormones %>% pivot_wider(id_cols = c("id", "sex"), names_from = condition, values_from = t_conc_corr) %>% mutate(delta_t = back_home - baseline) delta_t <- left_join(hormones, hormones_wide) delta_t <- delta_t %>% filter(condition == "baseline")%>% filter(!is.na(delta_t))

Comment: Plot sex and time point Boxplot for sex differences
Category: Visualization
Code:
t_condition <- hormones %>% ggplot(aes(x = condition, y = log(t_conc_corr), fill = sex)) + geom_boxplot(outlier.shape = NA, width = 0.7) +
File: workshop_example.R

Comment: Network Estimation Ising Model (Binary Data) can be estimated via estimateNetwork variables automatically binarized at median estimate regularized logistic nodewise regression network define where to binarize variables eLASSO (LASSO with EBIC model selection) listwise deletion of missing values (pairwise not possible for regressions)
Category: Statistical Modeling
Code:
Ising_net <- estimateNetwork(data, default = "IsingFit", missing = "listwise", rule = "OR")

Comment: compare GGM and Ising model correlating weights matrices
Category: Statistical Modeling
Code:
cor.test(Wmat_GGM[upper.tri(Wmat_GGM)], Wmat_Ising[upper.tri(Wmat_Ising)]) #.80
File: getLooks.r

Comment: create a storage container (i.e. a empty lists) for all hit_names ... ... that track looking times over all trials (e.g., looking_times$left)
Category: Data Variable
Code:
looking_times <- setNames(vector("list", length(hit_names)), hit_names)

Comment: create a storage container for all looking frequencies (i.e., counting the number of looks within an AOI)
Category: Data Variable
Code:
looking_frequencies <- setNames(vector("list", length(hit_names)), hit_names)

Comment: init storage containers for looking frequencies
Category: Data Variable
Code:
current_trial_total_looks <- setNames(vector("list", length(hit_names)), hit_names) for (hn in hit_names) {

Comment: get first and last FixationIndex (remove NAs), which define the boundaries of a single trial
Category: Data Variable
Code:
min_FixationIndex <- min(inter_trial_FixationIndexes, na.rm = TRUE) max_FixationIndex <- max(inter_trial_FixationIndexes, na.rm = TRUE)
File: my_utils.R

Comment: space between axis label and tick mark labels
Category: Visualization
Code:
my_settings$layout.widths$ylab.axis.padding <- 0.2 my_settings$layout.heights$axis.xlab.padding <- 0.2 my_settings$box.rectangle$col = 1 my_settings$box.umbrella$col = 1 my_settings$box.dot$col = 1 my_settings$plot.symbol$col = 1
File: 06_extrapermut_comaprison_with_random.R

Comment: Overlay the basic grid with colourful grid corresponding to the limits of sensitive period rectangles. These colourful lines should start in the points indicating the change values.
Category: Visualization
Code:
cols<-colscale[sapply(result$p1,function(x){which.min(abs(x-scaleseq))})] cols<-colscale[sapply(result$p1.rand[,exrun],function(x){which.min(abs(x-scaleseq))})]
File: Exp1.R

Comment: Skew effect
Category: Visualization
Code:
neg <- apply(chains[,c(1,3)], 1, sum) pos <- apply(chains[,c(1,2)], 1, sum) quantile(neg-pos, prob=c(.025, .975)) neg <- apply(chains[,c(1,3)], 1, sum) pos <- apply(chains[,c(1,2)], 1, sum) quantile(pos-neg, prob=c(.025, .975))

Comment: Fit hierarchical Bayesian model
Category: Statistical Modeling
Code:
fit.HBM <- stan(file='CAM_full_1.stan', data=c('Nobs','Nind','stim','bias','RM','AS','B1','id','mid','stim_sizes','Nstim'), chains=4, iter=2500, cores=no_cores, control=list(adapt_delta=.90, max_treedepth=15)) fit.HBM sum(summary(fit.HBM)$summary[,'Rhat'] > 1.01) pars <- extract(fit.HBM)