Closed mattocci27 closed 1 year ago
Using this as get_r2_2(log(PA_LMAp), log(PA_LMAs))
doesn't make sense either.
get_r2_2 <- function(ypred, y, median = TRUE) {
#e <- -1 * sweep(ypred, 2, y)
var_ypred <- apply(ypred, 1, var)
var_e <- apply(y - ypred, 1, var)
r2 <- var_ypred / (var_ypred + var_e)
if (median) median(r2) else r2
}
Because y - ypred
is not residual variance.
Simply checking r-value for each MCMC step might be better.
my_cor <- function(x, y, median = TRUE){
N <- nrow(x)
r <- numeric(N)
for (i in 1:N) r[i] <- cor(x[i, ], y[i, ])
if (median) median(r) else r
}
GL_LMAp %>% apply(., 2, median)
is not correct because median LMAp and median LMAs cannot exist together. Usingp_vec <- apply(p_mat, 2, median)
is correct.