bigsnpr
bigsnpr copied to clipboard
Trouble getting the model performance in LDPred2
Hi Florian,
I'm using the following codes to obtain the final model summary and I have some troubles as my target variable is binary. Can you suggest how I can obtain a model summary for binary outcome?
#8A. infinitesimal model
reg.formula <- paste("PC", 1:6, sep = "", collapse = "+") %>%
paste0("PAG~PRS+sex+", .) %>%
as.formula
reg.dat <- y
reg.dat$PRS <- pred_inf
inf.model <- lm(reg.formula, dat=reg.dat) %>%
summary
(result <- data.table(
infinitesimal = inf.model$r.squared - null.r2,
null = null.r2
))
#Error: Error in inf.model$r.squared - null.r2 : non-numeric argument to binary operator
#8B. grid model
reg.formula <- paste("PC", 1:6, sep = "", collapse = "+") %>%
paste0("PAG~PRS+sex+", .) %>%
as.formula
reg.dat <- y
max.r2 <- 0
for(i in 1:ncol(pred_grid)){
reg.dat$PRS <- pred_grid[,i]
grid.model <- lm(reg.formula, dat=reg.dat) %>%
summary
if(max.r2 < grid.model$r.squared){
max.r2 <- grid.model$r.squared
}
}
(result <- data.table(
grid = max.r2 - null.r2,
null = null.r2
))
#Error in max.r2 - null.r2 : non-numeric argument to binary operator
#8C. auto model
reg.formula <- paste("PC", 1:6, sep = "", collapse = "+") %>%
paste0("PAG~PRS+sex+", .) %>%
as.formula
reg.dat <- y
reg.dat$PRS <- pred_auto
auto.model <- lm(reg.formula, dat=reg.dat) %>%
summary
(result <- data.table(
auto = auto.model$r.squared - null.r2,
null = null.r2
))
#Error: Error in auto.model$r.squared - null.r2 : non-numeric argument to binary operator
This is a bit out-of-scope, as not really related to my packages.
Anyway, if you want to compute partial correlations, please use bigstatsr::pcor()
; this difference of R2 that everyone seems to be using makes absolutely no sense.
Thanks for the clarification Florian. Assuming that I have obtain PRS in reg.dat file, how can I obtain PRS for the 3 models? (inf, grid and auto) TIA
I am not sure I follow, please elaborate.
I'm following the LDPred2 tutorial from here: https://choishingwan.github.io/PRS-Tutorial/ldpred/
The PRS is stored in daf called reg.dat in the following step:
reg.formula <- paste("PC", 1:6, sep = "", collapse = "+") %>% paste0("Height~PRS+Sex+", .) %>% as.formula reg.dat <- y reg.dat$PRS <- pred_auto auto.model <- lm(reg.formula, dat=reg.dat) %>% summary (result <- data.table( auto = auto.model$r.squared - null.r2, null = null.r2 ))
My question is, the PRS in the above dataset is final PRS from LDPred2 or we can 3 PRS respectively for inf, grid and auto model?
TIA
This is not my LDpred2 tutorial, please use https://privefl.github.io/bigsnpr/articles/LDpred2.html.
If you have questions regarding that other tutorial, please open an issue at https://github.com/choishingwan/PRS-Tutorial/issues.