Study #1: Birth Order Code
Below is the code I used to conduct analysis on Enneagram vs birth order. There are undoubtedly more sophisticated ways to go about it, but I’m not a professional coder and my rudimentary methods seemed to do the trick. Feel free to double-check my work! The raw data file is available for download on Google Drive if you’d like to play around with it on your own or rerun my code in RStudio.
# This script contains all the tests performed to assess the dataset for # relationships between birth order and the Enneagram. # Generated and assessed by Danielle F. of The Scientific Enneagram # ## ### DO NOT RUN THIS CODE UNLESS YOU HAVE ALREADY RUN 'INITIAL SETUP.R' ## # ####SETUP#### # 1. Create dataframe with only those who answered birth order questions raw_bo <- raw_PBOI[!is.na(raw_PBOI$PBO)&!is.na(raw_PBOI$OrdinalBO)&raw_PBOI$OrdinalBO!="999",] ### check that raw_bo has 1696 observations and 102 variables # 2. Install and load required packages library(chisq.posthoc.test) #Needed for ChiSq post hoc library(rcompanion) #Needed for Pairwise Nominal Independence test ####BY TYPE#### # 3. Assess Ordinal Birth Order by Type ## Run descriptives addmargins(table(raw_bo$OrdinalBO)) #shows counts per ordinal birth order addmargins(table(raw_bo$Type,raw_bo$OrdinalBO)) ## Test of significance chisq.test(raw_bo$Type,raw_bo$OrdinalBO) #X2(24,1696)=51.539, p=.0008982 chisq.posthoc.test(table(raw_bo$Type,raw_bo$OrdinalBO), method="bonferroni") ## Create visualizations of above descriptives (optional) ggplot(data=raw_bo, aes(x=OrdinalBO,fill=OrdinalBO)) + geom_bar() + theme_minimal() + scale_fill_SciEn() + labs(title="Ordinal Birth Order", x=NULL,y="Count") ggplot(data=raw_bo, aes(fill=OrdinalBO, x=Type)) + geom_bar(position="fill", stat='count') + scale_fill_SciEn() + theme_minimal() + labs(title="Ordinal Birth Order by Type", x=NULL, y="Proportion (%)") + guides(fill=guide_legend(title="BO")) # 4. Assess Psychological Birth Order by Type ## Run descriptives addmargins(table(raw_bo$PBO)) #shows counts per psychological birth order addmargins(table(raw_bo$Type,raw_bo$PBO)) # Test of significance chisq.test(raw_bo$Type,raw_bo$PBO) #X2(24,1696)=185.97, p<2.2e-16 chisq.posthoc.test(table(raw_bo$Type,raw_bo$PBO), method="bonferroni") ## Create visualizations of above descriptives (optional) ggplot(data=raw_bo, aes(x=Type,fill=PBO)) + geom_bar() + theme_minimal() + scale_fill_SciEn() + labs(title="Psychological Birth Order", x=NULL,y="Count") ggplot(data=raw_bo, aes(fill=PBO, x=Type)) + geom_bar(position="fill", stat='count') + scale_fill_SciEn() + theme_minimal() + labs(title=NULL, x=NULL, y=NULL) + guides(fill=guide_legend(title="PBO")) ####EGO#### # 5. Assess Ordinal Birth Order by Ego ## Run descriptives addmargins(table(raw_bo$Ego)) #shows 1629 of 1696 answered the ego question addmargins(table(raw_bo$Ego,raw_bo$OrdinalBO)) ## Test of significance chisq.test(raw_bo$Ego,raw_bo$OrdinalBO) #X2(6,1629)=0.93212, p=.9881 chisq.posthoc.test(table(raw_bo$Ego,raw_bo$OrdinalBO), method = "bonferroni") ## Create visualizations of above descriptives (optional) ggplot(data=subset(raw_bo,!is.na(raw_bo$Ego) & !is.na(raw_bo$OrdinalBO)), aes(fill=Ego, x=OrdinalBO)) + geom_bar(position='fill', stat='count') + scale_fill_SciEn(palette = "stoplight") + theme_minimal() + labs(title=NULL, x="Ordinal Birth Order", y="Proportion (%)") + guides(fill=guide_legend(title="Ego Level")) ggplot(data=subset(raw_bo,!is.na(raw_bo$Ego)), aes(fill=Ego, x=OrdinalBO)) + geom_bar(stat='count') + scale_fill_SciEn(palette="stoplight") + theme_minimal() + labs(title=NULL, x=NULL, y="Count") + guides(fill=guide_legend(title="Ego Level")) # 6. Assess Psychological Birth Order by Ego ## Run descriptives addmargins(table(raw_bo$Ego,raw_bo$PBO)) ## Test of significance print(chisq.test(raw_bo$Ego,raw_bo$PBO)) #X2(6,1629)=21.383, p=.001566 print(chisq.posthoc.test(table(raw_bo$Ego,raw_bo$PBO), method = "bonferroni")) pairwiseNominalIndependence(table(raw_bo$Ego,raw_bo$PBO),method="bonferroni", fisher=FALSE, gtest=FALSE, stats=TRUE) ## Create visualizations of above descriptives (optional) ggplot(data=subset(raw_bo,!is.na(raw_bo$Ego) & !is.na(raw_bo$PBO)), aes(fill=Ego, x=PBO)) + geom_bar(position='fill', stat='count') + scale_fill_SciEn(palette = "stoplight") + theme_minimal() + labs(title=NULL, x=NULL, y="Proportion (%)") + guides(fill=guide_legend(title="Ego Level")) ggplot(data=subset(raw_bo,!is.na(raw_bo$Ego)), aes(fill=Ego, x=PBO)) + geom_bar(stat='count') + scale_fill_SciEn(palette="stoplight") + theme_minimal() + labs(title=NULL, x=NULL, y="Count") + guides(fill=guide_legend(title="Ego Level")) ####MINDSET#### # 7. Assess Ordinal Birth Order by Mindset ## Run descriptives addmargins(table(raw_bo$Arrow)) #shows 1695 of 1696 answered arrow question addmargins(table(raw_bo$Arrow,raw_bo$OrdinalBO)) # Test of Significance chisq.test(raw_bo$Arrow,raw_bo$OrdinalBO) #X2(6,1695)=13.083, p=.04174 chisq.posthoc.test(table(raw_bo$Arrow,raw_bo$OrdinalBO), method = "bonferroni") ## Create visualizations of above descriptives (optional) ggplot(data=subset(raw_bo,!is.na(raw_bo$Arrow)), aes(x=Arrow,fill=Arrow)) + geom_bar() + theme_minimal() + scale_fill_SciEn(palette = "stoplight") + labs(title="Recent Mindset (past 30 days)", x=NULL,y="Count") + theme(legend.position = "none") ggplot(data=subset(raw_bo,!is.na(raw_bo$Arrow)), aes(fill=Arrow, x=OrdinalBO)) + geom_bar(position='fill', stat='count') + scale_fill_SciEn(palette = "stoplight") + theme_minimal() + labs(title="Ordinal Birth Order by Recent Mindset (last 30 days)", x=NULL, y="Proportion (%)") + guides(fill=guide_legend(title="Mindest")) ggplot(data=subset(raw_bo,!is.na(raw_bo$Arrow)), aes(fill=Arrow, x=OrdinalBO)) + geom_bar(stat='count') + scale_fill_SciEn(palette = "stoplight") + theme_minimal() + labs(title=NULL, x=NULL, y="Count") + guides(fill=guide_legend(title="Mindset")) # 8. Assess Psychological Birth Order by Mindset ## Run descriptives addmargins(table(raw_bo$Arrow,raw_bo$PBO)) # Test of Significance chisq.test(raw_bo$Arrow,raw_bo$PBO) #X2(6,1695)=21.184, p=.0017 chisq.posthoc.test(table(raw_bo$Arrow,raw_bo$PBO), method = "bonferroni") pairwiseNominalIndependence(table(raw_bo$PBO,raw_bo$Arrow),method="bonferroni", fisher=FALSE, gtest=FALSE, stats=TRUE) ## Create visualizations of above descriptives (optional) ggplot(data=subset(raw_bo,!is.na(raw_bo$Arrow)), aes(fill=Arrow, x=PBO)) + geom_bar(position='fill', stat='count') + scale_fill_SciEn(palette = "stoplight") + theme_minimal() + labs(title=NULL,x=NULL, y="Proportion (%)") + guides(fill=guide_legend(title="Mindest")) ggplot(data=subset(raw_bo,!is.na(raw_bo$Arrow)), aes(fill=PBO, x=Arrow)) + geom_bar(stat='count') + scale_fill_SciEn() + theme_minimal() + labs(title=NULL, x=NULL, y="Count") + guides(fill=guide_legend(title="Birth Order"))