how to get the variance explained by the independent variable from multivariate distance matrix regression model with random effect?
2
0
Entering edit mode
15 days ago
leranwangcs ▴ 120

Hi,

I used mixed.mdmr() function from r package MDMR to fit a regression model with a distance matrix as the response variable and multiple variables as the fixed effects. And since there are repeated samples from each patient, I used Patient ID as the random effect. My model looks like this:

res <- mixed.mdmr(~ treatment + (1|paitnet_ID))

To check the result with summary(res), I got:

#               Statistic Numer.DF   p.value    
# Omnibus            2.69        1   0.01078 *  
# (Intercept)        3.64        1 0.0014491 ** 
# treatment         2.74        1  0.009606 **

What I need is the percentage of variance explained by the variable "treatment", similar thing to R2 value in a linear regression model. But at least in this package and this function, there is no such value.

Anyone who has used this package can provide some advice on how to get the explained variance from the model? Or if any one knows any package that can do this, please share.

Thanks!

Leran

multivariate-distance-matrix regression • 460 views
ADD COMMENT
1
Entering edit mode
14 days ago
LChart 3.9k

The issue here is the use of a mixed-effect model, which stymies any attempts to calculate (pseudo) R-squared.

Believe it or not, the way that mdmr works is to apply a (mixed) linear model to all of the MDS components, and the individual F statistic [for each variable] is the weighted sum of the statistic from each individual test, weighted by the MDS eigenvalue. As such, it is likely far more informative to actually perform these tests uni-variately as a post-hoc analysis. You will still have the issue that lmer does not give you r-squared values for mixed effect models. However, because you have only a single fixed effect, the marginal R2 computed by MuMIn or r2mlm will provide you a variance explained -- again, for the univariate test on each MDS component.

A thought (I have not actually evaluated this mathematically) is that you can sum up the variance explained as:

expl[k] = rsq[k] * total_variance[k]

var_exp_total = sum(expl * lambda)/sum(total_variance * lambda)  # all vectors, so the lambda doesn't actually cancel
ADD COMMENT
0
Entering edit mode

Thanks for your response! I have no statistics background so a bit hard to figure our the equation you provide with. I just want to find some tools that can allow me to fit this model.

ADD REPLY
0
Entering edit mode
14 days ago
LChart 3.9k

More explicitly:

G <- mdmr::gower(distance.matrix)
eig <- eigen(G)
U <- eig$vectors   ## this is the MDS embedding matrix
lambda <- eig$values  ## these are the eigenvalues

## Test each embedding individually by changing `k`
y <- U[,k]
fmla.full <- y ~ treatment + (1|patient_id)

# Fit full model
lmer.full <- lmer(fmla.full, REML = F,
                     lmerControl(calc.derivs = F))

chisq.res <- car::Anova(lmer.full, type = "III", test.statistic = "Chisq")

rsq <- MuMIn::r.squaredGLMM(lmer.full)
ADD COMMENT

Login before adding your answer.

Traffic: 2921 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6