Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in G * t(hat) : non-conformable arrays

Tags:

r

adonis.js

vegan

Trying to carry out a PERMANOVA using adonis in R. Added in my data table and factors, however, I keep getting the sample error - Error in G * t(hat) : non-conformable arrays

There is no N/A data, and it works with a ready made matrix of data and a subset of my own data table.

Sample data that doesn't work;

subset<-matrix(c(0,0.000666667,0.001333333,0.000333333,0.000333333,0.019833333,0.007666667,0.014666667,0.0005,0.022833333,0.016833333,0.018166667,0.000666667,0.009666667,0.008833333,0.009166667,0.001333333,0.018666667,0.0295,0.031833333),ncol=4)

test_groups<-c(1,1,2,2)
adonis(subset~test_groups)

Error in G * t(hat) : non-conformable arrays

Test data that does work;

test<-matrix(data=c(0.1,0.1,0.3,0.1,0.2,0.3,0.1,0,0.3,0.1,0.2,0.3,0.1,0.2,0.3,0.1),ncol=4)

Why doesn't it work?

like image 369
Bex Avatar asked Nov 07 '22 22:11

Bex


1 Answers

The length of the test_groups vector is 4 while the number of rows of subset is 5.
Below I set to 5 the number of rows of subset and the adonis command works nicely.

library(vegan) 
subset <- matrix(c(0,0.000666667,0.001333333,0.000333333,0.000333333,0.019833333,0.007666667,0.014666667,0.0005,0.022833333,0.016833333,0.018166667,0.000666667,0.009666667,0.008833333,0.009166667,0.001333333,0.018666667,0.0295,0.031833333),ncol=5)
test_groups <- c(1,1,2,2)     
adonis(subset~test_groups)

Here is the result.

'nperm' >= set of all permutations: complete enumeration.
Set of permutations < 'minperm'. Generating entire set.

Call:
adonis(formula = subset ~ test_groups) 

Permutation: free
Number of permutations: 23

Terms added sequentially (first to last)

            Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)
test_groups  1   0.22804 0.22804  1.0592 0.34624 0.3333
Residuals    2   0.43059 0.21530         0.65376       
Total        3   0.65864                 1.00000
like image 84
Marco Sandri Avatar answered Nov 15 '22 07:11

Marco Sandri