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/22 10:27]
osotolongo [Todas las redes]
neuroimagen:altdti [2020/08/04 10:58] (current)
Line 1650: Line 1650:
  
 </code> </code>
 +
 +Voy a mirar un poco,
 +
 +<code R>
 +> m0 <- lm(okdata0$funcioExecutiva_velocprocess_IM ~ okdata0$SUVR + okdata0$Edad)
 +> summary(m0)
 +
 +Call:
 +lm(formula = okdata0$funcioExecutiva_velocprocess_IM ~ okdata0$SUVR + 
 +    okdata0$Edad)
 +
 +Residuals:
 +    Min      1Q  Median      3Q     Max 
 +-1.3337 -0.5111 -0.1135  0.3141  2.5369 
 +
 +Coefficients:
 +             Estimate Std. Error t value Pr(>|t|)   
 +(Intercept)   2.79206    3.21204   0.869  0.39267   
 +okdata0$SUVR -6.70012    2.41598  -2.773  0.01013 * 
 +okdata0$Edad  0.07533    0.02137   3.526  0.00159 **
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 0.9002 on 26 degrees of freedom
 +Multiple R-squared:  0.4416, Adjusted R-squared:  0.3987 
 +F-statistic: 10.28 on 2 and 26 DF,  p-value: 0.0005129
 +
 +> m1 <- lm(okdata1$funcioExecutiva_velocprocess_IM ~ okdata1$SUVR + okdata1$Edad)
 +> summary(m1)
 +
 +Call:
 +lm(formula = okdata1$funcioExecutiva_velocprocess_IM ~ okdata1$SUVR + 
 +    okdata1$Edad)
 +
 +Residuals:
 +    Min      1Q  Median      3Q     Max 
 +-1.2138 -0.5730 -0.1959  0.2146  4.7844 
 +
 +Coefficients:
 +              Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)  -4.200673   1.052358  -3.992 0.000114 ***
 +okdata1$SUVR  0.002109   0.780712   0.003 0.997849    
 +okdata1$Edad  0.063894   0.011991   5.328 4.82e-07 ***
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 0.8937 on 118 degrees of freedom
 +  (1 observation deleted due to missingness)
 +Multiple R-squared:  0.2052, Adjusted R-squared:  0.1918 
 +F-statistic: 15.24 on 2 and 118 DF,  p-value: 1.3e-06
 +
 +> m2 <- lm(okdata2$funcioExecutiva_velocprocess_IM ~ okdata2$SUVR + okdata2$Edad)
 +> summary(m2)
 +
 +Call:
 +lm(formula = okdata2$funcioExecutiva_velocprocess_IM ~ okdata2$SUVR + 
 +    okdata2$Edad)
 +
 +Residuals:
 +     Min       1Q   Median       3Q      Max 
 +-1.74708 -0.28264 -0.07348  0.26384  2.76441 
 +
 +Coefficients:
 +             Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)  -4.49416    1.14875  -3.912   0.0003 ***
 +okdata2$SUVR  1.34940    0.54032   2.497   0.0161 *  
 +okdata2$Edad  0.04144    0.01738   2.384   0.0213 *  
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 0.8034 on 46 degrees of freedom
 +Multiple R-squared:  0.2749, Adjusted R-squared:  0.2434 
 +F-statistic: 8.719 on 2 and 46 DF,  p-value: 0.0006158
 +</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.1553250464.txt.gz · Last modified: 2020/08/04 10:46 (external edit)