Satisfacción

Load paquetes

library(foreign)
library(effects)
library(relaimpo)

Carga de datos

datos <- read.spss("fichero_articulo_JL.sav", to.data.frame = TRUE)
## re-encoding from CP1252
names(datos) <- tolower(names(datos))
datos$c1r <- factor(datos$c1r)
datos$c3rr <- factor(datos$c3rr)

Modelo lineal

mod1 <- lm(obsco1_1 ~ fac1_1 + fac2_1 + fac3_1 + fac4_1 + c1r + c3rr + c4rr + 
    grupo_h, data = datos)

Resumen

summary(mod1)
## 
## Call:
## lm(formula = obsco1_1 ~ fac1_1 + fac2_1 + fac3_1 + fac4_1 + c1r + 
##     c3rr + c4rr + grupo_h, data = datos)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.873 -0.121  0.099  0.284  2.947 
## 
## Coefficients:
##                                     Estimate Std. Error t value Pr(>|t|)
## (Intercept)                         -0.08699    0.02242   -3.88  0.00011
## fac1_1                               0.37858    0.00649   58.29  < 2e-16
## fac2_1                               0.30388    0.00655   46.41  < 2e-16
## fac3_1                               0.50650    0.00631   80.28  < 2e-16
## fac4_1                               0.16433    0.00663   24.80  < 2e-16
## c1r1                                -0.02045    0.01345   -1.52  0.12833
## c3rr1                                0.04146    0.01445    2.87  0.00413
## c4rr                                 0.04862    0.00666    7.30  3.0e-13
## grupo_hHospitales de Especialidades -0.03842    0.01975   -1.95  0.05174
## grupo_hHospitales Comarcales I      -0.15398    0.01986   -7.75  9.5e-15
## grupo_hHospitales Comarcales II     -0.09983    0.01765   -5.65  1.6e-08
## grupo_hHospitales Concentados       -0.17612    0.02382   -7.39  1.5e-13
##                                        
## (Intercept)                         ***
## fac1_1                              ***
## fac2_1                              ***
## fac3_1                              ***
## fac4_1                              ***
## c1r1                                   
## c3rr1                               ** 
## c4rr                                ***
## grupo_hHospitales de Especialidades .  
## grupo_hHospitales Comarcales I      ***
## grupo_hHospitales Comarcales II     ***
## grupo_hHospitales Concentados       ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.759 on 14814 degrees of freedom
##   (36 observations deleted due to missingness)
## Multiple R-squared:  0.465,  Adjusted R-squared:  0.464 
## F-statistic: 1.17e+03 on 11 and 14814 DF,  p-value: <2e-16

Efectos

Efectos <- allEffects(mod1)

Gráfico efectos

Todos los efectos

plot(Efectos)

plot of chunk unnamed-chunk-6

Tipo hospital Lo que nos muestra son la satisfacción media estimada en cada tipo de hospital. Es útil fijarse en la escala de satisfacción, aunque hay diferencias en las medias, la escala va de -0.15 a 0.05 cuando en el gráfico anterior se ve que la escala para por ejemplo fac3_1 es de -2 a 1.

plot(Efectos, "grupo_h", rotx = 90)

plot of chunk unnamed-chunk-7

Tipo hospital y fac3_1 Elegimos fac3_1 porque es la más influyente en el modelo. La satisfacción aumenta con el aumento en fac3_1 y las diferencias según el tipo de hospital son mínimas.

efectos <- Effect(c("grupo_h", "fac3_1"), mod1)
plot(efectos, multiline = TRUE)

plot of chunk unnamed-chunk-8

Si ajustamos un modelo con interacción entre tipo de hospital y fac3_1 sale significativa, pero aún así, el tamaño del efecto es mínimo

mod1.bis <- update(mod1, . ~ . + fac3_1:grupo_h)
library(car)
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:boot':
## 
##     logit
## 
## The following object is masked from 'package:effects':
## 
##     Prestige
Anova(mod1.bis)
## Anova Table (Type II tests)
## 
## Response: obsco1_1
##                Sum Sq    Df F value  Pr(>F)    
## fac1_1           1949     1 3400.68 < 2e-16 ***
## fac2_1           1238     1 2159.55 < 2e-16 ***
## fac3_1           3711     1 6475.54 < 2e-16 ***
## fac4_1            349     1  609.78 < 2e-16 ***
## c1r                 1     1    2.19  0.1390    
## c3rr                4     1    7.62  0.0058 ** 
## c4rr               30     1   52.84 3.8e-13 ***
## grupo_h            54     4   23.70 < 2e-16 ***
## fac3_1:grupo_h     44     4   19.01 1.3e-15 ***
## Residuals        8488 14810                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
efectos <- Effect(c("grupo_h", "fac3_1"), mod1.bis)
plot(efectos, multiline = TRUE)

plot of chunk unnamed-chunk-10

Importancia relativa variables

res <- calc.relimp(mod1, rela = TRUE)  # rela=T es para normalizar
res@lmg
##  grupo_h   fac1_1   fac2_1   fac3_1   fac4_1      c1r     c3rr     c4rr 
## 0.006402 0.265595 0.166164 0.509689 0.045895 0.002426 0.001118 0.002712

Bootstrap

Se trata de ver la distribución de la media lmg , para eso hacemos 1000 remuestreos de los datos Tarda bastante. Mirar la tabla final con los CI

bootresult <- boot.relimp(mod1, b = 1000, type = "lmg", rela = TRUE)
booteval.relimp(bootresult, typesel = "lmg", level = 0.95, bty = "perc", nodiff = TRUE)
## Response variable: obsco1_1 
## Total response variance: 1.075 
## Analysis based on 14826 observations 
## 
## 11 Regressors: 
## Some regressors combined in groups: 
##         Group  grupo_h : grupo_hHospitales de Especialidades grupo_hHospitales Comarcales I grupo_hHospitales Comarcales II grupo_hHospitales Concentados 
## 
##  Relative importance of 8 (groups of) regressors assessed: 
##  grupo_h fac1_1 fac2_1 fac3_1 fac4_1 c1r c3rr c4rr 
##  
## Proportion of variance explained by model: 46.47%
## Metrics are normalized to sum to 100% (rela=TRUE). 
## 
## Relative importance metrics: 
## 
##              lmg
## grupo_h 0.006402
## fac1_1  0.265595
## fac2_1  0.166164
## fac3_1  0.509689
## fac4_1  0.045895
## c1r     0.002426
## c3rr    0.001118
## c4rr    0.002712
## 
## Average coefficients for different model sizes: 
## 
##                                        1group  2groups  3groups  4groups
## fac1_1                               0.381959  0.38061  0.37957  0.37882
## fac2_1                               0.297863  0.29680  0.29642  0.29671
## fac3_1                               0.515231  0.51325  0.51154  0.51007
## fac4_1                               0.159370  0.15798  0.15736  0.15745
## c1r                                  0.120571  0.09942  0.07871  0.05836
## c3rr                                 0.059264  0.05907  0.05805  0.05624
## c4rr                                -0.056720 -0.04104 -0.02558 -0.01034
## grupo_hHospitales de Especialidades -0.063502 -0.06057 -0.05746 -0.05413
## grupo_hHospitales Comarcales I      -0.137187 -0.14101 -0.14423 -0.14694
## grupo_hHospitales Comarcales II      0.001431 -0.01451 -0.02978 -0.04448
## grupo_hHospitales Concentados       -0.066049 -0.08625 -0.10460 -0.12134
##                                       5groups  6groups   7groups  8groups
## fac1_1                               0.378355  0.37816  0.378239  0.37858
## fac2_1                               0.297624  0.29915  0.301242  0.30388
## fac3_1                               0.508846  0.50785  0.507069  0.50650
## fac4_1                               0.158228  0.15965  0.161698  0.16433
## c1r                                  0.038334  0.01856 -0.001018 -0.02045
## c3rr                                 0.053644  0.05030  0.046229  0.04146
## c4rr                                 0.004689  0.01952  0.034161  0.04862
## grupo_hHospitales de Especialidades -0.050584 -0.04679 -0.042744 -0.03842
## grupo_hHospitales Comarcales I      -0.149205 -0.15109 -0.152661 -0.15398
## grupo_hHospitales Comarcales II     -0.058726 -0.07263 -0.086302 -0.09983
## grupo_hHospitales Concentados       -0.136668 -0.15078 -0.163877 -0.17612
## 
##  
##  Confidence interval information ( 1000 bootstrap replicates, bty= perc ): 
## Relative Contributions with confidence intervals: 
##  
##                                 Lower  Upper
##             percentage 0.95     0.95   0.95  
## grupo_h.lmg 0.0064     ____E___ 0.0041 0.0100
## fac1_1.lmg  0.2656     _B______ 0.2382 0.2920
## fac2_1.lmg  0.1662     __C_____ 0.1487 0.1839
## fac3_1.lmg  0.5097     A_______ 0.4771 0.5390
## fac4_1.lmg  0.0459     ___D____ 0.0361 0.0560
## c1r.lmg     0.0024     _____FGH 0.0014 0.0041
## c3rr.lmg    0.0011     _____FGH 0.0002 0.0030
## c4rr.lmg    0.0027     _____FG_ 0.0022 0.0037
## 
## Letters indicate the ranks covered by bootstrap CIs. 
## (Rank bootstrap confidence intervals always obtained by percentile method) 
## CAUTION: Bootstrap confidence intervals can be somewhat liberal.

Nos fijamos en los intervalos de confianza. Las letras indican la posición , fac3_1.lmg es la más importante, seguido de fac1_1.lmg y fac2_1.lmg