Hello R Community,
Subject: Bayes Factor
A Bayesian ANOVA of the form:
competitionBayesOut <- anovaBF(biomass ~ clipping, data = competition)
Returns the following Error message:
Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘compare’ for
signature ‘"BFlinearModel", "missing", "tbl_df"’

My guess the problem is in the ‘class’, which is:
[1] “tbl_df”  “tbl”  “data.frame”
The data was imported via the ‘readr’ package through R Studio, and
then saved as a RData file.
My code is below, and the data is attached as a text file.

Thanks for your assistance.
Best regards,
James

# Plots for Interpreting One-Way ANOVA

library(digest)

library(DT)

datatable(competition)

# Characterize the data.

class(competition)

str(competition)

competition$clipping <- as.factor(competition$clipping)

competition$biomass <- as.numeric(competition$biomass)

str(competition)

#

tapply(competition$biomass, competition$clipping, mean)

tapply(competition$biomass, competition$clipping, sd)





# Bayesian Procedure for ANOVA



# Calculate Bayes Factors

library(BayesFactor)

competitionBayesOut <- anovaBF(biomass ~ clipping, data = competition)

# Run mcmc iterations

mcmcOut2 <- posterior(competitionBayesOut, iterations = 10000)

# boxplot of the posteriors for the groups

boxplot(as.matrix(mcmcOut2[,2:6]))

# Show the HDIs

summary(mcmcOut2)

# Calculate the Bayes Factor

competitionBayesOut



# Pairwise "post hoc" tests

library(rjags)

library(BEST)



# competitionare 'r5' vs. 'control'

plot(BESTmcmc(competition[competition$clpping=="r5",2],
competition[competition$clipping=="control",2]))

#

plot(BESTmcmc(competition[competition$clpping=="r10",2],
competition[competition$clipping=="control",2]))

# competitionare 'n10' vs. 'control'

plot(BESTmcmc(competition[competition$clipping=="n10",2],
competition[competition$clipping=="control",2]))

# competitionare 'n50' vs. 'control'

plot(BESTmcmc(competition[competition$clipping=="n50",2],
competition[competition$clipping=="control",2]))
clipping        biomass
n25     551
n25     457
n25     450
n25     731
n25     499
n25     632
n50     595
n50     580
n50     508
n50     583
n50     633
n50     517
r5      639
r5      615
r5      511
r5      573
r5      648
r5      677
control 417
control 449
control 517
control 438
control 415
control 555
r10     563
r10     631
r10     522
r10     613
r10     656
r10     679
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to