Closed bhym closed 5 years ago
Have you changed multi = "single" into multi = "tab" in your code? Strangely I have not such error when I use your former code with the latest version of the package.
Here is my complete code:
require(vegan)
data(BCI)
arc.res<-rrarefy(BCI, sample=100)
f.sumstats <- function(tab) {
rich <- apply(tab, 1, function(x) sum(x!=0))
shan <- apply(tab, 1, function(x) vegan::diversity(x, index="shannon"))
beta <- lapply(betapart::beta.pair.abund(tab),
function(x) rowMeans(as.matrix(x), na.rm=T))$beta.bray
stats <- c(rich, shan, beta)
names(stats) <- paste0(rep(c("rich", "shan", "beta"), each = 19), 1:19)
return(stats)
}
test.tab <- coalesc_abc(arc.res, multi = "tab",
filt.abc = NULL,
traits = NULL,
prop =F,
f.sumstats = f.sumstats, params = NULL,
theta.max = 100, nb.samp = 100, tol = 0.01,
pkg = c("vegan","betapart"), method.abc = "neuralnet",
parallel = F)
Have you changed multi = "single" into multi = "tab" in your code?
Yes, I did. I edited my first comment accordingly.
Strangely I have not such error when I use your former code with the latest version of the package.
After some tests, I discovered that my data was corrupted. After rebuilding my data sets, things seems to work :)
I will consider this closed. Thank you
I was too optimist!
The code from frmunoz's previous comment seems to be unable to calculate the ABC parameter estimation:
Warning messages:
1: No species pool provided: pool will be simulated and logseries theta estimated
2: No habitat filtering function provided. Neutral communities will be simulated and only m will be estimated
3: Trait information is not provided
4: All parameters are "none" transformed.
5: In abc::abc(target = stats.obs.scaled, param = sim$params.sim, sumstat = sim$stats.scaled, :
No summary statistics names are given, using S1, S2, ...
6: ABC computation failed with the requested method.
If I choose the default method.abc (ie. "rejection"
) things seems to work.
On the other hand, using the coalesc_abc() output:
> abc::abc(target = test.tab$obs, param = test.tab$par, sumstat = test.tab$ss, tol = 0.01, method = "neuralnet")
rror in nnet.default(scaled.sumstat[wt1, ], param[wt1, ], weights = weights, :
nrows of 'x' and 'y' must match
...
For reference:
> package_info(c("ecolottery", "vegan","abc","betapart"), dependen=F)
package * version date lib source
abc 2.1 2015-05-05 [1] CRAN (R 3.5.2)
betapart 1.5.1 2018-10-18 [1] CRAN (R 3.5.2)
ecolottery * 1.2.0 2019-06-12 [1] Github (frmunoz/ecolottery@76284d0)
vegan * 2.5-5 2019-05-12 [1] CRAN (R 3.5.2)
I think that the problem is that you don't have enough simulations to perform ABC analysis (nbsamp=100 is too small).