User Tools

Site Tools


neuroimagen:altdti

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
neuroimagen:altdti [2019/03/25 08:59]
osotolongo [Todas las redes]
neuroimagen:altdti [2020/08/04 10:58] (current)
Line 1724: Line 1724:
 F-statistic: 8.719 on 2 and 46 DF,  p-value: 0.0006158 F-statistic: 8.719 on 2 and 46 DF,  p-value: 0.0006158
 </code> </code>
 +
 +
 +===== Riesgo - No riesgo =====
 +
 +Vamosaplantear el problema de manera distinta. Supongamos que la contribucion del APOE depende solo de la presencia del alelo $\epsilon$-4 y clasifiquemos los sujetos segun esto, en //con riesgo// o //sin riesgo//.
 +
 +<code R>
 +> okdata$Risk <- ifelse (okdata$APOE==2 , 1, 0)
 +</code>
 +
 +Pero ahora voy a hacer una cosa un poco mas complicada,
 +
 +<code R get_lms2.r>
 +library(QuantPsyc)
 +x<-read.csv("facehbi_dti_np.csv")
 +Color=c("red","blue")
 +scan("npvars.names", what = character())->np
 +scan("nivars.names", what = character())->ni
 +sink(file = "facehbi_dti_np_models.txt", append = TRUE, type = "output", split = FALSE)
 +
 +for(i in 1:length(np)){
 +        for(j in 1:length(ni)){
 +                y.data <- x[c(ni[j], np[i], "female", "Edad", "Escolaridad", "SUVR", "Risk")]
 +                y.data <- y.data[complete.cases(y.data),]
 +                a <- lm( paste ('y.data$', np[i], ' ~ y.data$', ni[j], ' + y.data$SUVR +y.data$Risk + y.data$female + y.data$Edad + y.data$Escolaridad + ', 'y.data$', ni[j], '*y.data$Risk'))
 +                writeLines(paste("NP: ", np[i], " NI: ", ni[j]))
 +                writeLines(paste("R2: ", summary(a)$adj.r.squared, " p-value: ", 1-pf(summary(a)$fstatistic[1], summary(a)$fstatistic[2], summary(a)$fstatistic[3])))
 +                writeLines(paste("p-value (", ni[j],"): ", summary(a)$coef[2,4], " p-value (SUVR): ", summary(a)$coef[3,4]))
 +                beta <- lm.beta(a)
 +                for(k in 1:length(beta)){
 +                        writeLines(paste(names(beta[k]), ": ", beta[k]))
 +                }
 +                writeLines(paste("-------"))
 +        }
 +}
 +sink()
 +</code>
 +
 +Asi que pruebo con el global,
 +
 +<code R>
 +> write.csv(okdata, file="facehbi_dti_np.csv")
 +> source("get_lms2.r")
 +</code>
 +
 +y luego,
 +
 +<code bash>
 +[osotolongo@detritus dti_model]$ ./checkr2.pl 
 +Analizing facehbi_dti_np_models.txt ...
 +
 +DMN_FA, funcioExecutiva_velocprocess_IM
 +r2 = 0.312799089824939, p-value = 2.93098878501041e-14
 +pv_DMN_FA = 0.476462254461098, pv_SUVR = 0.179281559330912 
 +
 +SN_FA, funcioExecutiva_velocprocess_IM
 +r2 = 0.311504329049638, p-value = 3.47499806707674e-14
 +pv_SN_FA = 0.551975051522526, pv_SUVR = 0.181998130409768 
 +
 +FPCustom_FA, funcioExecutiva_velocprocess_IM
 +r2 = 0.311678871879767, p-value = 3.39728245535298e-14
 +pv_FPCustom_FA = 0.151421806156447, pv_SUVR = 0.201473541858229 
 +</code>
 +
 +puaf, a ver,
 +
 +<code R>
 +> m <- lm(okdata$funcioExecutiva_velocprocess_IM ~ okdata$SUVR + okdata$Edad + okdata$Escolaridad + okdata$female + okdata$DMN_FA*okdata$Risk)
 +> summary(m)
 +
 +Call:
 +lm(formula = okdata$funcioExecutiva_velocprocess_IM ~ okdata$SUVR + 
 +    okdata$Edad + okdata$Escolaridad + okdata$female + okdata$DMN_FA * 
 +    okdata$Risk)
 +
 +Residuals:
 +    Min      1Q  Median      3Q     Max 
 +-1.4094 -0.5672 -0.1264  0.3442  4.3680 
 +
 +Coefficients:
 +                           Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)                -4.12971    1.33068  -3.103  0.00221 ** 
 +okdata$SUVR                 0.58201    0.43176   1.348  0.17928    
 +okdata$Edad                 0.05310    0.00865   6.139 4.82e-09 ***
 +okdata$Escolaridad         -0.04301    0.01362  -3.157  0.00186 ** 
 +okdata$female              -0.38688    0.13066  -2.961  0.00346 ** 
 +okdata$DMN_FA               2.24716    3.14978   0.713  0.47646    
 +okdata$Risk                 5.03080    2.38260   2.111  0.03605 *  
 +okdata$DMN_FA:okdata$Risk -15.70430    7.30118  -2.151  0.03276 *  
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 0.8286 on 188 degrees of freedom
 +  (4 observations deleted due to missingness)
 +Multiple R-squared:  0.3375, Adjusted R-squared:  0.3128 
 +F-statistic: 13.68 on 7 and 188 DF,  p-value: 2.936e-14
 +</code>
 +
 +No, gracias. :-\
  
neuroimagen/altdti.1553504348.txt.gz · Last modified: 2020/08/04 10:45 (external edit)