[R] multivariate analysis by using lme
Spencer Graves
spencer.graves at pdf.com
Mon Aug 21 18:13:20 CEST 2006
You get the "singularity in backsolve" because res1+res2 = 1. If
you replace "res1+res2" everywhere by "res1+res2-1", I believe you will
get more sensible results. The default model assumes a constant term,
and when res1+res2=1, the fixed effects model is singular unless you
explicitly remove the constant by the "-1". Alternatively, you could
get the same thing by deleting either res1 or res2 or by using
"I(res1-res2)" in their place.
Thirty years ago, I got very excited about multivariate analysis
models crudely like this. Since then, I've concluded that they are
rarely as useful as one might think. Have you made normal probability
plots of both variables separately? Are they both reasonably close to
being normally distributed? If yes, have you first tried univariate
variance component models (a) individually and (b) for each variable
using the other as a potential explanatory variable? I don't understand
your 'inter', but there is probably a way to include that in the model.
Only after doing the best I could with univariate modeling would
I then consider multivariate modeling. And then I'd want to think very
carefully about whether the multivariate model(s) under consideration
seemed consistent with the univariate results -- and what else they
might tell me that I hadn't already gotten from the univariate model.
If you've already done all this, I'm impressed. In the almost 30 years
since I realized I should try univariate models first and work up to
multivariate whenever appropriate, I've not found one application where
the extra effort seemed justified. R has made this much easier, but I'm
still looking for that special application that would actually require
the multivariate tools.
Hope this helps.
Spencer Graves
Hui-Ju Tsai wrote:
> Dear R users,
>
>
>
> I have a data structure as follows:
>
>
>
> id two res1 res2 c1 c2 inter
>
> 1 -0.786093166 1 0 1 2 6
>
> 3 -0.308495749 1 0 0 1 2
>
> 5 -0.738033048 1 0 0 0 1
>
> 7 -0.52176252 1 0 1 0 4
>
> 9 -2.023641189 1 0 1 1 5
>
> 10 0.463469887 1 0 1 0 4
>
> 14 0.379364681 1 0 1 0 4
>
> 17 -1.422889721 1 0 0 0 1
>
> 19 -2.582340053 1 0 0 2 3
>
> 20 0.721793018 1 0 1 2 6
>
> 1 -0.867823661 0 1 1 2 6
>
> 3 -0.727418536 0 1 0 1 2
>
> 5 -0.331731368 0 1 0 0 1
>
> 7 -0.835913405 0 1 1 0 4
>
> 9 -0.612541616 0 1 1 1 5
>
> 10 -0.063685221 0 1 1 0 4
>
> 14 0.3511481 0 1 1 0 4
>
> 17 -1.3847698 0 1 0 0 1
>
> 19 -2.232306187 0 1 0 2 3
>
> 20 0.0014117 0 1 1 2 6
>
>
>
> I would like to apply multivariate analysis and test interaction effect in
> the same model by using lme function. The 'two' variable is a bi-variate
> outcome by combining two continuous outcomes. The 'res1' and 'res2' are two
> dummy variables to flag these two outcome variables, separately. The
> interaction term for c1 and c2 is "inter" with 6 levels. What I have done
> are as follows:
>
>
>
> # capture clustering structure
>
>
>
> tmp <- groupedData(two~res1+res2+inter|id,data=a); tmp <- na.exclude(tmp);
>
>
>
> # treat 'inter' as a multi-level variable
>
>
>
> options(contrasts=c(factor="contr.treatment",ordered="contr.poly"));
> tmp$inter <- factor(tmp$inter); contrasts(tmp$inter)
>
>
>
> # perform multivariate analysis and test interaction effect
>
>
>
> m1 <- summary(lme(two~res1+res2+inter, random=~1|id, data=tmp))
>
>
>
> ## Error in MEEM(object, conLin, control$niterEM) :
>
> ## Singularity in backsolve at level 0, block 1
>
>
>
> Unfortunately, I have been unable to get it work. If I removed these two
> dummy variables like this:
>
>
>
> m2 <- summary(lme(two~inter, random=~1|id, data=tmp))
>
>
>
> I did get some outputs, but these outputs in the model m2 were wrong. Is
> there any way to perform multivariate analysis and test interaction effect
> (a multi-level factor) in the same model by lme? In addition, can lme be
> used for multivariate analyses of combining several binary outcome
> variables? Or it may be doable in some R function?
>
>
>
> Many thanks for your suggestions.
>
>
>
> Hui-Ju
>
>
>
>
>
>
>
>
>
> The contents of this e-mail message and any attachments are private and confidential communications intended solely for the addressee(s) named in this message. If you are not the intended recipient of this message, please 1) immediately notify the sender by reply e-mail and then delete this message and its attachments and 2) do not read, use, distribute disclose or copy this message and/or any attachments.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list