ID
int64 1
1.07k
| Comment
stringlengths 8
1.13k
| Code
stringlengths 10
4.28k
| Label
stringclasses 4
values | Source
stringlengths 21
21
| File
stringlengths 4
82
|
---|---|---|---|---|---|
601 |
Coding past experiences into binary variables
|
data <- data %>% mutate_at(vars("graphic_exp":"attentioncheck_exp"), list(buc = bucketing_experienced)) %>% glimpse
|
Data Variable
|
https://osf.io/3aryn/
|
3VariableCreation.R
|
602 |
Coding behaviors into binary variables 0 unselected, 1 selected
|
data <- data %>% mutate_at(vars("behavior_donation":"behavior_none"), list(bin = binary.behavior)) %>% glimpse
|
Data Variable
|
https://osf.io/3aryn/
|
3VariableCreation.R
|
603 |
Creating a combined race/ethnicity variable
|
data <- data %>% mutate(race.eth = case_when(hispanic == "Yes" ~ "Hispanic or Latinx", race == "Caucasian/White" & hispanic == "No" ~ "White, Non-Latinx", race == "Black or African-American" & hispanic == "No" ~ "Black, Non-Latinx", race == "Asian" & hispanic == "No" ~ "Asian", race == "Multi-Racial" & hispanic == "No" ~ "Multi-Racial", TRUE ~ "Other Races/Ethnicities"))
|
Data Variable
|
https://osf.io/3aryn/
|
3VariableCreation.R
|
604 |
correlations between csd_mean and averaged csds for Big Five traits (not mentioned in the text):
|
psych::corr.test( df2$e_csd,df2$csd_mean_e ) psych::corr.test( df2$a_csd,df2$csd_mean_a ) psych::corr.test( df2$pa_csd,df2$csd_mean_pa ) psych::corr.test( df2$na_csd,df2$csd_mean_na )
|
Data Variable
|
https://osf.io/tajd9/
|
Flux_MainDataAnalyses.R
|
605 |
Participants could select all response options that applied to them in any given situation. Here, we create one dummy variable for every response option.
|
for (i in 1:length(survey$interacting_by)) { v <- unlist(strsplit(survey$interacting_by[i], ",")) if (is.element("1", v)) { survey$TiP[i] <- 1 } if (is.element("2", v)) { survey$ToP[i] <- 1 } if (is.element("3", v)) { survey$TM[i] <- 1 } if (is.element("4", v)) { survey$ChattingWHATSAPP[i] <- 1 } if (is.element("5", v)) { survey$ChattingDATING[i] <- 1 } if (is.element("6", v)) { survey$Emailing[i] <- 1 } if (is.element("7", v)) { survey$Videochatting[i] <- 1 } if (is.element("8", v)) { survey$Facebook[i] <- 1 } if (is.element("9", v)) { survey$Instagram[i] <- 1 } if (is.element("10", v)) { survey$Snapchat[i] <- 1 } if (is.element("11", v)) { survey$Twitter[i] <- 1 } if (is.element("12", v)) { survey$OTHER[i] <- 1 } if (is.element("0", v)) { survey$NoInteraction[i] <- 1 } if (is.element("999", v)) { survey$SKIP[i] <- 1 } } for (i in 1:length(survey$interacting_people)){ v <- unlist(strsplit(survey$interacting_people[i], ",")) if (is.element("1", v)) { survey$Classmates[i] <- 1 } if (is.element("2", v)) { survey$Coworkers[i] <- 1 } if (is.element("3", v)) { survey$Family[i] <- 1 } if (is.element("4", v)) { survey$Friends[i] <- 1 } if (is.element("5", v)) { survey$Roommates[i] <- 1 } if (is.element("6", v)) { survey$Significant_other[i] <- 1 } if (is.element("7", v)) { survey$Strangers[i] <- 1 } if (is.element("8", v)) { survey$OTHER2[i] <- 1 } if (is.element("999", v)) { survey$SKIP2[i] <- 1 } }
|
Data Variable
|
https://osf.io/nxyh3/
|
Data_Prep_S1S2.R
|
606 |
Rescore so high values are what we expect to be positive predictors (e.g. female 2 male 1)
|
df$Nationality2 <- df$Nationality df$Nationality2 <- as.integer(df$Nationality2 %in% "Dutch") df$Nationality2[df$Nationality2==0] <- 2 df$Nationality2[df$Nationality2==1] <- 0 df$Nationality2[df$Nationality2==2] <- 1 # Dutch=0 (36), Rest=1 (44) count(df$Nationality2) df$RelationshipStatus2 <- df$RelationshipStatus df$RelationshipStatus2 <- recode(df$RelationshipStatus2, "3" = 2) df$RelationshipStatus2[df$RelationshipStatus2==2] <- 0 # Partnered=0 (30), Single=1 (50) count(df$RelationshipStatus2) df$Gender2 <- df$Gender # df$Gender2[df$Gender2==3] <- NA # code 1 nonbinary participant as NA for this to avoid 3 levels df$Gender2[df$Gender2==1] <- 0 df$Gender2[df$Gender2==2] <- 1 # men=0 (19), women=1 (60), 1 NA count(df$Gender2) df$WorkStatus2 <- df$WorkStatus df$WorkStatus2[df$WorkStatus2==2] <- 0 # 54no, 26yes count(df$WorkStatus2) df$MentalHealth2 <- as.numeric(df$MentalHealth) df$MentalHealth2[df$MentalHealth2==1] <- 0 df$MentalHealth2[df$MentalHealth2==2] <- 1 # healthy=0 (59), history=1 (17), 4 NA count(df$MentalHealth2) df$selfefficacy_pre2 <- df$selfefficacy_pre*-1 # reverse code
|
Data Variable
|
https://osf.io/mvdpe/
|
4. Compare pre-post.R
|
607 |
Rating Means and Standard Deviations of Conditions Unspecified Rating
|
round(mean(unspecified$rating), 2) round(sd(unspecified$rating), 2)
|
Statistical Test
|
https://osf.io/9tnmv/
|
Exp4_buddhist_post.R
|
608 |
Save and export image as .eps (8.18 x 4.88 inch)
|
if(saveFigures) cairo_ps(file = '../R_Output/Images/AccuracyPerProject_Revision.eps', onefile = TRUE, fallback_resolution = 600, width = 8.18, height = 4.88) par(cex.main = 2.2, mar = c(5, 5.5, 2, 2) + 0.1, mgp = c(3, 1, 0), cex.lab = 2, font.lab = 1, cex.axis = 1.6, bty = 'n', las = 1) plot(x = c(.5, .8), y = c(0, 50), type = 'n', xlab = expression(paste("Accuracy Rate ", omega, " (in %)")), ylab = 'Density', main = '', axes = FALSE) axis(2, lwd.tick = 0, labels = FALSE) axis(1, at = seq(.5, .8, by = .05), labels = seq(50, 80, by = 5)) d <- lapply(split(df$omega, df$condition), density) Map(function(dens, col) polygon(dens, col = col), dens = d, col = figureColors[['cols.transparent']]) text(.64,44.5,'Laypeople\n(Evidence)', cex = 1.3) text(.55,44.5,'Laypeople\n(Description)', cex = 1.3) text(.621,25,'Experts\nML2', cex = 1.3) text(.75,25, 'Experts\nSSRP', cex = 1.3) graphics.off()
|
Visualization
|
https://osf.io/x72cy/
|
ExploratoryAnalyses.R
|
609 |
function to calculate AUC
|
groupAUC.description <- pnorm(description.mud / sqrt(2)) # signal distribution has sigma = 1 quantile(groupAUC.description, c(0.025, 0.5, 0.975)) groupAUC.evidence <- pnorm(evidence.mud / sqrt(2)) # signal distribution has sigma = 1 quantile(groupAUC.evidence, c(0.025, 0.5, 0.975))
|
Statistical Modeling
|
https://osf.io/x72cy/
|
ExploratoryAnalyses.R
|
610 |
get relevant information compute mode of signal distribution
|
estimate_mode <- function(x) { d <- density(x) d$x[which.max(d$y)] } modeD <- estimate_mode(mud) medianC <- median(muc) empiricalLambda <- (0.5*modeD) + medianC
|
Statistical Modeling
|
https://osf.io/x72cy/
|
ExploratoryAnalyses.R
|
611 |
compute CIs for each value of lambda
|
probD <- quantile(mud, probs = probs) for (i in seq_len(nPoints)){ c <- lambdas[i] - (0.5 * probD) qph[i, ] <- pnorm((0.5 * probD) - c) }
|
Statistical Test
|
https://osf.io/x72cy/
|
ExploratoryAnalyses.R
|
612 |
get the posterior distributions of the intercepts, transformed to rate scale
|
post.description <- inv_logit_scaled(posterior_samples(m.studies, 'b_intercept'))[,1] post.evidence <- inv_logit_scaled(posterior_samples(m.studies, 'b_intercept') + posterior_samples(m.studies, 'b_conditionDescriptionPlusEvidence'))[,1]
|
Statistical Modeling
|
https://osf.io/x72cy/
|
ExploratoryAnalyses.R
|
613 |
add the observed average accuracy per study and per condition
|
fit$obs.accuracy <- c(aggregate(dat$guessed.correctly, list(condition = dat$condition), mean)[,'x'], aggregate(dat$guessed.correctly, list(study = dat$study, condition = dat$condition), mean)[,'x'])
|
Data Variable
|
https://osf.io/x72cy/
|
ExploratoryAnalyses.R
|
614 |
Create a binary trial type variable 0 Go, 1 No Go
|
sart$trial_type <- sart$code sart$trial_type[sart$code == 3] <- NA sart$trial_type <- as.factor(sart$trial_type-1)
|
Data Variable
|
https://osf.io/7vbtr/
|
Gyurkovics_Stafford_Levita_analyses.R
|
615 |
Calculate Go RT coefficient of variation (CV) to index intraindividual variability
|
sartsub$go_cv <- sartsub$gosd / sartsub$gomean sart <- merge(sart, sartsub[,c(1,5,6,9)], by = "subid")
|
Statistical Test
|
https://osf.io/7vbtr/
|
Gyurkovics_Stafford_Levita_analyses.R
|
616 |
Add CSE variables to the MW probe data set
|
probes <- merge(probes, cse_wide[,c("subid","cse","ce","csez","cez")], by = "subid")
|
Data Variable
|
https://osf.io/7vbtr/
|
Gyurkovics_Stafford_Levita_analyses.R
|
617 |
read in, display, and summarize 'csv' data
|
data_raw <- read.table("osylv_spaceuse_raw.csv", header = T, sep =",") head(data_raw)
|
Data Variable
|
https://osf.io/3bpn6/
|
osylv_sitecomparison.R
|
618 |
Add collumns with delta distance and delta time
|
tracks <- tracks %>% group_by(id) %>% mutate(time_diff = difftime(dt, lag(dt, n = 1L), units = "min"), delta_x = x_utm - lag(x_utm, n = 1L), delta_y = y_utm - lag(y_utm, n = 1L), dist = sqrt(delta_x^2+delta_y^2))
|
Data Variable
|
https://osf.io/3bpn6/
|
osylv_sitecomparison.R
|
619 |
boxplot of maximum dist per id
|
maxdist_plot <- ggplot(daily_perid, aes(x= sex, y=max_dist_perid, fill = sex)) + theme_bw(20) + geom_boxplot(aes(fill = sex), outlier.shape = NA) + labs(y = "Longest movement (m)") + geom_jitter(aes(fill=sex), position=position_jitterdodge(0.2), shape = 21, size = 4, alpha=0.4) + facet_wrap(~site, labeller = labeller( site=c(can ="Natural site", oto = "Enclosures"))) + scale_x_discrete(labels= c("F", "M")) + theme(legend.position= "none", axis.title.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_text(color = "black", size = 18), aspect.ratio = 3) + ylim(0, 25) # excludes one male point at >40m from Canande maxdist_plot
|
Visualization
|
https://osf.io/3bpn6/
|
osylv_sitecomparison.R
|
620 |
centering a variable to a range from 0.5 to 0.5
|
center <- function(x) { minimum <- min(x) maximum <- max(x) return((x - (minimum + maximum)/2)/(maximum - minimum)) }
|
Data Variable
|
https://osf.io/9qbwv/
|
helper.R
|
621 |
keep only data from 2003 onwards (because fid started in 2003)
|
survival <- subset(survival, year >2002)
|
Data Variable
|
https://osf.io/3wy58/
|
bivariate_model_winter_revision.R
|
622 |
identify influenial points (e.g., cooksD > 6/n)
|
influential_obs <- as.numeric(names(cooksD)[(cooksD > (6/n))])
|
Statistical Modeling
|
https://osf.io/3bpn6/
|
all_navigation_models.R
|
623 |
function serves to plot all important information what is plotted can be modified by whatplot argument first predict value line second confidence interval third points fourth axis fifth summary of the end point sixth corresponding line
|
nice.plot<-function(X=describe$generation,Y,maxY,minY=0,col,whatplot=c(T,T,T,T,T,T),ofset=0,name="",labs=c(minY,ifelse(explarge==T,signif(maxY,nsignif),maxY)),span=0.18,end=length(X),roundrep=0,nsignif=3,percentual=F,explarge=F,labrep=ifelse(explarge==T,signif((ci[,1][newend]*(maxY-minY)+minY),nsignif),ifelse(percentual==T,paste(round((ci[,1][newend]*(maxY-minY)+minY)*100,roundrep),"%",sep=""),round((ci[,1][newend]*(maxY-minY)+minY),roundrep))),cextext=1,lwdmain=2,mtextcex=1,firstax=-0.3,smooth=F){ col.li<-col col.ci<-paste(col,"20",sep="") col.po<-paste(col,"33",sep="") Y<-(Y-minY)/(maxY-minY) if(whatplot[3]==T){ points(X[1:end],Y[1:end],col=col.po,pch=16) } tryCatch({ lo <- loess(Y~X,degree=1,span=span) newX <- seq(min(X),max(X), length.out=1000) ci = cbind( predict(lo, data.frame(X=newX)), predict(lo, data.frame(X=newX))+ predict(lo, data.frame(X=newX), se=TRUE)$se.fit*qnorm(1-.05/2), predict(lo, data.frame(X=newX))- predict(lo, data.frame(X=newX), se=TRUE)$se.fit*qnorm(1-.05/2) ) }, error = function(e){ print("warning: loess returned error, original values instead of loess smoothed curved are visualized") newX <- X ci = cbind(Y,Y,Y) }) newend<-which.min(abs(newX-end)) if(smooth==F){ newY <- approx(Y,n=1000)$y ci <- cbind(newY,newY,newY) } if(whatplot[1]==T){ lines(newX[1:newend], ci[,1][1:newend], lwd=lwdmain,col=col.li) } if(whatplot[2]==T){ if(smooth==T){ polygon(c(newX[1:newend],rev(newX[1:newend])), c(ci[,2][1:newend],rev(ci[,3][1:newend])), col=col.ci,border=NA) } } if(whatplot[4]==T){ par(mgp=c(3,ofset+firstax,ofset+firstax-0.2)) axis(2,at=c(0,1),lab=c("",""),col=col.li,col.axis=col.li,tck=-0.008) mtext(name,2,line=ofset+firstax,col=col.li,cex=mtextcex) mtext(labs,at=c(0,1),2,line=ofset+firstax,col=col.li,cex=mtextcex) } xtext<-par("usr")[2]-(par("usr")[2]-par("usr")[1])/50 if(whatplot[5]==T){ text(xtext,ci[,1][newend],labrep,col=col.li,xpd=T,pos=4,cex=cextext) } if(whatplot[6]==T){ lines(c(0,xtext),rep(ci[,1][newend],2),col=col.li,lty=3,xpd=T) } }
|
Visualization
|
https://osf.io/pvyhe/
|
visualize_niceplot.R
|
624 |
We draw a lollipop diagram to illustrate color distribution
|
par(ps = PS, mar = c(5, 5, 4, 2) + 0.1) plot(x = graphData$colour, y = graphData$Beach, type = "p", col = col_beach, ylim = c(0, 65), xlab = "Colour", ylab = "Proportion [%]", pch = PCH, xaxt = "n", cex = SS) axis(1, at = seq(1, 6, by = 1), labels = c("White", "Beige", "Grey", "Yellow", "Red", "Black")) par(ps = PS, new = TRUE, mar = c(5, 5, 4, 2) + 0.1) plot(x = graphData$colour, y = graphData$Wreck, type = "p", col = col_wreck, ylim = c(0, 65), axes = FALSE, xlab = "", ylab = "", pch = PCH, cex = SS) arrows(x0 = graphData$colour, x1 = graphData$colour, y0 = graphData$Beach, y1 = graphData$Wreck, angle = 90, length = 0, ) legend("topright", legend = c("Beach", "Wreck"), fill = c(col_beach, col_wreck), bty = "n")
|
Visualization
|
https://osf.io/9jxzs/
|
03_analysis_color.R
|
625 |
Extract model statistics Extract coefficients and std errors
|
model_coefs <- glmm_list %>% plyr::ldply(.fun = tidy) %>% subset(group == 'fixed') %>% droplevels
|
Statistical Modeling
|
https://osf.io/x8vyw/
|
03_glmm_analysis.R
|
626 |
Regression test for funnel plot asymmetry
|
res <- rma(Z_value,Z_var, data=data1, measure = "ZCOR", method = "ML") regtest(res, predictor = "vi")
|
Visualization
|
https://osf.io/kpe75/
|
analysis.R
|
627 |
build a new matrix that includes the formatted correlations and their significance stars
|
Rnew <- matrix(Rformatted, ncol = ncol(x)) rownames(Rnew) <- colnames(x) colnames(Rnew) <- paste(colnames(x), "", sep =" ")
|
Data Variable
|
https://osf.io/6jmke/
|
custom_functions.R
|
628 |
CLEAR ENVIRONMENT function to clear the environment after running a script while keeping important objects use clear_environment: add store_to_keep variable with list variables;; tip: include a variable with curr_env
|
clear_environment <- function(keep, # vector with variable-names to be excluded from cleaning all=ls(envir=pos.to.env(1))){ rm(list = all[! all %in% keep], envir = pos.to.env(1)) }
|
Data Variable
|
https://osf.io/6jmke/
|
custom_functions.R
|
629 |
boxplot visualizing the differences between the three languages
|
par(mfrow = c(1,1)) boxplot(ReadRate ~ Language, data = joint.read_rate, main = "Reading rate, words/minute")
|
Visualization
|
https://osf.io/ex9fj/
|
RCode_Final_24Feb20.R
|
630 |
zscore RSES T1 and T2
|
df2$RSES1Z <- (df2$RSES1 - mean(df2$RSES1))/sd(df2$RSES1) df2$RSES2Z <- (df2$RSES2 - mean(df2$RSES2, na.rm = TRUE))/sd(df2$RSES2, na.rm = TRUE)
|
Statistical Test
|
https://osf.io/9jzfr/
|
20180513Study3Analysis.R
|
631 |
ANALYSES Does Att Valence differ across Sections, OA Practice, and Level?
|
mod_attvalence <- lmer(Att~Level*Section*OAPractice+(1|Responder_ID), df_attvalence) summary(mod_attvalence) anova(mod_attvalence) eta_sq(mod_attvalence, partial = TRUE)
|
Data Variable
|
https://osf.io/qbgct/
|
code_analyses.R
|
632 |
Create variable Past_Future from Item.
|
df_use$Past_Future <- recode(df_use$Item, P1Use01 = "In the past 12 months",P1Use02 = "In the following 12 months", P2Use01 = "In the past 12 months",P2Use02 = "In the following 12 months", P3Use01 = "In the past 12 months",P3Use02 = "In the following 12 months", P4Use01 = "In the past 12 months",P4Use02 = "In the following 12 months", P5Use01 = "In the past 12 months",P5Use02 = "In the following 12 months")
|
Data Variable
|
https://osf.io/qbgct/
|
code_analyses.R
|
633 |
Calculate average level of Att across Perspectives.
|
df_use_attvalence$Att <- rowMeans(df_use_attvalence[,c('Att_DailyLife', 'Att_ResearchField', 'Att_PublicSociety')], na.rm=TRUE)
|
Data Variable
|
https://osf.io/qbgct/
|
code_analyses.R
|
634 |
Formula and family specification In our case, setting `k 4` and `bs 'cr'` in the mgcv::s() smooth term is not overly restrictive (checked by running the frequentist mgcv::gam() function for each existing activity index in turn, thereby varying arguments `k` and `bs`, and then checking the summary() of the resulting fits), but in a future (prospective) study, the mgcv::s() settings need to be checked again:
|
C_formula <- as.formula(paste(voutc, "~", paste0("s(", vactidx_i, ", k = 4, bs = 'cr')"))) C_family <- cumulative(link = "logit", link_disc = "log", threshold = "flexible")
|
Statistical Modeling
|
https://osf.io/emwgp/
|
comparison_smooth.R
|
635 |
display relationships between WVSES and associated variables
|
ggplot(df11, aes(WVSES, SE)) + geom_jitter() ggplot(df11, aes(WVSES, SISE)) + geom_jitter() ggplot(df11, aes(WVSES, ANX)) + geom_jitter() ggplot(df11, aes(WVSES, AVO)) + geom_jitter() ggplot(df11, aes(WVSES, LIFE)) + geom_jitter() ggplot(df11, aes(WVSES, EXTRA)) + geom_jitter() ggplot(df11, aes(WVSES, AGREE)) + geom_jitter() ggplot(df11, aes(WVSES, CON)) + geom_jitter() ggplot(df11, aes(WVSES, NEUR)) + geom_jitter() ggplot(df11, aes(WVSES, OPEN)) + geom_jitter() ggplot(df11, aes(WVSES, SSTA)) + geom_jitter() ggplot(df11, aes(WVSES, SINC)) + geom_jitter() ggplot(df11, aes(WVSES, MDS)) + geom_jitter()
|
Visualization
|
https://osf.io/9jzfr/
|
20180714Study1analysisscript.R
|
636 |
take RSES and run confirmatory factor analysis
|
RSESdata <- data.frame(df11$SE1, df11$SE2, df11$SE3, df11$SE4, df11$SE5, df11$SE6, df11$SE7, df11$SE8, df11$SE9, df11$SE10) singleF.model <- 'SE =~ df11.SE1 + df11.SE2 + df11.SE3 + df11.SE4 + df11.SE5 + df11.SE6 + df11.SE7 + df11.SE8 + df11.SE9 + df11.SE10'
|
Statistical Modeling
|
https://osf.io/9jzfr/
|
20180714Study1analysisscript.R
|
637 |
pivot authorlevel data to "longer" authorarticlelevel dataframe
|
article_author_level <- author_level %>% dplyr::select(FirstName_MI_LastName_str, full_name.kap, Article.1.Code.kap, Article.2.Code.kap, Article.3.Code.kap, Article.4.Code.kap, Article.5.Code.kap, Article.6.Code.kap, Article.7.Code.kap, Article.8.Code.kap, Article.9.Code.kap, Article.10.Code.kap, Gender.apsa, R_E.apsa, PhD.Year, PhD.Institution) %>% pivot_longer(cols = -c(FirstName_MI_LastName_str, full_name.kap, Gender.apsa, R_E.apsa, PhD.Year, PhD.Institution), values_to = "article_title", names_to = "names") %>% subset(article_title != "NA") %>% relocate(article_title)
|
Data Variable
|
https://osf.io/uhma8/
|
mmcpsr_author_data.R
|
638 |
authorlevel count and proportion for all race / ethnic identity categories
|
summary_race_ethnicity_author <- article_author_level %>% dplyr::select(-c(article_title, names)) %>% distinct() %>% summarize(count = c(sum(white, na.rm = TRUE), sum(black, na.rm = TRUE), sum(east_asian, na.rm = TRUE), sum(south_asian, na.rm = TRUE), sum(latino, na.rm = TRUE), sum(mena, na.rm = TRUE), sum(native, na.rm = TRUE), sum(pacific, na.rm = TRUE), sum(other, na.rm = TRUE))) summary_race_ethnicity_author <- summary_race_ethnicity_author %>% mutate(race_ethnicity = c("White", "Black", "East Asian", "South Asian", "Hispanic or Latino", "Middle Eastern / Arab", "Native", "Pacific Islander", "Other")) %>% mutate(proportion = round(count / sum(count), 2)) %>% dplyr::select(race_ethnicity, count, proportion)
|
Data Variable
|
https://osf.io/uhma8/
|
mmcpsr_author_data.R
|
639 |
Convert `candidate_page` to a factor. (Facilitates data visualizations and exploration).
|
elxn2015$candidate_page <- factor(elxn2015$candidate_page, levels = c("Harper", "Trudeau", "Mulcair"))
|
Visualization
|
https://osf.io/3fnjq/
|
facebook_pages.R
|
640 |
Timestamps are initially encoded as factors. Convert them to POSIXct format to avoid errors. Dates and times are separated and saved as two new variables;; namely, `date_published` and `time_published`. `date_published` must be converted back to POSIXct format. `Time_published` is left as a character string as this format proves easier to work with when plotting timerelated data.
|
elxn2015$created_time <- anytime(elxn2015$created_time, tz = "America/Los_Angeles") elxn2015$date_published <- as.POSIXct(format(elxn2015$created_time, "%Y-%m-%d")) elxn2015$time_published <- format(elxn2015$created_time, "%H:%M:%S")
|
Data Variable
|
https://osf.io/3fnjq/
|
facebook_pages.R
|
641 |
Create a new variable from `date_published` to indicate the month each post was published.
|
elxn2015$month_published <- as.POSIXct(elxn2015$date_published, format="%H:%M:%S") elxn2015$month_published <- format(elxn2015$month_published, "%B")
|
Data Variable
|
https://osf.io/3fnjq/
|
facebook_pages.R
|
642 |
`month_published` is converted to a factor with three levels such that values are chronologically ordered.
|
elxn2015$month_published <- factor(elxn2015$month_published, levels = c("August", "September","October"))
|
Data Variable
|
https://osf.io/3fnjq/
|
facebook_pages.R
|
643 |
Ensure consistent data types across data sets. IDs are appropriately treated as characters rather than numeric.
|
Facebook_Pages$id <- as.character(Facebook_Pages$id) Facebook_Pages$likes_count <- as.double(Facebook_Pages$likes_count) Facebook_Pages$comments_count <- as.double(Facebook_Pages$comments_count) Facebook_Pages$shares_count <- as.double(Facebook_Pages$shares_count)
|
Data Variable
|
https://osf.io/3fnjq/
|
facebook_pages.R
|
644 |
run random and fixed effects analyses on the data and calculate confidence intervals for the variables corresponding to heterogeneity (I2, H2 and T2). slab contains a vector of study names to display on the plot.
|
res <- rma(measure = "MD", m1i = m2,m2i = m1, sd1i = sd2, sd2i = sd1, n1i = n2, n2i = n1, weights = as.numeric(weights.r), slab = c("Mc1", "Mc2", "Mi1", "Mi2", "Mi3", "Mi4", "Mi5", "Mi6", "Mi7", "Mi8" ), method = "DL") res.f <- rma(measure = "MD", m1i = m2,m2i = m1, sd1i = sd2, sd2i = sd1, n1i = n2, n2i = n1, weights = weights.f, method = "FE") con <- confint(res)
|
Statistical Test
|
https://osf.io/gwn4y/
|
ESCI_forest_plot.R
|
645 |
2. Transform precision into partial correlations for interpretation
|
pr2pc <- function(K) { D.Prec = diag(diag(K)^(-.5)) R <- diag(2,dim(K)[1])-D.Prec%*%K%*%D.Prec colnames(R) <- colnames(K) rownames(R) <- rownames(K) return(R) }
|
Data Variable
|
https://osf.io/xjm6z/
|
AuxiliaryFunctions.R
|
646 |
4. BDgraph extract posterior distribution for estimates
|
extractposterior <- function(fit, data, method = c("ggm", "gcgm"), not.cont){ m <- length(fit$all_graphs) k <- 30000 n <- nrow(data) p <- ncol(data) j <- 1 densities <- rep(0, k)
|
Statistical Modeling
|
https://osf.io/xjm6z/
|
AuxiliaryFunctions.R
|
647 |
objects to store graph centrality measures
|
degree <- matrix(0, nrow = len, ncol = p) betweenness <- matrix(0, nrow = len, ncol = p) closeness <- matrix(0, nrow = len, ncol = p)
|
Data Variable
|
https://osf.io/xjm6z/
|
AuxiliaryFunctions.R
|
648 |
create token named "twitter_token"
|
twitter_token <- create_token( app = appname, consumer_key = key, consumer_secret = secret, access_token = access_token, access_secret = access_secret)
|
Data Variable
|
https://osf.io/yc8b5/
|
get_tweets.R
|
649 |
mean/sd ratings of targets and decoys by condition
|
tapply(dat.long$rating, list(dat.long$condition, dat.long$target), mean) tapply(dat.long$rating, list(dat.long$condition, dat.long$target), function(x) sd(x)/sqrt(length(x)))
|
Data Variable
|
https://osf.io/eg6w5/
|
experiment1b_analyses.R
|
650 |
mean difference between candidates in each condition
|
round(s[s$target == 'envy.target' & s$condition == 'Baseline', "emmean"] - s[s$target == 'pity.target' & s$condition == 'Baseline', "emmean"],3) round(s[s$target == 'envy.target' & s$condition == 'PityAD', "emmean"] - s[s$target == 'pity.target' & s$condition == 'PityAD', "emmean"],3) round(s[s$target == 'envy.target' & s$condition == 'PityC', "emmean"] - s[s$target == 'pity.target' & s$condition == 'PityC', "emmean"],3) round(s[s$target == 'envy.target' & s$condition == 'EnvyAD', "emmean"] - s[s$target == 'pity.target' & s$condition == 'EnvyAD', "emmean"],3) round(s[s$target == 'envy.target' & s$condition == 'EnvyC', "emmean"] - s[s$target == 'pity.target' & s$condition == 'EnvyC', "emmean"],3)
|
Statistical Modeling
|
https://osf.io/eg6w5/
|
experiment1b_analyses.R
|
651 |
regression for difference between social/nonsocial
|
b = glmer(choice ~ pchoice1*social + opchoice2*social + opchoice1 + pchoice2 + (1 + pchoice1 + opchoice2 + opchoice1 + pchoice2 |code),family = 'binomial',data[data$opponent == 1,] ,control = glmerControl(optimizer="bobyqa", tolPwrss = 1e-10, optCtrl = list(maxfun = 60000))) b = glmer(choice ~ pchoice1*social + opchoice2*social + opchoice1 + pchoice2 + (1 + pchoice1 + opchoice2 + opchoice1 + pchoice2 |code),family = 'binomial',data[data$opponent == 0,] ,control = glmerControl(optimizer="bobyqa", tolPwrss = 1e-10, optCtrl = list(maxfun = 60000)))
|
Statistical Modeling
|
https://osf.io/2yq8a/
|
figure2.R
|
652 |
Principal component analysis with correlation matrix
|
pca <- prcomp(d[, -whi], scale. = T)
|
Statistical Modeling
|
https://osf.io/8fzns/
|
2_Conditioning_Recode.R
|
653 |
Make stacked figure of costs by age
|
stack <- lapply(pe.list.hadza_male, colMeans, na.rm=T) stacks <- as.data.frame(do.call(rbind, stack)) names(stacks) <- c(male.acts, "climbing") stacks$age <- age_seq stacks$Processing <- stacks$light_processing + stacks$other_out_of_camp + stacks$pounding_baobab stack_plot_male <- stacks %>% select(-nonsubsistence, -resting, -light_processing, -other_out_of_camp, -pounding_baobab) %>% gather(key="act", value="cost", carry_firewood_water:climbing, Processing) male_stack_hadza <- ggplot(stack_plot_male, aes(x=age, y=cost, fill=act)) + geom_area() + scale_fill_manual(name="Activity", labels=c("Firewood and water collection", "Chopping", "Climbing", "Eating", "Manufacture", "Food processing", "Walking (during foraging)"), values = brewer.pal(7, "Set1")) + labs(x="Age (years)", y="Energy cost (kcal/day)") + theme_classic(base_size=16) + ggtitle("Hadza: Men") + lims(y=c(0, 750)) stack <- lapply(pe.list.hadza_female, colMeans, na.rm=T) stacks <- as.data.frame(do.call(rbind, stack)) names(stacks) <- female.acts stacks$age <- age_seq stacks$Processing <- stacks$light_processing + stacks$other_out_of_camp + stacks$pounding_baobab stack_plot_female <- stacks %>% select(-nonsubsistence, -resting, -light_processing, -other_out_of_camp, -pounding_baobab) %>% gather(key="act", value="cost", carry_firewood_water:digging, Processing) fhcols <- brewer.pal(8, "Set1")[c(1,2,4,5,6,7)] fhcols[2] <- "#33CCFF" female_stack_hadza <- ggplot(stack_plot_female, aes(x=age, y=cost, fill=act)) + geom_area() + scale_fill_manual(name="Activity", labels=c("Firewood and water collection", "Digging", "Eating", "Manufacture", "Food processing", "Walking (during foraging)"), values = fhcols) + labs(x="Age (years)", y="Energy cost (kcal/day)") + theme_classic(base_size=16) + ggtitle("Hadza: Women") + lims(y=c(0, 750))
|
Visualization
|
https://osf.io/92e6c/
|
hadza_combine_data.R
|
654 |
create centered age^2 variable for quadratic LGCM
|
qscale <- 100 rndhrs_subset <- rndhrs_subset %>% mutate(CAGE2_T4 = CAGE_T4^2 / qscale, CAGE2_T5 = CAGE_T5^2 / qscale, CAGE2_T6 = CAGE_T6^2 / qscale, CAGE2_T7 = CAGE_T7^2 / qscale, CAGE2_T8 = CAGE_T8^2 / qscale, CAGE2_T9 = CAGE_T9^2 / qscale, CAGE2_T10 = CAGE_T10^2 / qscale, CAGE2_T11 = CAGE_T11^2 / qscale )
|
Statistical Modeling
|
https://osf.io/3uyjt/
|
preprocessing_hrs.R
|
655 |
put.pvalue Function to put the pvalues accoridng to the journals guidelines
|
put.pvalue=function(p){ sapply(p, function(x){ if (is.na(x)){pc="NA"} else if (x<0.0001){pc="<0.0001"} else if (0.0001<=x & x<0.001){pc <- sprintf("%.4f", x)} else if (0.049<=x & x<0.05) {pc <- sprintf("%.3f", floor(x*1000)/1000)} else if (0.001<=x & x<0.1){pc <- sprintf("%.3f", x)} else if (0.1<=x){pc <- sprintf("%.2f", x)} return(pc) }) }
|
Data Variable
|
https://osf.io/dr8gy/
|
RCS_plot_LogisticCox.R
|
656 |
wald.test Function to perform Wald test in logistic or Cox model
|
wald.test <- function(model, ntest){ d <- length(ntest) a <- t(coefficients(model)[ntest]) mat <- vcov(model)[ntest,ntest] value <- as.numeric(a%*%solve(mat)%*%t(a)) pvalue <- pchisq(value, df=d, lower.tail=F) return(list(value=value, df=d, pvalue=pvalue)) }
|
Statistical Test
|
https://osf.io/dr8gy/
|
RCS_plot_LogisticCox.R
|
657 |
Function to change pvalues in the stat table with the ones from the model
|
update_table <- function(mymod) { modsum <- summary(mymod) p <- modsum$coefficients[, "Pr(>|t|)"] p <- as.vector(p) p <- pvalr(p, sig.limit = .001, digits = 3) p }
|
Statistical Modeling
|
https://osf.io/z6nm8/
|
Stats_figures_JBTxECT.R
|
658 |
Plot KM Curve
|
tiff("PRAD_KM Curve.tiff", units = "in", width=8, height=6, res=300) ggsurvplot(fit1, D2, risk.table=TRUE, palette = "jco", pval=TRUE, conf.int=FALSE, surv.median.line="hv", ylab= "Survival Probability (%)", xlab= "Time (months)", legend.title = "TX GROUP", pval.coord=c(10,0.25)) dev.off()
|
Visualization
|
https://osf.io/srbcf/
|
R_KMCurveCode.R
|
659 |
now iterate through each participant, take that PP's data frame and add z scores for RT afterwards, add that PP's data frame to the empty data frame to recreate the main df including z scores
|
for (aPP in unique(excl2Exp$PP)){ dat <- excl2Exp[excl2Exp$PP == aPP,] dat$zScore <- scale(dat$RespRT, scale = TRUE) excl2Exp2 <- rbind(excl2Exp2, dat) }
|
Data Variable
|
https://osf.io/g8kbu/
|
dataAnalysisRewardAppsExperiment.R
|
660 |
ttest on subset 1 (n6/sex/group)
|
p_6m6f = t.test(measure ~ group, data=simdata6each_sub1)$p.value #using 6 each sex, t-tests
|
Statistical Test
|
https://osf.io/6q73b/
|
SubgroupStatsSimulationV5.R
|
661 |
box and whisker plot for refined factor scores convert dataframe of factor scores and cluster membership to long form
|
KClusterScores.long <- KClusterScores %>% pivot_longer(c(Sensory, CognitiveDemand, ThreatToSelf, CrossSettings, Safety, States), names_to = c("Factor")) KClusterScores.long$Factor <- factor(KClusterScores.long$Factor, levels = c("Sensory", "CognitiveDemand", "ThreatToSelf", "CrossSettings", "Safety", "States"))
|
Visualization
|
https://osf.io/2j47e/
|
Figures.R
|
662 |
box and whisker plot for nonrefined factor (scale) scores convert dataframe of factor scores and cluster membership to long form
|
scale.KClusterScores.long <- scale.KClusterScores %>% pivot_longer(c(Sensory, CognitiveDemand, ThreatToSelf, CrossSettings, Safety, States), names_to = c("Factor")) scale.KClusterScores.long$Factor <- factor(scale.KClusterScores.long$Factor, levels = c("Sensory", "CognitiveDemand", "ThreatToSelf", "CrossSettings", "Safety", "States"))
|
Visualization
|
https://osf.io/2j47e/
|
Figures.R
|
663 |
calculate logrank Zstatistics assuming balanced risk set (in OE, E is always 0.5)
|
zs <- sapply(1:(CureVobs1 + CureVobs0), function(n) (sum(CureVobs1s[1:n]) - n/2)/sqrt(n/4))
|
Statistical Test
|
https://osf.io/d9jny/
|
Ter Schure (2021) R code ALL-IN meta-analysis paper.R
|
664 |
Statistics check distributions check normal distribution of PSE's
|
qqnorm(AllPSEs$Tennis.thre) shapiro.test(AllPSEs$Tennis.thre) # p < .01, qqnorm(AllPSEs$SoccerD.thre) shapiro.test(AllPSEs$SoccerD.thre) # p = .14, qqnorm(AllPSEs$SoccerI.thre) shapiro.test(AllPSEs$SoccerI.thre) # p < .01 qqnorm(AllPSEs$Coin.thre) shapiro.test(AllPSEs$Coin.thre) # p = .04
|
Statistical Test
|
https://osf.io/8fw3b/
|
QPsyAnalyse.R
|
665 |
TEST 1: wilcoxon's signed rank test for direct/ indirect trials
|
(TestID <- wilcox.test(EffectDirect, EffectIndirect, paired = TRUE))
|
Statistical Test
|
https://osf.io/8fw3b/
|
QPsyAnalyse.R
|
666 |
add a column with "time_interval" : either 9:00;;13:00;;17:00;;21:00 for this, check the $created column and depending on which interval it is in, create a new column with mutate
|
df_ESM_data_analysis = df_ESM_data_analysis %>% mutate( time_interval = case_when( format(created,"%H:%M") >= param_timepoints[1] & format(created,"%H:%M") < param_timepoints[2] ~ param_timepoints[1], format(created,"%H:%M") >= param_timepoints[2] & format(created,"%H:%M") < param_timepoints[3] ~ param_timepoints[2], format(created,"%H:%M") >= param_timepoints[3] & format(created,"%H:%M") < param_timepoints[4] ~ param_timepoints[3], format(created,"%H:%M") >= param_timepoints[4] & format(created,"%H:%M") < param_t_end ~ param_timepoints[4], ) )
|
Data Variable
|
https://osf.io/dngyk/
|
ESM-RUM_R_code.R
|
667 |
first find the duplicates according to n_obs and time_interval
|
df_ESM_data_analysis = df_ESM_data_analysis %>% arrange(session, created) %>% group_by(session, n_obs, time_interval) %>% mutate(num_dups = n(), dup_id = row_number()) %>% ungroup() %>%
|
Data Variable
|
https://osf.io/dngyk/
|
ESM-RUM_R_code.R
|
668 |
plot perseverance as a function of n_obs for each subject
|
gdat <- groupedData(perseverance ~ n_obs | session, data=df_ESM_data_analysis_noNAnoOutliers) plot(gdat)
|
Visualization
|
https://osf.io/dngyk/
|
ESM-RUM_R_code.R
|
669 |
put alpha together with descriptive statistics
|
questionnaire_stats <- bind_cols(questionnaires_stats, scores_alpha) %>% dplyr::select(-name, -vars)
|
Data Variable
|
https://osf.io/dngyk/
|
ESM-RUM_R_code.R
|
670 |
Correlation plot (colors on top, numbers on bottom) JUST MEANS (aggregated within person)
|
corrplot(means, p.mat = res2$p, insig = "label_sig", sig.level = c(.001, .01, .05), pch.cex = .9, pch.col = "gray", method = "color", tl.col = "black", tl.cex = 1, cl.offset = 0.25, cl.cex = 0.75) corrplot(means, method="number", col = "black", add = TRUE, cl.pos = "n", tl.pos = "n", type = "lower", number.cex = .60, number.digits = 2, tl.col = "black", cl.offset = 4)
|
Visualization
|
https://osf.io/dngyk/
|
ESM-RUM_R_code.R
|
671 |
Independence test: two ways (HSIC or Nonlinear corr) HSIC
|
if (independence == "hsic") { hsic.p <- dhsic.test(ry, rx, method = "gamma", kernel = "gaussian")$p.value pval[i] <- hsic.p }
|
Statistical Test
|
https://osf.io/qwr69/
|
nGFS.R
|
672 |
Correlation table (only with complete cases so takes out data from single parent)
|
means <- cor(mean_data_mat[,c(2:12)], use = "complete.obs") # Correlation matrix res2 <- cor.mtest(mean_data_mat[,c(2:12)], conf.level = .95, use = "complete.obs") # p-values
|
Data Variable
|
https://osf.io/dngyk/
|
ESM-RUM_R_code.R
|
673 |
EXCLUDE PPN WITH RT < or > 3 SD
|
max_sd_rt <- print(mean(data.rt.check$rt)+3*sd(data.rt.check$rt)) ppn.exclude.rt <- print(filter(data.rt.check, rt >= max_sd_rt)$ppn)
|
Data Variable
|
https://osf.io/c8vfj/
|
Analysis_Imitation_and_Token.R
|
674 |
Calculate and plot difference between the distributions
|
postDiff <- forModel2plotA$b_cfaInequality_nat - forModel2plotB$b_cfaSocial_control_nat %>% as.data.frame() ggplot(postDiff, aes(.)) + geom_histogram(bins = 100, color = "black", fill = "lightgray") quantile(postDiff, c(0.025, 0.975)) #So 95% confidence interval of the difference lies above 0
|
Visualization
|
https://osf.io/2sguf/
|
US attitude code.R
|
675 |
Exclude participants with accuracy less than 0.8
|
d_lowAcc = CQ_acc %>% filter(accuracy < 0.8) d = d[!d$Subject %in% d_lowAcc$Subject,] rm(list=ls()[! ls() %in% c("d")])
|
Data Variable
|
https://osf.io/cd5r8/
|
R_Code_Fang_Wu.R
|
676 |
check the correlation between even and oddnumbered sets Pearson
|
print(corr.test(person$ConditionOr_even, person$ConditionOr_odd), short = FALSE) KH_Correct(-.09) #.16 print(corr.test(person$ConditionOr_even, person$ConditionOr_odd), short = FALSE) KH_Correct(-.11) #.20
|
Statistical Test
|
https://osf.io/cd5r8/
|
R_Code_Fang_Wu.R
|
677 |
model criticism (remove data points with abs(standardized residuals) over 2.5)
|
de_trim<- de[abs(scale(resid(m_de)))<2.5,] do_trim<- do[abs(scale(resid(m_do)))<2.5,] m_de_mc = blmer(-1/Reaction.Time ~ Condition + (1+Condition|Subject) + (1+Condition|ItemNo), data = de_trim, control=lmerControl(optimizer = "nloptwrap", optCtrl = list(algorithm = "NLOPT_LN_NELDERMEAD", maxit = 2e5))) m_do_mc = blmer(-1/Reaction.Time ~ Condition + (1+Condition|Subject) + (1+Condition|ItemNo), data = do_trim, control=lmerControl(optimizer = "nloptwrap", optCtrl = list(algorithm = "NLOPT_LN_NELDERMEAD", maxit = 2e5)))
|
Statistical Modeling
|
https://osf.io/cd5r8/
|
R_Code_Fang_Wu.R
|
678 |
Add new ParentIndex column in trialSummary and fill with NA
|
trialSummary[,"ParentIndex"] <- NA
|
Data Variable
|
https://osf.io/42nyv/
|
Eye tracking_pre-processing_R1.R
|
679 |
Lookup the parent row index of the stimulus string in s.data and insert it for social
|
for(k in 1:length(trialSummary$Stimulus)){ trialSummary$ParentIndex[k] <- which(s.data$Stimulus == trialSummary$Stimulus[k])[1] } trialSummary$AgeGroup <- s.info[i,3] trialSummary$Sex <- s.info[i,4] trialSummary$ID <- i
|
Data Variable
|
https://osf.io/42nyv/
|
Eye tracking_pre-processing_R1.R
|
680 |
Fixation Count custom mean function: mean of fixation count left and right eye (if only ONE eye contains 0.0 > no averaging) https://stackoverflow.com/questions/45998419/aggregategroupmeanswhileignoringzerosunless0istheonlyvalue
|
meanSubset.FixCount = aggregate(Fixation.Count~Stimulus+AOI.Name, data=s.data, FUN=(function(x){ifelse(sum(x==0)>0 & sum(x !=0) >0, mean(x[x>0]), mean(x))}))
|
Data Variable
|
https://osf.io/42nyv/
|
Eye tracking_pre-processing_R1.R
|
681 |
3) CALCULATION OF ESTIMATED MARGINAL MEANS Tests for differences in response to jargon and get data for plots
|
at_jarg <- list(Jargon = c("Less", "More"), TrvlAdv_Atten = "Cons", BackgrYrsOfExp = "6-10 yrs", BackgrDaysPerYr = "11-20 days", BullUseType = "D", cut = "3|4") grid_jarg <- ref_grid(clmm_underjar, mode = "exc.prob", at = at_jarg) (emm_jarg <- emmeans(grid_jarg, specs = pairwise ~ Jargon, by = "BackgrAvTraining")) plot_jarg <- summary(emm_jarg$emmeans) cont_jarg <- summary(emm_jarg$contrasts)
|
Statistical Test
|
https://osf.io/aczx5/
|
220423_Fig06_Under_JargExpl.R
|
682 |
create data frame for mean acceptrate (%) per participant, per effortlevel in 'young' group
|
d.young.effort.1 <- filter(d, Group == 'Young') %>% group_by(ID, Agent, Effort) %>% summarise(m = mean(Choice)*100)
|
Data Variable
|
https://osf.io/guqrm/
|
Reproduce_figures_prosocial_ageing.R
|
683 |
create data frame reflecting mean accept rate (%) per participant at each rewardlevel in 'old' group
|
d.reward.old.1 <- filter(d, Group == 'Old') %>% group_by(ID, Agent, Reward) %>% summarise(m = mean(Choice)*100)
|
Data Variable
|
https://osf.io/guqrm/
|
Reproduce_figures_prosocial_ageing.R
|
684 |
create data frame reflecting overall mean accept rate (%) and SE at each rewardlevel in 'old' group
|
d.reward.old.2 <- d.reward.old.1 %>% group_by(Agent, Reward) %>% summarise(SE = std.error(m), M = mean(m, na.rm = T))
|
Data Variable
|
https://osf.io/guqrm/
|
Reproduce_figures_prosocial_ageing.R
|
685 |
Welch's oneway ANOVA
|
anova_dehyd = df_dehyd %>% welch_anova_test(dehyd ~ cond) anova_dist_ran = df_dist_ran %>% welch_anova_test(dist ~ cond) anova_run_time = df_run_time %>% welch_anova_test(time ~ cond) anova_heat_time = df_heat_time %>% welch_anova_test(time ~ cond) anova_tcmax = df_tcmax %>% welch_anova_test(tcmax ~ cond) anova_tcmin = df_tcmin %>% welch_anova_test(tcmin ~ cond) anova_duration = df_duration %>% welch_anova_test(duration ~ cond) anova_thermal_load = df_thermal_load %>% welch_anova_test(thermal_load ~ cond) anova_heat_time = df_heat_time %>% welch_anova_test(heat_time ~ cond)
|
Statistical Test
|
https://osf.io/n5ahf/
|
Table1_analysis.R
|
686 |
Function to generate the true value for the Diamond Ratio
|
true.ratio <- function(n1, n2, tau, delta){ v <- (n1 + n2)/(n1*n2) + delta^2/2/(n1 + n2) j <- 1 - 3/(4*(n1 + n2 - 2) - 1) v.g <- (j^2)*v w <- 1/v.g w.star <- 1/(v.g + tau^2) var.fixed <- 1/sum(w) var.random <- 1/sum(w.star) sqrt(var.random/var.fixed) }
|
Statistical Modeling
|
https://osf.io/gwn4y/
|
Simulations_line_plots.R
|
687 |
lmer model for dimorphism
|
Lat.ML<-lmer(Latency.cen~Sex+scale(Mass, scale = F)+ Generation+Pop+Stage+Injured+scale(Temp, scale = F)+ scale(Time, scale = F)+JDate_dev+(1|Sire)+(1|Dam),data=Data) summary(Lat.ML) drop1(Lat.ML) OF.ML<-lmer(sqrt(OF.Dist)~Sex+scale(Mass, scale = F)+ Generation+Pop+Stage+Injured+scale(Temp, scale = F)+ scale(Time, scale = F)+JDate_dev+(1|Sire)+(1|Dam),data=Data) summary(OF.ML) drop1(OF.ML) AP.ML<-lmer(sqrt(AP.Dist)~Sex+scale(Mass, scale = F)+ Generation+Pop+Stage+Injured+scale(Temp, scale = F)+ scale(Time, scale = F)+JDate_dev+(1|Sire)+(1|Dam),data=Data) summary(AP.ML) drop1(AP.ML) Lat.ML<-lmer(Latency.Cens~Sex+Mass+Generation+Pop+Stage+Injured+Temp+ Time+JDate_dev+(1|Sire)+(1|Dam),data=Data) summary(Lat.ML) drop1(Lat.ML) OF.ML<-lmer(OF.Dist~Sex+Mass+Generation+Pop+Stage+Injured+Temp+ Time+JDate_dev+(1|Sire)+(1|Dam),data=Data) summary(OF.ML) drop1(OF.ML) AP.ML<-lmer(AP.Dist~Sex+Mass+Generation+Pop+Stage+Injured+Temp+ Time+JDate_dev+(1|Sire)+(1|Dam),data=Data) summary(AP.ML) drop1(AP.ML)
|
Statistical Modeling
|
https://osf.io/pnug5/
|
3.Ginteger_CrossSex_Tables&Figures.R
|
688 |
return the lastN characters of a string
|
fn$lastN<-function(string, n){ l<-nchar(string) result<-substr(string,l-n+1,l) result }
|
Data Variable
|
https://osf.io/xwp2d/
|
generic.r
|
689 |
Linear mixed effects model for reproduction bias
|
mod_full <- lmer(Prct_Bias ~ ContextC*(GMSI_Gen_Z + OrderC*Distort) + (1|Subject), data=dat2)
|
Statistical Modeling
|
https://osf.io/wxgm5/
|
Exp2_tapping.R
|
690 |
Extra function MM to inchconversion for plot
|
MMtoInch <- function(MM) { z <- MM / 25.4 return(z) }
|
Visualization
|
https://osf.io/3w8eg/
|
All_Figures.R
|
691 |
plot mean force (+/ SE) at each effortlevel in old group AND show individual data points
|
plot.force.old.2 <- ggplot(d.force.old, aes(x = Effort, y = m)) + geom_point(aes(group = Agent, color = Agent), position = position_dodge(width = 0.3), alpha = 0.4, shape = 1, size = 0.5) + geom_errorbar(data = d.force.old.summary, aes(group = Agent, color = Agent, ymin = m - SE, ymax = m + SE), position = position_dodge(0.02), alpha = 1, width = 0.2) + geom_line(data = d.force.old.summary, aes(group = Agent, color = Agent), position = position_dodge(0.02)) + scale_x_continuous(name = 'Effort level', breaks = seq(2, 6, 1)) + scale_y_continuous(name = 'Force exerted (normalised AUC)', breaks = seq(0.0, 1.0, 0.2)) + scale_color_brewer(palette = 'Set1') + coord_cartesian(xlim = c(2, 6), ylim = c(0.30, 1.0)) + theme_classic() + theme(legend.position = c(0.9, 0.15)) + theme(axis.text=element_text(size = 11), axis.title=element_text(size = 13)) plot.force.old.2 ggsave(filename = 'plot_force_old_v2.pdf', plot.force.old.2, height = 5, width = 4)
|
Visualization
|
https://osf.io/guqrm/
|
Reproduce_figures_prosocial_ageing.R
|
692 |
plot mean force (no SE) at each effortlevel in old group AND show individual data points
|
plot.force.old.3 <- ggplot(d.force.old, aes(x = Effort, y = m, group = Agent, color = Agent, fill = Agent)) + geom_point(data = d.force.old, aes(group = Agent, color = Agent), position = position_dodge(width = 0.3), alpha = 0.4, shape = 1, size = 0.5) + geom_smooth(method = 'lm', alpha = 0.3, size = 0.6, se = F) + coord_cartesian(xlim = c(2, 6), ylim = c(0.35, 0.9)) + scale_x_continuous(name = 'Effort level', breaks = seq(2, 6, 1)) + scale_y_continuous(name = 'Force exerted (normalised AUC)', breaks = seq(0, 1.0, 0.2)) + scale_color_brewer(palette = 'Set1') + scale_fill_brewer(palette = 'Set1') + theme_classic() + theme(legend.position = c(0.9, 0.15)) + theme(axis.text=element_text(size = 11), axis.title=element_text(size = 13)) plot.force.old.3 ggsave(filename = 'plot_force_old_v3.pdf', plot.force.old.3, height = 5, width = 4)
|
Visualization
|
https://osf.io/guqrm/
|
Reproduce_figures_prosocial_ageing.R
|
693 |
bootstrap modindices of item residual covariances
|
cfa.csurf.bl.full.1.boot <- bootstrapLavaan(cfa.csurf.bl.full.1, R = 5000, FUN = function(x) {modindices(x)$mi}, verbose = TRUE) cfa.csurf.bl.full.1.boot <- data.frame(cfa.csurf.bl.full.1.boot) cfa.csurf.fu1.full.1.boot <- bootstrapLavaan(cfa.csurf.fu1.full.1, R = 5000, FUN = function(x) {modindices(x)$mi}, verbose = TRUE) cfa.csurf.fu1.full.1.boot <- data.frame(cfa.csurf.fu1.full.1.boot) cfa.csurf.bl.deponly.1.boot <- bootstrapLavaan(cfa.csurf.bl.deponly.1, R = 5000, FUN = function(x) {modindices(x)$mi}, verbose = TRUE) cfa.csurf.bl.deponly.1.boot <- data.frame(cfa.csurf.bl.deponly.1.boot) cfa.csurf.fu1.deponly.1.boot <- bootstrapLavaan(cfa.csurf.fu1.deponly.1, R = 5000, FUN = function(x) {modindices(x)$mi}, verbose = TRUE) cfa.csurf.fu1.deponly.1.boot <- data.frame(cfa.csurf.fu1.deponly.1.boot)
|
Statistical Modeling
|
https://osf.io/a6tuw/
|
OnlinesupplementaryR-scriptc-surfsamples.R
|
694 |
recode played hours into numeric (if multiple numbers, choose the first one)
|
mydf$Hours <- as.numeric(stri_extract_first_regex(mydf$Hours, "[0-9]+"))
|
Data Variable
|
https://osf.io/vnbxk/
|
GamingStudy_PreProcessing.R
|
695 |
recode streamed hours into numeric (if multiple numbers, choose the first one)
|
mydf$streams <- as.numeric(stri_extract_first_regex(mydf$streams, "[0-9]+"))
|
Data Variable
|
https://osf.io/vnbxk/
|
GamingStudy_PreProcessing.R
|
696 |
recode narcisiim scale into numeric (if multiple numbers, choose the first one)
|
mydf$Narcissism <- as.numeric(stri_extract_first_regex(mydf$Narcissism, "[0-9]+"))
|
Data Variable
|
https://osf.io/vnbxk/
|
GamingStudy_PreProcessing.R
|
697 |
Display and rank games by frequency
|
tGames <- as.data.frame(table(data_main$Game)) View(tGames[order(tGames$Freq, decreasing = TRUE), ])
|
Visualization
|
https://osf.io/vnbxk/
|
GamingStudy_PreProcessing.R
|
698 |
Display and rank residence country by frequency
|
tResidence <- as.data.frame(table(data_main$Residence)) View(tResidence[order(tResidence$Freq, decreasing = TRUE), ])
|
Data Variable
|
https://osf.io/vnbxk/
|
GamingStudy_PreProcessing.R
|
699 |
Display and rank country of birth by frequency
|
tBirth <- as.data.frame(table(data_main$Birthplace)) View(tBirth[order(tBirth$Freq, decreasing = TRUE), ])
|
Data Variable
|
https://osf.io/vnbxk/
|
GamingStudy_PreProcessing.R
|
700 |
Loop to downsample data based on minimum time between points Time parameter is set in "while(diff < time in minutes)"
|
trajectory_dsmpl <- data.frame() ids <- unique(trajectory.df$id) for(i in ids) { traj = subset(trajectory.df, trajectory.df$id == i) for(i in 1:nrow(traj)) { diff <- difftime(traj$dt[i+1], traj$dt[i], units = "mins") if(is.na(diff)) {break} while(diff < 15) { traj <- traj[-(i+1),] diff <- difftime(traj$dt[i+1], traj$dt[i], units = "mins") if(is.na(diff)) {break} } } trajectory_dsmpl <- bind_rows(trajectory_dsmpl, traj) } trajectory_dsmpl <- trajectory_dsmpl %>% group_by(id) %>% mutate(time_diff = difftime(dt, lag(dt, n = 1L), units = "min"), delta_x = x_utm - lag(x_utm, n = 1L), delta_y = y_utm - lag(y_utm, n = 1L), dist = sqrt(delta_x^2+delta_y^2))
|
Data Variable
|
https://osf.io/3bpn6/
|
os_homing_dataproc.R
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.