rblockrepeatanovameasures

Friedman (agricolae) error


I'm trying to run a blocked, repeated measures ANOVA with the friedman test (agricolae package). However, I keep getting the same error and I don't understand what it means.

This is the code:

out<-with(nh3,friedman(season,datecode,meannh3, alpha = 0.05, group=TRUE,main=NULL,console=TRUE))  

My data is shaped like this:

class(nh3$meannh3): numeric
class(nh3$season): factor
class(nh3$datecode): factor

My treatment is the season, and they should be blocked by date code. The meannh3 is the variable of interest. The dates are not independent, that's why they are blocked. While the seasonal differences are what I am interested in seeing, that's why it is the treatment. The variable of interest is the concentration of NH3.

This is the error I get:

out<-with(nh3,friedman(season,datecode,meannh3, alpha = 0.05, group=TRUE,main=NULL,console=TRUE))

Study: meannh3 ~ season + datecode 

datecode,  Sum of the ranks

   meannh3 r
1     11.0 3
10    10.5 3
11    15.0 3
13    11.0 3
14    11.0 3
2     17.0 3
3     17.0 3
4     17.0 8
5     12.5 1
6     13.5 3
7     14.5 3
8     15.5 3
9     16.5 3

Friedman's Test
===============
Adjusted for ties
Value: 2.718615
Pvalue chisq : 0.9972256
F value : 0.1277461
Pvalue F: 0.9996747 0.9998106 NaN

Alpha     : 0.05
t-Student : 2.178813
LSD       : 22.04983

Means with the same letter are not significantly different.
GroupTreatment and Sum of the ranks
a      2   17 
a      3   17 
a      4   17 
a      9   16.5 
a      8   15.5 
a      11      15 
a      7   14.5 
a      6   13.5 
a      5   12.5 
a      1   11 
a      13      11 
a      14      11 
a      10      10.5 

Error in `row.names<-.data.frame`(`*tmp*`, value = value) : 
  invalid 'row.names' length
In addition: Warning message:
In pf(T2.aj, ntr - 1, (ntr - 1) * (nr - 1)) : NaNs produced

What does this mean? I've searched for this specific error, and I came up with nothing that made sense, nothing related to the Friedman test. The Study equation spit out above is correct... So, I don't understand.

I have reviewed this page (friedman agricolae returning errors) but it was no help.


Solution

  • This analysis proved to be too difficult - the data was not shaped properly, it needs to be in a matrix for the Friedman (agricolae) test.

    I ended up using repeated measures analysis of variance, permutations, as follows:

    model<-aovp(nh4~season*year+Error(daysinceiceon/season), data=df) summary(model) posthoc.kruskal.nemenyi.test(nh4 ~ season, data =df)

    The aovp is part of the lmPerm package. I know this is a bit outdated, so if anyone has a more updated, supported permutation ANOVA, please let me know.

    Here, my null hypothesis is that there are no differences among seasons, years or season*years and daysinceiceon is the repeated measure.

    Then, if significant differences are found among seasons, I would move on and do a posthoc test (posthoc.kruskal.nemenyi.test) for seasonal differences. When writing these results I will need to indicate that at times, season*year interactions are also significant.