El dataset presentado corresponde a una encuesta realizada por psicólogos en 2015 a jugadores de videojuegos de diferentes nacionalidades. Las preguntas de la encuesta corresponden a tests standard de 1.GAD (Desorden General de ansiedad), 2.SWL (Satisfacción de Vida) y 3.SPIN(Índice de Phobia Social), además de datos demográficos para identificar el pais de origen, edad y genero de los jugadores.
Referencia: https://www.kaggle.com/datasets/divyansh22/online-gaming-anxiety-data?rvi=1
Encontrar patrones o tendencias de las calificaciones mas negativas del cuestionario y buscar relación entre países de origen, hábitos de juego, género, etc.
library(readr)
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(modeest)
library(moments)
##
## Attaching package: 'moments'
## The following object is masked from 'package:modeest':
##
## skewness
library(ggplot2)
library(plotrix)
library(vcd)
## Loading required package: grid
library(gplots)
##
## Attaching package: 'gplots'
## The following object is masked from 'package:plotrix':
##
## plotCI
## The following object is masked from 'package:stats':
##
## lowess
library(corrplot)
## corrplot 0.92 loaded
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
library(rmarkdown)
library(rsconnect)
getwd()
## [1] "C:/Users/ogl88/OneDrive/Documentos/Master Big Data/1. Principales herramientas"
setwd("C:/Users/ogl88/OneDrive/Documentos/Master Big Data/1. Principales herramientas")
GamingStudy_data = read.csv("GamingStudy_data.csv", header = TRUE, sep =",")
#head(GamingStudy_data, 5)
GamingStudy_processed = GamingStudy_data %>%
select(1,"GADE", "Game", "Platform", "Hours", "whyplay", "League", "Narcissism", "Gender", "Age", "Work", "Degree", "Birthplace", "Residence", "Playstyle", "GAD_T", "SWL_T", "SPIN_T")
head(GamingStudy_processed, 5)
## S..No. GADE Game Platform Hours whyplay
## 1 1 Not difficult at all Skyrim Console (PS, Xbox, ...) 15 having fun
## 2 2 Somewhat difficult Other PC 8 having fun
## 3 3 Not difficult at all Other PC 0 having fun
## 4 4 Not difficult at all Other PC 20 improving
## 5 5 Very difficult Other Console (PS, Xbox, ...) 20 having fun
## League Narcissism Gender Age Work
## 1 N/A 1 Male 25 Unemployed / between jobs
## 2 N/A 1 Male 41 Unemployed / between jobs
## 3 n/a 4 Female 32 Employed
## 4 N/A 2 Male 28 Employed
## 5 n/a 1 Male 19 Employed
## Degree Birthplace Residence
## 1 Bachelor\xa0(or equivalent) USA USA
## 2 Bachelor\xa0(or equivalent) USA USA
## 3 Bachelor\xa0(or equivalent) Germany Germany
## 4 Bachelor\xa0(or equivalent) USA USA
## 5 High school diploma (or equivalent) USA South Korea
## Playstyle GAD_T SWL_T
## 1 Singleplayer 1 23
## 2 Multiplayer - online - with strangers 8 16
## 3 Singleplayer 8 17
## 4 Multiplayer - online - with online acquaintances or teammates 0 17
## 5 Multiplayer - online - with strangers 14 14
## SPIN_T
## 1 5
## 2 33
## 3 31
## 4 11
## 5 13
str(GamingStudy_processed)
## 'data.frame': 13464 obs. of 18 variables:
## $ S..No. : int 1 2 3 4 5 6 7 8 9 10 ...
## $ GADE : chr "Not difficult at all" "Somewhat difficult" "Not difficult at all" "Not difficult at all" ...
## $ Game : chr "Skyrim" "Other" "Other" "Other" ...
## $ Platform : chr "Console (PS, Xbox, ...)" "PC" "PC" "PC" ...
## $ Hours : int 15 8 0 20 20 4 30 25 2 25 ...
## $ whyplay : chr "having fun" "having fun" "having fun" "improving" ...
## $ League : chr "N/A" "N/A" "n/a" "N/A" ...
## $ Narcissism: int 1 1 4 2 1 2 2 5 1 1 ...
## $ Gender : chr "Male" "Male" "Female" "Male" ...
## $ Age : int 25 41 32 28 19 24 29 23 23 27 ...
## $ Work : chr "Unemployed / between jobs" "Unemployed / between jobs" "Employed" "Employed" ...
## $ Degree : chr "Bachelor\xa0(or equivalent)" "Bachelor\xa0(or equivalent)" "Bachelor\xa0(or equivalent)" "Bachelor\xa0(or equivalent)" ...
## $ Birthplace: chr "USA" "USA" "Germany" "USA" ...
## $ Residence : chr "USA" "USA" "Germany" "USA" ...
## $ Playstyle : chr "Singleplayer" "Multiplayer - online - with strangers" "Singleplayer" "Multiplayer - online - with online acquaintances or teammates" ...
## $ GAD_T : int 1 8 8 0 14 1 0 0 12 10 ...
## $ SWL_T : int 23 16 17 17 14 17 16 23 12 13 ...
## $ SPIN_T : int 5 33 31 11 13 13 26 NA 55 26 ...
Se eliminan aquellos registros con valores N/A o valores no validos en las columnas relevantes para el análisis, como son: -Valores en las evaluaciones de GAD, SWL y SPIN -Lugar de nacimiento y lugar de residencia -Situacion laboral
#cuenta cuantos registros tienen NA
sum(is.na(GamingStudy_processed))
## [1] 3135
#identifica que variables tienen NA
sapply(GamingStudy_processed, function(x) sum(is.na(x)))
## S..No. GADE Game Platform Hours whyplay League
## 0 649 0 0 30 0 1745
## Narcissism Gender Age Work Degree Birthplace Residence
## 23 0 0 38 0 0 0
## Playstyle GAD_T SWL_T SPIN_T
## 0 0 0 650
GamingStudy_processed <- GamingStudy_processed %>%
filter(!is.na(GADE)) %>%
filter(!is.na(Hours)) %>%
filter(!is.na(Narcissism))%>%
filter(!is.na(Work))%>%
filter(!is.na(SPIN_T)) %>%
filter(!is.na(League))
# cálcular columnas para clasificación
GamingStudy_processed$GAD_T =as.factor(GamingStudy_processed$GAD_T)
#GamingStudy_processed$Age =as.factor(GamingStudy_processed$Age)
GamingStudy_processed = GamingStudy_processed %>%
mutate(SWL_Class = if_else(SWL_T <= 19,"No satisfecho",
if_else(SWL_T >= 25, "Sumamente Satisfecho","Satisfecho en General"))) %>%
mutate(SPIN_Class = if_else(SPIN_T <= 30,"Ninguno/Bajo",
if_else(SPIN_T >= 41, "Severo","Moderado")))
sapply(GamingStudy_processed, function(x) sum(is.na(x)))
## S..No. GADE Game Platform Hours whyplay League
## 0 0 0 0 0 0 0
## Narcissism Gender Age Work Degree Birthplace Residence
## 0 0 0 0 0 0 0
## Playstyle GAD_T SWL_T SPIN_T SWL_Class SPIN_Class
## 0 0 0 0 0 0
head(GamingStudy_processed, 5)
## S..No. GADE Game Platform Hours whyplay
## 1 1 Not difficult at all Skyrim Console (PS, Xbox, ...) 15 having fun
## 2 2 Somewhat difficult Other PC 8 having fun
## 3 3 Not difficult at all Other PC 0 having fun
## 4 4 Not difficult at all Other PC 20 improving
## 5 5 Very difficult Other Console (PS, Xbox, ...) 20 having fun
## League Narcissism Gender Age Work
## 1 N/A 1 Male 25 Unemployed / between jobs
## 2 N/A 1 Male 41 Unemployed / between jobs
## 3 n/a 4 Female 32 Employed
## 4 N/A 2 Male 28 Employed
## 5 n/a 1 Male 19 Employed
## Degree Birthplace Residence
## 1 Bachelor\xa0(or equivalent) USA USA
## 2 Bachelor\xa0(or equivalent) USA USA
## 3 Bachelor\xa0(or equivalent) Germany Germany
## 4 Bachelor\xa0(or equivalent) USA USA
## 5 High school diploma (or equivalent) USA South Korea
## Playstyle GAD_T SWL_T
## 1 Singleplayer 1 23
## 2 Multiplayer - online - with strangers 8 16
## 3 Singleplayer 8 17
## 4 Multiplayer - online - with online acquaintances or teammates 0 17
## 5 Multiplayer - online - with strangers 14 14
## SPIN_T SWL_Class SPIN_Class
## 1 5 Satisfecho en General Ninguno/Bajo
## 2 33 No satisfecho Moderado
## 3 31 No satisfecho Moderado
## 4 11 No satisfecho Ninguno/Bajo
## 5 13 No satisfecho Ninguno/Bajo
#print(GamingStudy_processed)
Se muestra un resumen de los valores de cada variable. Adicional se calculan las frecuencias de los valores mas relevantes para el análisis.
summary(GamingStudy_processed)
## S..No. GADE Game Platform
## Min. : 1 Length:10542 Length:10542 Length:10542
## 1st Qu.: 3510 Class :character Class :character Class :character
## Median : 7054 Mode :character Mode :character Mode :character
## Mean : 7076
## 3rd Qu.:10648
## Max. :14250
##
## Hours whyplay League Narcissism
## Min. : 0.00 Length:10542 Length:10542 Min. :1.000
## 1st Qu.: 12.00 Class :character Class :character 1st Qu.:1.000
## Median : 20.00 Mode :character Mode :character Median :2.000
## Mean : 22.77 Mean :2.056
## 3rd Qu.: 30.00 3rd Qu.:3.000
## Max. :8000.00 Max. :5.000
##
## Gender Age Work Degree
## Length:10542 Min. :18.00 Length:10542 Length:10542
## Class :character 1st Qu.:18.00 Class :character Class :character
## Mode :character Median :20.00 Mode :character Mode :character
## Mean :20.82
## 3rd Qu.:22.00
## Max. :50.00
##
## Birthplace Residence Playstyle GAD_T
## Length:10542 Length:10542 Length:10542 2 :1312
## Class :character Class :character Class :character 1 :1215
## Mode :character Mode :character Mode :character 3 :1197
## 4 :1006
## 0 : 892
## 5 : 848
## (Other):4072
## SWL_T SPIN_T SWL_Class SPIN_Class
## Min. : 5.00 Min. : 0.00 Length:10542 Length:10542
## 1st Qu.:14.00 1st Qu.:10.00 Class :character Class :character
## Median :20.00 Median :17.00 Mode :character Mode :character
## Mean :19.63 Mean :19.95
## 3rd Qu.:25.00 3rd Qu.:28.00
## Max. :35.00 Max. :68.00
##
freq_pais = table(GamingStudy_processed$Birthplace)
freq_gender = table(GamingStudy_processed$Gender)
prop_gender = prop.table(freq_gender)*100
print(prop_gender)
##
## Female Male Other
## 4.5627016 95.0578638 0.3794346
freq_work = table(GamingStudy_processed$Work)
prop_work = prop.table(freq_work)*100
print(prop_work)
##
## Employed Student at college / university
## 19.512426 53.822804
## Student at school Unemployed / between jobs
## 16.704610 9.960159
freq_age = table(GamingStudy_processed$Age)
prop_age = prop.table(freq_age)*100
print(prop_age)
##
## 18 19 20 21 22 23
## 26.958831341 16.600265604 13.811420983 11.477897932 8.328590400 6.402959590
## 24 25 26 27 28 29
## 4.809334092 3.727945361 2.352494783 1.584139632 1.109846329 0.853727945
## 30 31 32 33 34 35
## 0.483779169 0.350977044 0.360462910 0.227660785 0.132802125 0.142287991
## 36 37 38 39 40 41
## 0.075886928 0.028457598 0.056915196 0.028457598 0.018971732 0.028457598
## 42 50
## 0.037943464 0.009485866
freq_SPIN = table(GamingStudy_processed$SPIN_Class)
prop_SPIN = prop.table(freq_SPIN)*100
print(prop_SPIN)
##
## Moderado Ninguno/Bajo Severo
## 12.189338 78.969835 8.840827
freq_SWL = table(GamingStudy_processed$SWL_Class)
prop_SWL = prop.table(freq_SWL)*100
print(prop_SWL)
##
## No satisfecho Satisfecho en General Sumamente Satisfecho
## 49.03244 22.42459 28.54297
freq_GAD = table(GamingStudy_processed$GAD_T)
prop_GAD = prop.table(freq_GAD)*100
print(prop_GAD)
##
## 0 1 2 3 4 5 6
## 8.4613925 11.5253273 12.4454563 11.3545817 9.5427813 8.0440144 6.6970214
## 7 8 9 10 11 12 13
## 5.7104914 4.6480744 3.8607475 3.0829065 2.8078164 2.2291785 2.3240372
## 14 15 16 17 18 19 20
## 1.7928287 1.2047050 1.0908746 0.8157845 0.6640106 0.5027509 0.2371467
## 21
## 0.9580725
GamingStudy_processed$GAD_T =as.factor(GamingStudy_processed$GAD_T)
GamingStudy_processed$SWL_Class=as.factor(GamingStudy_processed$SWL_Class)
GamingStudy_processed$SPIN_Class =as.factor(GamingStudy_processed$SPIN_Class)
GamingStudy_processed$Work =as.factor(GamingStudy_processed$Work)
#GamingStudy_processed$Age =as.factor(GamingStudy_processed$Age)
#GamingStudy_processed$hours =as.factor(GamingStudy_processed$hours)
GamingStudy_processed$Age =as.numeric(GamingStudy_processed$Age)
#plot(GamingStudy_processed$Age, col="darkblue", horiz = FALSE, main="Distribución de edades", xlab="Edad", ylab="Encuestados")
plot(GamingStudy_processed$GAD_T, col="darkgreen", horiz = FALSE, main="Distribución de Nivel de Ansiedad", xlab="GAD", ylab="Encuestados")
plot(GamingStudy_processed$SWL_Class, col="darkred", horiz = FALSE, main="Distribución de Satisfacción", xlab="Clasificación", ylab="Encuestados")
plot(GamingStudy_processed$SPIN_Class, col="yellow", horiz = FALSE, main="Distribución de Phobia Social", xlab="Clasificación", ylab="Encuestados")
##plot(GamingStudy_processed$Hours, col="black", horiz = FALSE, main="Distribución de Horas de juego", xlab="Clasificación", ylab="Encuestados")
pie(freq_work, main="Gráfico de sectores de la variable quality", col = c("blue", "yellow", "green", "red", "blue", "purple"))
#hist(GamingStudy_processed$Age,main="Histograma de la variable age", xlab="edad",ylab="frequencia", col="light blue")
hist(GamingStudy_processed$Age,main="Histograma de la variable fixed.acidity", xlab="edad",ylab="densidad", col="light blue", freq = FALSE, ylim = c(0,0.6), xlim = c(15,30))
lines(density(GamingStudy_processed$Age))
Se hace notar que la distribución de las edades de la muestra no es
normal, por lo que la medición puede ser erronea al considerar todo el
universo de datos En esta ocasión no se explorará la normalización de
los datos.
A Partir de las frecuencias observadas, se tomará un enfoque orientado a los resultados de las pruebas y la potencial correlación de sus resultados con edad y ocupación
cat("Promedio: ",mean(GamingStudy_processed$Hours))
## Promedio: 22.76769
cat("Mediana: ",median(GamingStudy_processed$Hours))
## Mediana: 20
#moda
#se crea función para cálculo de moda
mode <- function (x) {
ux <- unique(x)
ux[which.max(tabulate(match(x,ux)))]
}
moda_edad <- mode(GamingStudy_processed$Age)
cat("Moda: ",moda_edad)
## Moda: 18
summary(GamingStudy_processed$Age)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 18.00 18.00 20.00 20.82 22.00 50.00
#mlv(GamingStudy_processed$Age, method = "discrete")
Entender la correlación entre variables
Var_num <- GamingStudy_processed %>%
select("Narcissism", "Age", "GAD_T", "SWL_T", "SPIN_T")
Var_num$Narcissism =as.integer(Var_num$Narcissism)
Var_num$GAD_T =as.integer(Var_num$GAD_T)
Var_num$SWL_T =as.integer(Var_num$SWL_T)
Var_num$SPIN_T =as.integer(Var_num$SPIN_T)
Var_num$Age =as.integer(Var_num$Age)
pairs(Var_num)
M<-cor(Var_num[,1:5]) #creamos la matriz de correlación, OJO, si no quitamos del cálculo la variable quality (factor), nos aparecerá un warning
head(round(M,2), n=5)
## Narcissism Age GAD_T SWL_T SPIN_T
## Narcissism 1.00 -0.03 0.07 -0.01 -0.01
## Age -0.03 1.00 -0.03 0.00 -0.11
## GAD_T 0.07 -0.03 1.00 -0.40 0.44
## SWL_T -0.01 0.00 -0.40 1.00 -0.32
## SPIN_T -0.01 -0.11 0.44 -0.32 1.00
corrplot(M, method="circle")
Podemos observar que las variables con mayor relacion entre si son: 1.
Los resultados de SPIN y los resultados de GAD con un coeficiente de
0.44, que a su vez no es una correlación suficientemente fuerte o
representativa , pero muestr indicios que a mayor Ansiedad, Mayor Phobia
social puede mostrar la persona y 2. Los resultados de SWL y GAD con un
coeficiente negativo de -0.40, que nos indica que se comprtan de manera
inversa, es decir, a mayor satisfacción de la vida responda la persona,
menor su probabilidad de mostrar sintomas de ansiedad y viceversa
Entrando a detalle de las correlaciones podemos obervar la siguiente gráfica.
Nota: no se considera esta correlación como concluyente
pairs(Var_num[3:5])
scatterplot(SPIN_T~GAD_T, Var_num, pch=1, boxplot=FALSE, smooth=FALSE)
abline(lm(SPIN_T~GAD_T,Var_num), col="black")
scatterplot(SWL_T~GAD_T, Var_num, pch=1, boxplot=FALSE, smooth=FALSE, col="red")
abline(lm(SWL_T~GAD_T,Var_num), col="black")
summary(Var_num)
## Narcissism Age GAD_T SWL_T
## Min. :1.000 Min. :18.00 Min. : 1.000 Min. : 5.00
## 1st Qu.:1.000 1st Qu.:18.00 1st Qu.: 3.000 1st Qu.:14.00
## Median :2.000 Median :20.00 Median : 5.000 Median :20.00
## Mean :2.056 Mean :20.82 Mean : 6.405 Mean :19.63
## 3rd Qu.:3.000 3rd Qu.:22.00 3rd Qu.: 9.000 3rd Qu.:25.00
## Max. :5.000 Max. :50.00 Max. :22.000 Max. :35.00
## SPIN_T
## Min. : 0.00
## 1st Qu.:10.00
## Median :17.00
## Mean :19.95
## 3rd Qu.:28.00
## Max. :68.00
You can also embed plots, for example: