Open thongnt2 opened 4 years ago
After digging into the code, I found issue with the way that R.squared was calculated. It's in line 55 of file analysis.R in music.basic
function: R.squared = 1 - var(Y - X%*%as.matrix(lm.D.weight$x))/var(Y)
. I fixed this as below, and got more reasonable R.squared values.
#R.squared = 1 - var(Y - X%*%as.matrix(lm.D.weight$x))/var(Y)
RSS <- sum(resid(lm.D.weight)^2) # residual sum of squares
TSS <- sum((Y.weight - mean(Y.weight))^2)
R.squared <- 1 - RSS/TSS
@xuranw Hi Xuran,
Really appreciate you developed this awesome R package. I have a question regarding R-squared. Could you please briefly describe how r-squared is calculated? Why R-squared is negative in some samples when running your example provided in the tutorial (see below)? Should it be between 0 and 1? Do you suggest to use R-squared to assess the deconvolution model (i.e. to know the proportion of variance explained )?
Thanks so much,
Tom