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

2013-10-03 Thread Paolo Piras
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@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


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

2013-10-03 Thread Jari Oksanen
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-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] 
on behalf of Paolo Piras [paolo.pi...@uniroma3.it]
Sent: 03 October 2013 14:59
To: r-sig-ecology@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@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

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


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

2013-10-03 Thread Paolo Piras
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.oksa...@oulu.fi
Inviato: giovedì 3 ottobre 2013 14.25
A: Paolo Piras; r-sig-ecology@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-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] 
on behalf of Paolo Piras [paolo.pi...@uniroma3.it]
Sent: 03 October 2013 14:59
To: r-sig-ecology@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@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

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


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

2013-10-03 Thread Jari Oksanen
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.pi...@uniroma3.it]
Sent: 03 October 2013 15:52
To: Jari Oksanen; r-sig-ecology@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.oksa...@oulu.fi
Inviato: giovedì 3 ottobre 2013 14.25
A: Paolo Piras; r-sig-ecology@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-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] 
on behalf of Paolo Piras [paolo.pi...@uniroma3.it]
Sent: 03 October 2013 14:59
To: r-sig-ecology@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@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


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


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

2013-10-03 Thread Paolo Piras
Thanks Jari, I understand
Before going trough the code of rda I would prefer to see if I can do this 
using RsquareAdj

When you say The default method can be called as RsquareAdj(x, n, m), and in 
the default method x is the unadjusted correlation...etc..
my problem is to extract the global unadjusted correlation that is a single 
global R-square; 
As I said, just averaging the single adjusted R-squared does not return the 
same values of RsquareAdj

best
paolo



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

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.pi...@uniroma3.it]
Sent: 03 October 2013 15:52
To: Jari Oksanen; r-sig-ecology@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.oksa...@oulu.fi
Inviato: giovedì 3 ottobre 2013 14.25
A: Paolo Piras; r-sig-ecology@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-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] 
on behalf of Paolo Piras [paolo.pi...@uniroma3.it]
Sent: 03 October 2013 14:59
To: r-sig-ecology@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@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


___
R-sig-ecology mailing list
R