[Rd] Nested design

2011-05-28 Thread unpeatable
Dear R-users,
I have the following problem. I have performed an experiment for which I
gathered a lot of data which I now want to test. The problem is that I
cannot find an appropriate test in R (I am a starter) and someone might give
me a hand. This is what I have done:
Across three sites (Site), I have laid out five transects (Trans)...meaning
five transects in each sites. In each transect I have five Microhabitats
(MH) which should be regarded as subplots (I think). In each transect, every
MH has the same position (so they are not randomized). I now want to test
the effect of Site and MH (nested in Trans) on my response variables.

This is what I do now: model<-aov(Response~Site*MH+error(Trans/MH))

I get the following output: 

Error: Trans
 Df   Sum Sq  Mean Sq
Site  1 0.030294 0.030294

Error: Trans:MH
 Df  Sum Sq Mean Sq
Site  1 10.8367 10.8367
MH3  0.2836  0.0945

Error: Within
  Df  Sum Sq Mean Sq F valuePr(>F)
Site   2 0.92504 0.46252 11.7304 5.880e-05 ***
MH 4 1.86688 0.46672 11.8370 5.645e-07 ***
Site:MH8 1.17041 0.14630  3.7105  0.001615 ** 
Residuals 54 2.12917 0.03943  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

How do I read this?
Any help appreciated!

BTW: I also tried the lme function: model<-lme(Response~Site*MH,
random=~1|Trans/MH)
but then the output is really complicated.

-
Dr. Bjorn JM Robroek
Ecology and Biodiversity Group
Institute of Environmental Biology, Utrecht University
Padualaan 8, 3584 CH Utrecht, The Netherlands
Email address: b.j.m.robr...@uu.nl
http://www.researcherid.com/rid/C-4379-2008
Tel: +31-(0)30-253 6091
--
View this message in context: 
http://r.789695.n4.nabble.com/Nested-design-tp3557388p3557388.html
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] [R] NaN, Inf to NA

2011-05-28 Thread Duncan Murdoch

On 27/05/2011 11:52 AM, Marc Schwartz wrote:


On May 27, 2011, at 10:33 AM, Duncan Murdoch wrote:


On 27/05/2011 11:11 AM, Martin Maechler wrote:

  Duncan Murdoch
  on Fri, 27 May 2011 08:23:14 -0400 writes:


 >   On 11-05-27 4:27 AM, Albert-Jan Roskam wrote:
 >>   Aha! Thank you very much for that clarification! It would
 >>   be much more user friendly if R generated a
 >>   NotImplementedError or something similar. The 'garbage
 >>   results' are pretty misleading, esp. to a novice.

 >   I think that's a good idea.  The default methods are
 >   documented to work on atomic vectors; dataframes are not
 >   atomic vectors, so it would be reasonable to generate an
 >   error.  (See ?is.atomic for a definition of atomic
 >   vectors.)

 >   I'll see if this causes a lot of trouble...

 >   Duncan Murdoch

Duncan,
do you remember the issue of mean(), var(), median(),... etc
that was the topic a few weeks ago ?

I strongly advocated that  mean.data.frame() should become
*deprecated*, and I would propose the same for the functions
mentioned here.


I think you may have misunderstood my proposal.  Currently is.nan, is.finite 
and is.infinite have no data.frame methods, so the default method is used.  The 
problem is that the default method is too permissive:  it operates on the 
data.frame by treating it as a list; then it returns FALSE for each list 
element.  (If there is only one row, it applies the test to the singleton in 
the column.)   This is pretty strange default behaviour.

What I'm proposing is that the default method should trigger an error if you 
try to send it anything that's not atomic.  This gives sensible behaviour in 
most cases; the only one where it doesn't work is a list of singletons, which 
used to be handled sensibly, but will now fail.

(There's still a question about what the answer should be for these functions 
when applied to character or raw vectors, which are both atomic.  I'm leaning 
towards returning FALSE for every element, which matches the current behaviour, 
but perhaps those should also generate an error.)

I think this partially addresses Bill's objection, but not completely.  Someone 
could still put a class on an atomic vector, and that might not be handled 
properly by the default method.


People should  *apply (or *ply) on data frames, and not expect
that all kind of functions have data.frame methods
which are simply equivalent to basically  sapply(,)

{and yes -- all this belongs to R-devel rather than R-help}


Where I've moved it now.

Duncan Murdoch

Martin



I snipped some of the older content and added Bill.

It seems to me that unless the 'x' argument is both atomic and numeric, these 
functions really don't have much utility, if you are going to implement 
standard default behavior and more rigorous error checking.


In the commit yesterday I signalled an error for character or raw vector 
input, and this caused about 30 packages to fail testing.  I checked a 
couple of them, and they both had applied one of the functions to 
character data.  Before introducing the error, these tests were 
basically harmless.


One example had code like this:

stop.na.inf <- function(x) {
  if(any(is.na(x)) | any(is.infinite(x)))
stop("Either an NA or an infinite in the data: ",
 deparse(substitute(x)), ".\n",
 "   Eliminate those values or use imputation")
}

This little utility function was used a lot, including on character 
data.  Since it is rather ugly to say which types are okay to pass, I've 
reverted that part of the change and am running new tests, I will commit 
soon.


(The test could be improved a little; I'll send advice to the author on 
that.  But I don't think we should require x not to be a character vector.)


Duncan Murdoch



So I would support adding an error message if both conditions are not passed, 
rather than an unpredictable result, which an unsuspecting useR might not catch.

I agree that the non-default methods should be deprecated.

Regards,

Marc



__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel