Code
url <- (
"https://openpsychometrics.org/_rawdata/IPIP-FFM-data-8Nov2018.zip")
file_name <- "b5d.zip"
file_path <- ("/media/drive2/Quarto/")
download.file(url = url, destfile = paste0(file_path, file_name, sep = ""))
unzip("b5d.zip")This file is my version of the work presented by Allen B. Downey in his book Probably Overthingking It. The reason for replicate the text is apply R tools for the data analysis and learn to use Quarto also in R. The details on how the data is prepared can be founded in Allen Downey Github repository . I followed the steps presented there.
The data can be downloaded from the Open-Source Psychometrics Project. The downloadable is described as “Answers to the IPIP Big Five Factor Markers”. The download is a .zip file containing the dataset (.csv file) and a .txt codebook.
The following is the procedure to download and unzip the file.
url <- (
"https://openpsychometrics.org/_rawdata/IPIP-FFM-data-8Nov2018.zip")
file_name <- "b5d.zip"
file_path <- ("/media/drive2/Quarto/")
download.file(url = url, destfile = paste0(file_path, file_name, sep = ""))
unzip("b5d.zip")The dataset will be set available to work with using the tidyverse tools.
library(tidyverse)
library(gridExtra)
library(grid)
library(corrplot)dat1 <- read_tsv(
"/media/drive2/Quarto/IPIP-FFM-data-8Nov2018/data-final.csv",col_select = c(1:50))Rows: 1015341 Columns: 50
── Column specification ────────────────────────────────────────────────────────
Delimiter: "\t"
chr (50): EXT1, EXT2, EXT3, EXT4, EXT5, EXT6, EXT7, EXT8, EXT9, EXT10, EST1,...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
To make it easier the work with this dataset we will limit ourselves to the answers of the test only and then not including additional information available in the downloaded file.
All variables in this subset are of character type. The first step will be to transform it to numeric variable type.
dat1 <- dat1 %>%
mutate(across(where(is.character), as.numeric))Let start by looking at some of the data.
apply(dat1[,1:10],2,table) EXT1 EXT2 EXT3 EXT4 EXT5 EXT6 EXT7 EXT8 EXT9 EXT10
0 3720 6099 6075 6893 9781 6183 8179 6372 6845 6261
1 249711 210104 76730 102032 98458 266568 236795 78165 173361 76504
2 199165 235528 191723 208184 178508 338198 227788 175759 221323 158282
3 288622 244683 269135 280161 234463 191408 194827 229962 214960 191349
4 191638 190216 284124 257148 299214 139539 197374 274953 242310 268237
5 80702 126928 185771 159140 193134 71662 148595 248347 154759 312925
The first thing to notice is the existence of 0 in the first 10 data columns and this value it is not expected as a valid response. The expected values ranges from 1 to 5.
We will take a look at missing values across variables if any.
apply(is.na(dat1[,1:10]),2,sum) EXT1 EXT2 EXT3 EXT4 EXT5 EXT6 EXT7 EXT8 EXT9 EXT10
1783 1783 1783 1783 1783 1783 1783 1783 1783 1783
And yes, we have missing (NA) values in at least the first 10 variables of the dataset.
Before continue on any posterior analysis we need to remove the cases with a 0 and or NA.
First we will transform all 0 values to NA.
#|label: Change 0 to NA
dat1[dat1==0] <- NAAnd second, remove all cases with NA
dat1 <- dat1 %>% drop_na()And let look the dataset again
#label: check for changes
apply(dat1[,1:10],2,table) EXT1 EXT2 EXT3 EXT4 EXT5 EXT6 EXT7 EXT8 EXT9 EXT10
1 216949 179468 66519 86970 85967 229996 207648 66244 150045 64801
2 176207 205925 168457 181098 158114 297333 200884 152483 194494 136922
3 247835 212344 234223 242115 204662 165199 168070 198204 185618 164581
4 166599 167015 247551 226729 261179 121334 171441 241798 211865 235322
5 66844 109682 157684 137522 164512 60572 126391 215705 132412 272808
dat1# A tibble: 874,434 × 50
EXT1 EXT2 EXT3 EXT4 EXT5 EXT6 EXT7 EXT8 EXT9 EXT10 EST1 EST2 EST3
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 4 1 5 2 5 1 5 2 4 1 1 4 4
2 3 5 3 4 3 3 2 5 1 5 2 3 4
3 2 3 4 4 3 2 1 3 2 5 4 4 4
4 2 2 2 3 4 2 2 4 1 4 3 3 3
5 3 3 3 3 5 3 3 5 3 4 1 5 5
6 3 3 4 2 4 2 2 3 3 4 3 4 3
7 4 3 4 3 3 3 5 3 4 3 2 4 4
8 3 1 5 2 5 2 5 2 3 2 2 4 2
9 1 5 3 5 2 3 2 4 5 4 3 3 3
10 3 3 2 3 3 2 4 3 3 5 4 3 4
# ℹ 874,424 more rows
# ℹ 37 more variables: EST4 <dbl>, EST5 <dbl>, EST6 <dbl>, EST7 <dbl>,
# EST8 <dbl>, EST9 <dbl>, EST10 <dbl>, AGR1 <dbl>, AGR2 <dbl>, AGR3 <dbl>,
# AGR4 <dbl>, AGR5 <dbl>, AGR6 <dbl>, AGR7 <dbl>, AGR8 <dbl>, AGR9 <dbl>,
# AGR10 <dbl>, CSN1 <dbl>, CSN2 <dbl>, CSN3 <dbl>, CSN4 <dbl>, CSN5 <dbl>,
# CSN6 <dbl>, CSN7 <dbl>, CSN8 <dbl>, CSN9 <dbl>, CSN10 <dbl>, OPN1 <dbl>,
# OPN2 <dbl>, OPN3 <dbl>, OPN4 <dbl>, OPN5 <dbl>, OPN6 <dbl>, OPN7 <dbl>, …
There was a reduction in the number of rows from 1015341 to 874,434, i.e., a reduction of 140907 rows (13.8%).
In the documentation associated is said:
“The big five personality traits are the best accepted and most commonly used model of personality in academic psychology” and “This test uses the Big-Five Factor Markers from the International Personality Item Pool, developed by Goldberg (1992).”
In the text aforementioned is said that the test consist of fifty items that are rated on how true they are about you on a five point scale where 1=Disagree, 3=Neutral and 5=Agree.
The questions about people personality are: extraversion (EXT), neuroticism (EST), agreeableness (AGR), conscientiousness (CSN) and openness (OPN) to experience.
The personality traits score can be obtained by aggregating answers. As result of using a technique called factor analysis, the answers to the questions could be positive or negative keyed. Then each trait is developed by adding the keyed responses.
#|label: Traits
EXT <- dat1[,1]-dat1[,2]+dat1[,3]-dat1[,4]+dat1[,5]-dat1[,6]+dat1[,7]-dat1[,8]+dat1[,9]-dat1[,10]
EST <- dat1[,11]-dat1[,12]+dat1[,13]-dat1[,14]+dat1[,15]-dat1[,16]+dat1[,17]-dat1[,18]+dat1[,19]-dat1[,20]
AGR <- dat1[,21]-dat1[,22]+dat1[,23]-dat1[,24]+dat1[,25]-dat1[,26]+dat1[,27]-dat1[,28]+dat1[,29]-dat1[,30]
CSN <- dat1[,31]-dat1[,32]+dat1[,33]-dat1[,34]+dat1[,35]-dat1[,36]+dat1[,37]-dat1[,38]+dat1[,39]-dat1[,40]
OPN <- dat1[,41]-dat1[,42]+dat1[,43]-dat1[,44]+dat1[,45]-dat1[,46]+dat1[,47]-dat1[,48]+dat1[,49]-dat1[,50]Collect the traits score in a dataset
#|label: Explore the score distributions for each personality trait.
bfd <- data.frame(EXT,EST,AGR,CSN,OPN)
bfd <- bfd %>%
rename("EXT" = "EXT1", "EST"="EST1", "AGR" = "AGR1",
"CSN"="CSN1","OPN"="OPN1")Plot the traits
#|label: Traits histograms
#|warning: false
ext <- ggplot(bfd,aes(x=EXT)) +
geom_histogram(binwidth = 1)
est <- ggplot(bfd,aes(x=EST)) +
geom_histogram(binwidth = 1)
agr <- ggplot(bfd,aes(x=AGR)) +
geom_histogram(binwidth = 1)
csn <- ggplot(bfd,aes(x=CSN)) +
geom_histogram(binwidth = 1)
opn <- ggplot(bfd,aes(x=OPN)) +
geom_histogram(binwidth = 1)
grid.arrange(ext,est,agr,csn,opn, ncol=2)Distribution frequency of scores show a clustering around some central value and dispersion of deviations with different level of symmetry.
The level of correlation between the traits can be seen as follows:
cormat <- round(cor(bfd),2)
corrplot(cormat, type = "lower",order = "hclust",tl.col = "black",
tl.srt = 45)