Análisis No Paramétrico

Carga de Paquetes


library(summarytools)

library(foreign)

Cargar data


df <- read.spss("BASE.sav", to.data.frame = T , use.value.labels = T)

Adecuación de data

Como la variable dependiente está registrada como objeto de tipo factor, la pasamos a objeto numérico.


df$P1A_TOT_Panel1.n <- as.numeric(df$P1A_TOT_Panel1)

Exploración de base


names(df)
##  [1] "NUM"                        "Paneles"                   
##  [3] "Paneles_01_02"              "Paneles_01_03"             
##  [5] "Formato_Recolección_Panel2" "SEXO"                      
##  [7] "EDAD"                       "P1A_TOT_Panel1"            
##  [9] "P1B_TOT_Panel1"             "P1C_TOT_Panel1"            
## [11] "P1D_TOT_Panel1"             "P5A_Panel1"                
## [13] "P5B_Panel1"                 "P5C_Panel1"                
## [15] "P5D_Panel1"                 "P5E_Panel1"                
## [17] "P5F_Panel1"                 "P5G_Panel1"                
## [19] "P5H_Panel1"                 "P20A_Panel1"               
## [21] "P20B_Panel1"                "P20C_Panel1"               
## [23] "P20D_Panel1"                "P20E_Panel1"               
## [25] "P20F_Panel1"                "P21A_Panel1"               
## [27] "P21B_Panel1"                "P21C_Panel1"               
## [29] "P21D_Panel1"                "P21E_Panel1"               
## [31] "P21F_Panel1"                "P53A_Panel1"               
## [33] "P53B_Panel1"                "P53C_Panel1"               
## [35] "P53D_Panel1"                "P53E_Panel1"               
## [37] "P53F_Panel1"                "P53G_Panel1"               
## [39] "P53H_Panel1"                "P53I_Panel1"               
## [41] "P53J_Panel1"                "P53K_Panel1"               
## [43] "P54A_Panel1"                "P54B_Panel1"               
## [45] "P54C_Panel1"                "P54D_Panel1"               
## [47] "P54E_Panel1"                "P54F_Panel1"               
## [49] "P54G_Panel1"                "NSEmarco"                  
## [51] "NSEGrupMarco"               "PPO"                       
## [53] "Confianza_medios"           "P1A_TOT_Panel1.n"

1. Estadísticos descriptivos


with(df, stby(P1A_TOT_Panel1.n, INDICES = NSEGrupMarco, 
                   FUN = descr))
## Descriptive Statistics  
## P1A_TOT_Panel1.n by NSEGrupMarco  
## Data Frame: df  
## N: 95  
## 
##                        A/B        C      D/E
## ----------------- -------- -------- --------
##              Mean     5.75     5.94     5.33
##           Std.Dev     2.74     2.57     2.73
##               Min     1.00     1.00     1.00
##                Q1     3.00     4.00     3.00
##            Median     8.00     8.00     6.00
##                Q3     8.00     8.00     8.00
##               Max     8.00     8.00     8.00
##               MAD     0.00     0.00     2.97
##               IQR     5.00     4.00     5.00
##                CV     0.48     0.43     0.51
##          Skewness    -0.64    -0.71    -0.43
##       SE.Skewness     0.25     0.16     0.16
##          Kurtosis    -1.33    -1.13    -1.38
##           N.Valid    95.00   243.00   240.00
##         Pct.Valid   100.00   100.00   100.00

2. Evaluación de normalidad

Como se trata de una variable con más de 120 casos, utilizamos la prueba de Kolgomorov


tapply(df$P1A_TOT_Panel1.n, df$NSEGrupMarco,ks.test, "pnorm")
## $`A/B`
## 
##  One-sample Kolmogorov-Smirnov test
## 
## data:  X[[i]]
## D = 0.87199, p-value < 2.2e-16
## alternative hypothesis: two-sided
## 
## 
## $C
## 
##  One-sample Kolmogorov-Smirnov test
## 
## data:  X[[i]]
## D = 0.90318, p-value < 2.2e-16
## alternative hypothesis: two-sided
## 
## 
## $`D/E`
## 
##  One-sample Kolmogorov-Smirnov test
## 
## data:  X[[i]]
## D = 0.84134, p-value < 2.2e-16
## alternative hypothesis: two-sided

Si tueviera menos de 120 casos, utilizamos la prueba de contraste de Shapiro-Wilk

tapply(variable dependiente, variable independiente, shapiro.test)

3. Prueba de contraste estadístico

kruskal.test(df$P1A_TOT_Panel1.n ~ df$NSEGrupMarco) 
## 
##  Kruskal-Wallis rank sum test
## 
## data:  df$P1A_TOT_Panel1.n by df$NSEGrupMarco
## Kruskal-Wallis chi-squared = 7.5192, df = 2, p-value = 0.02329
pairwise.wilcox.test(x = df$P1A_TOT_Panel1.n, g = df$NSEGrupMarco, p.adjust.method = "holm" )
## 
##  Pairwise comparisons using Wilcoxon rank sum test with continuity correction 
## 
## data:  df$P1A_TOT_Panel1.n and df$NSEGrupMarco 
## 
##     A/B   C    
## C   0.500 -    
## D/E 0.311 0.022
## 
## P value adjustment method: holm

Otras pruebas

wilcox.test(variable, mu = parametro, conf.int = TRUE)

wilcox.test(variable depebdiete ~ variable independiente)

wilcox.test(variable 1, variable 2,paired=TRUE)