[R-sig-eco] vegan RsquareAdj() for lm models

Jari Oksanen jari.oksanen at oulu.fi
Thu Oct 3 15:56:45 CEST 2013


Paolo,

See ?RsquareAdj for the call interface. The default method can be called as RsquareAdj(x, n, m), and in the default method x is the unadjusted correlation, n is the number of observations and m is the number of parameters (degrees of freedom) in the fitted model. Specific methods for univariate lm or for rda (and some others) find these variables in the result object, but then they just call the default method with the found x, n and m. You can build your model on that. It is possible to build a specific function for mlm objects, but nobody has done so in vegan.

You cannot build an rda design without an intercept. It was a conscious design decision to make this impossible without hacking the rda.default code (I even say this in decision-vegan vignette). I am not going to make easy to have non-centred RDA: I care too much about people and i don't want to do evil. If you really *know* that you need non-centred RDA. then you know how to change those lines of code in rda.default. 

Cheers, Jari Oksanen
________________________________________
From: Paolo Piras [paolo.piras at uniroma3.it]
Sent: 03 October 2013 15:52
To: Jari Oksanen; r-sig-ecology at r-project.org
Subject: RE: [R-sig-eco] vegan RsquareAdj() for lm models

Thankyou very much Jari!
I think that it is nearly ok
what I would like to have is the same as in
RsquareAdj(vegan::rda(yy,xx))

that is a GLOBAL measure of the association
BUT...I want it for a multiple-multivariate lm model that does not include the intercept;
an alternative could be to build a rda design for the exclusion of intercept but I really cannot figure out how to do it.

I think I just need to compute the average of single adjusted r squared from the output of your line of code,
But the results are not identical
EXAMPLE  WITH INTERCEPT IN ORDER TO COMPARE WITH RDA

RsquareAdj(vegan::rda(yy,xx))
mean(sapply(summary(lm(yy~xx)), function(x) c("r.squared" = x$r.squared, "adj.r.squared" = x$adj.r.squared))[2,])

Or.... I just miss something in this computation

Thanks again for any further suggestion


________________________________________
Da: Jari Oksanen <jari.oksanen at oulu.fi>
Inviato: giovedì 3 ottobre 2013 14.25
A: Paolo Piras; r-sig-ecology at r-project.org
Oggetto: RE: [R-sig-eco] vegan RsquareAdj() for lm models

Specific reason is that nobody has implemented this. These things don't come by automatic writing, but somebody must do them.

What would you expect to get? Is this what was on your mind:

> sapply(summary(lm(yy~xx-1)), function(x) c("r.squared" = x$r.squared, "adj.r.squared" = x$adj.r.squared))
              Response Y1 Response Y2 Response Y3 Response Y4
r.squared      0.06845032  0.04788037  0.01702738  0.11253059
adj.r.squared -0.01255400 -0.03491264 -0.06844849  0.03535934


This could be implemented, but (1) is this what you or anybody else would like to have?, (2) how many things would it break by returning several values instead of one?

If you want to have this, you really do not need to use vegan. vegan:::RsquareAdj.lm() takes its results from summary(<lm_object>). You can use that stats:::summary.lm directly.

Cheers, Jari Oksanen

________________________________________
From: r-sig-ecology-bounces at r-project.org [r-sig-ecology-bounces at r-project.org] on behalf of Paolo Piras [paolo.piras at uniroma3.it]
Sent: 03 October 2013 14:59
To: r-sig-ecology at r-project.org
Subject: [R-sig-eco] vegan RsquareAdj() for lm models

Dear list,
I would like to easily compute the adjusted R-square in a lm model without intercept (excluding the intercept is essential for my analysis)

I found that RsquareAdj() in vegan returns NA if the argument is  a multiple-multivariate lm model thus including multivariate responses and multiple predictors, while it works for univariate response and multiple predictors.

For example:
library(vegan)

yy<-matrix(rnorm(200,0,1),ncol=4)
xx<-matrix(rnorm(200,0,1),ncol=4)
RsquareAdj(lm(yy~xx-1))
RsquareAdj(lm(yy[,1]~xx-1))



There some specific reason for this behavior?
Thanks in advance for any advice
best regards
Poalo






_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology




More information about the R-sig-ecology mailing list