## Loading required package: ggplot2
## Loading required package: GGally
##
## Attaching package: 'GGally'
## The following object is masked from 'package:dplyr':
##
## nasa
## [1] "total en googlesheet: 262"
## [1] "excluidos por criterio: 32"
## [1] "excluidos por seguimiento: 6"
## [1] "desde: 2014-01-13"
## [1] "hasta: 2016-01-06"
## Warning: Removed 26 rows containing missing values (geom_point).
## Warning: Removed 26 rows containing missing values (geom_point).
model1<-lm(critotal~añosdeeducacion*diagnosticoCat,
datos.filtrados)
summary(model1)$coef
anova(model1)
datos.completos<-select(.data = datos.filtrados, denominaciondeboston, critotal,diagnosticoCat,edad)%>%mutate (bostonSuccess=denominaciondeboston,bostonFailure=60-denominaciondeboston)
model2<-glm(cbind(bostonSuccess,bostonFailure)~critotal+diagnosticoCat+edad,family="binomial",
datos.completos)
summary(model2)$coef
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.694059218 0.298346578 5.678159 1.361524e-08
## critotal 0.009931598 0.001040639 9.543750 1.377582e-21
## diagnosticoCatDCL -0.592845527 0.064720446 -9.160097 5.185093e-20
## diagnosticoCatDemencia -0.870356700 0.081588111 -10.667690 1.441653e-26
## edad -0.012964437 0.003419818 -3.790973 1.500585e-04
datos.completos<-mutate(datos.completos,
bostonPred=60*exp(predict(model2,datos.completos))/(1+exp(predict(model2,datos.completos))))
Luego de probar varias cosas el mejor modelo de distribución que aplica es negative binomial.
datos.completos<-select(.data = datos.filtrados, tapr, critotal,diagnosticoCat,edad)%>%mutate (taprSuccess=tapr,taprFailure=50-taprSuccess)
model3<-glm(cbind(taprSuccess, taprFailure)~critotal+diagnosticoCat+edad,
family = "binomial",
datos.completos)
## Warning: non-integer counts in a binomial glm!
summary(model3)$coef
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.38052543 0.375476531 -9.003294 2.190457e-19
## critotal 0.02608386 0.001441527 18.094601 3.514769e-73
## diagnosticoCatDCL -0.48342277 0.083499484 -5.789530 7.058366e-09
## diagnosticoCatDemencia -0.37624063 0.107883455 -3.487473 4.876082e-04
## edad 0.02638782 0.004097559 6.439889 1.195606e-10
datos.completos<-mutate(datos.completos,
taprPred=50*exp(predict(model3,datos.completos))/(1+exp(predict(model3,datos.completos))))
## Warning: Removed 26 rows containing non-finite values (stat_smooth).
## Warning: Removed 85 rows containing missing values (geom_point).
## Warning: Removed 26 rows containing non-finite values (stat_smooth).
## Warning: Removed 85 rows containing missing values (geom_point).
model4<-lm(criescuela~añosdeeducacion*diagnosticoCat,datos.filtrados)
summary (model4)$coef
## Estimate Std. Error t value
## (Intercept) 73.0741216 7.0821633 10.3180509
## añosdeeducacion 3.8565126 0.5127965 7.5205518
## diagnosticoCatDCL 2.2116120 7.7357900 0.2858935
## diagnosticoCatDemencia 2.0840323 9.8116165 0.2124046
## añosdeeducacion:diagnosticoCatDCL 0.1511805 0.5748904 0.2629727
## añosdeeducacion:diagnosticoCatDemencia 0.1376158 0.7762450 0.1772840
## Pr(>|t|)
## (Intercept) 3.865162e-20
## añosdeeducacion 2.039998e-12
## diagnosticoCatDCL 7.752679e-01
## diagnosticoCatDemencia 8.320167e-01
## añosdeeducacion:diagnosticoCatDCL 7.928536e-01
## añosdeeducacion:diagnosticoCatDemencia 8.594722e-01
anova(model4)
## Analysis of Variance Table
##
## Response: criescuela
## Df Sum Sq Mean Sq F value Pr(>F)
## añosdeeducacion 1 57748 57748 343.5545 <2e-16 ***
## diagnosticoCat 2 598 299 1.7794 0.1715
## añosdeeducacion:diagnosticoCat 2 12 6 0.0350 0.9657
## Residuals 192 32273 168
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model4<-lm(critrabajo~añosdeeducacion*diagnosticoCat,datos.filtrados)
summary (model4)$coef
## Estimate Std. Error t value
## (Intercept) 83.848784 12.5159598 6.6993492
## añosdeeducacion 2.507587 0.9062401 2.7670232
## diagnosticoCatDCL -11.648510 13.6710821 -0.8520547
## diagnosticoCatDemencia -36.160168 17.3395884 -2.0854110
## añosdeeducacion:diagnosticoCatDCL 0.688953 1.0159757 0.6781196
## añosdeeducacion:diagnosticoCatDemencia 2.392596 1.3718197 1.7441036
## Pr(>|t|)
## (Intercept) 2.258500e-10
## añosdeeducacion 6.210329e-03
## diagnosticoCatDCL 3.952453e-01
## diagnosticoCatDemencia 3.835400e-02
## añosdeeducacion:diagnosticoCatDCL 4.985123e-01
## añosdeeducacion:diagnosticoCatDemencia 8.274141e-02
anova(model4)
## Analysis of Variance Table
##
## Response: critrabajo
## Df Sum Sq Mean Sq F value Pr(>F)
## añosdeeducacion 1 43904 43904 83.6312 <2e-16 ***
## diagnosticoCat 2 1271 635 1.2104 0.3003
## añosdeeducacion:diagnosticoCat 2 1695 848 1.6146 0.2017
## Residuals 192 100795 525
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model4<-lm(critiempolibre~añosdeeducacion*diagnosticoCat,datos.filtrados)
summary (model4)$coef
## Estimate Std. Error t value
## (Intercept) 92.56753543 8.9878524 10.29918282
## añosdeeducacion 1.23481743 0.6507813 1.89743850
## diagnosticoCatDCL -9.12632504 9.8173589 -0.92961103
## diagnosticoCatDemencia -32.07968898 12.4517548 -2.57631872
## añosdeeducacion:diagnosticoCatDCL 0.03436258 0.7295836 0.04709889
## añosdeeducacion:diagnosticoCatDemencia 1.36743018 0.9851193 1.38808589
## Pr(>|t|)
## (Intercept) 4.385724e-20
## añosdeeducacion 5.927083e-02
## diagnosticoCatDCL 3.537398e-01
## diagnosticoCatDemencia 1.073694e-02
## añosdeeducacion:diagnosticoCatDCL 9.624834e-01
## añosdeeducacion:diagnosticoCatDemencia 1.667194e-01
anova(model4)
## Analysis of Variance Table
##
## Response: critiempolibre
## Df Sum Sq Mean Sq F value Pr(>F)
## añosdeeducacion 1 10749 10749.3 39.7064 1.974e-09 ***
## diagnosticoCat 2 5314 2657.2 9.8151 8.739e-05 ***
## añosdeeducacion:diagnosticoCat 2 768 384.0 1.4185 0.2446
## Residuals 192 51978 270.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
datos.filtrados$diagnosticoCat<-relevel(datos.filtrados$diagnosticoCat,"DCL")
model4<-lm(critiempolibre~añosdeeducacion*diagnosticoCat,datos.filtrados)
summary (model4)$coef
## Estimate Std. Error
## (Intercept) 83.44121040 3.9495624
## añosdeeducacion 1.26918001 0.3298121
## diagnosticoCatSin deterioro 9.12632504 9.8173589
## diagnosticoCatDemencia -22.95336394 9.4796492
## añosdeeducacion:diagnosticoCatSin deterioro -0.03436258 0.7295836
## añosdeeducacion:diagnosticoCatDemencia 1.33306761 0.8097653
## t value Pr(>|t|)
## (Intercept) 21.12669733 5.604717e-52
## añosdeeducacion 3.84819124 1.619092e-04
## diagnosticoCatSin deterioro 0.92961103 3.537398e-01
## diagnosticoCatDemencia -2.42133051 1.639388e-02
## añosdeeducacion:diagnosticoCatSin deterioro -0.04709889 9.624834e-01
## añosdeeducacion:diagnosticoCatDemencia 1.64623957 1.013503e-01
anova(model4)
## Analysis of Variance Table
##
## Response: critiempolibre
## Df Sum Sq Mean Sq F value Pr(>F)
## añosdeeducacion 1 10749 10749.3 39.7064 1.974e-09 ***
## diagnosticoCat 2 5314 2657.2 9.8151 8.739e-05 ***
## añosdeeducacion:diagnosticoCat 2 768 384.0 1.4185 0.2446
## Residuals 192 51978 270.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
datos.completos<-select (datos.filtrados, criescuela, critrabajo,critiempolibre,
añosdeeducacion, diagnosticoCat)%>%
gather(key = CRI,value = Score, -(añosdeeducacion:diagnosticoCat))
datos.completos$CRI<-as.factor(datos.completos$CRI)
levels(datos.completos$CRI)<-c("Educacion","Tiempo libre", "Trabajo")
grafico4<-ggplot(datos.completos, aes(y = Score,x = añosdeeducacion, color=CRI))
grafico4<-grafico4+geom_jitter(width = .4,height = 0, size=3, alpha=0.5)
grafico4<-grafico4+geom_smooth(method="lm")
grafico4<-grafico4+ylab("CRI")+xlab("Educacion (años)")+theme_bw()
grafico4
grafico4+facet_grid(facets = .~diagnosticoCat)
datos.completos<-select(.data = datos.filtrados,
tapr, critotal, criescuela,
critrabajo, critiempolibre,
diagnosticoCat,edad, diagnosticoCat)%>%
mutate (taprSuccess=tapr,taprFailure=50-taprSuccess)
model5<-glm(cbind(taprSuccess,taprFailure)~criescuela+critrabajo+critiempolibre+diagnosticoCat, family = "binomial",
datos.completos)
## Warning: non-integer counts in a binomial glm!
summary (model5)$coef
## Estimate Std. Error z value
## (Intercept) -2.97508368 0.214675639 -13.858506
## criescuela 0.02461387 0.001843103 13.354584
## critrabajo 0.00193510 0.001347811 1.435736
## critiempolibre 0.00936656 0.001965509 4.765463
## diagnosticoCatSin deterioro 0.40171839 0.083195226 4.828623
## diagnosticoCatDemencia 0.13524519 0.078538491 1.722024
## Pr(>|z|)
## (Intercept) 1.130014e-43
## criescuela 1.113781e-40
## critrabajo 1.510776e-01
## critiempolibre 1.884206e-06
## diagnosticoCatSin deterioro 1.374803e-06
## diagnosticoCatDemencia 8.506511e-02
datos.completos<-select(datos.filtrados, critotal,digitosdirectos,digitosreversos,
waistotal, tmta,tmtb,fluenciasemantica,fluenciafonologica,
denominaciondeboston, refranes, reloj,diagnosticoCat,recuerdodiferidolibre,
recuerdodiferidofacilitado,recuerdodiferidototal, gbtotallibre,
gbtotalfacilitado, gbrecuerdostotales, intrusiones)
model6<-glm(digitosdirectos~critotal+ diagnosticoCat,datos.completos, family="poisson")
round(summary (model6)$coef,3)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.558 0.155 10.070 0.000
## critotal 0.001 0.001 1.045 0.296
## diagnosticoCatSin deterioro 0.075 0.072 1.052 0.293
## diagnosticoCatDemencia -0.011 0.086 -0.128 0.898
model6Pred<-exp(predict(model6,datos.completos))
datos.completos<-mutate(datos.completos, digitosDirPred=model6Pred)
grafico5<-ggplot (datos.completos, aes(y = critotal,x = as.factor(digitosdirectos)))
grafico5<-grafico5 + geom_jitter(width= .2, height = 0,size=3,color="blue",alpha=0.5)
grafico5<-grafico5+ylab("CRI total (puntos)")+xlab("Digitos directos (n)")+theme_bw()
grafico5<-grafico5 + geom_boxplot(fill=NA)+coord_flip()
grafico5<-grafico5+ geom_line(aes(x=digitosDirPred), color="red", size=1)
grafico5
## Warning: Removed 26 rows containing non-finite values (stat_boxplot).
## Warning: Removed 26 rows containing missing values (geom_point).
## Warning: Removed 26 rows containing missing values (geom_path).
grafico5+facet_grid(facets = .~diagnosticoCat)
## Warning: Removed 26 rows containing non-finite values (stat_boxplot).
## Warning: Removed 26 rows containing missing values (geom_point).
## Warning: Removed 4 rows containing missing values (geom_path).
modelAnova1<-aov(formula = critotal~as.factor(digitosdirectos)+diagnosticoCat,datos.completos)
anova(modelAnova1)
## Analysis of Variance Table
##
## Response: critotal
## Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(digitosdirectos) 6 6393 1065.51 2.1146 0.053530 .
## diagnosticoCat 2 4809 2404.67 4.7723 0.009524 **
## Residuals 186 93722 503.88
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(modelAnova1)$diagnosticoCat
## diff lwr upr p adj
## Sin deterioro-DCL 9.062666 0.05465738 18.070675 0.04825493
## Demencia-DCL -5.100334 -15.72044389 5.519776 0.49399901
## Demencia-Sin deterioro -14.163000 -26.16921622 -2.156784 0.01611197
datos.completos<-select(datos.filtrados, id, critotal,digitosdirectos,digitosreversos,
waistotal, tmta,tmtb,fluenciasemantica,fluenciafonologica,
denominaciondeboston, refranes, reloj,diagnosticoCat,recuerdodiferidolibre,
recuerdodiferidofacilitado,recuerdodiferidototal, gbtotallibre,
gbtotalfacilitado, gbrecuerdostotales, intrusiones,fasekasspv,fasekassbp)
modelAnova2<-aov(critotal~fasekasspv+diagnosticoCat,data =filter(datos.completos,fasekasspv!="."))
anova(modelAnova2)
## Analysis of Variance Table
##
## Response: critotal
## Df Sum Sq Mean Sq F value Pr(>F)
## fasekasspv 3 778 259.46 0.4805 0.69654
## diagnosticoCat 2 5161 2580.73 4.7790 0.01028 *
## Residuals 107 57781 540.01
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modelAnova3<-aov(critotal~fasekassbp+diagnosticoCat,data =datos.completos)
anova(modelAnova3)
## Analysis of Variance Table
##
## Response: critotal
## Df Sum Sq Mean Sq F value Pr(>F)
## fasekassbp 3 393 131.13 0.2417 0.867085
## diagnosticoCat 2 5273 2636.39 4.8591 0.009553 **
## Residuals 107 58055 542.57
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
fasekas<-select (datos.completos, id, diagnosticoCat, SBP=fasekassbp, SPV=fasekasspv, critotal)%>%
gather (key = Fasekas,value = score, -id, -diagnosticoCat, -critotal)%>%filter(!is.na(score))%>%filter(score!=".")
## Warning: attributes are not identical across measure variables; they will
## be dropped
grafico6<-ggplot(data= fasekas,aes(x = as.factor(score),y = critotal, color=Fasekas))
grafico6<-grafico6+geom_jitter(width = .4,size=3, alpha=0.5)+geom_boxplot(fill=NA)
grafico6<-grafico6+theme_bw()+xlab("Fasekas (score)")+ylab("Cri total (puntos)")
grafico6<-grafico6+theme(legend.title=element_blank())
grafico6<-grafico6+coord_flip()
grafico6
## Warning: Removed 11 rows containing non-finite values (stat_boxplot).
## Warning: Removed 11 rows containing missing values (geom_point).
grafico6+facet_grid(facets = .~diagnosticoCat)
## Warning: Removed 11 rows containing non-finite values (stat_boxplot).
## Warning: Removed 11 rows containing missing values (geom_point).