Skip to content

Commit

Permalink
add fitted RoBMA model for data library (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
FBartos authored Feb 1, 2024
1 parent 2fb4637 commit e18493f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ Imports:
Remotes:
jasp-stats/jaspBase,
jasp-stats/jaspGraphs
Depends:
R (>= 2.10)
LazyData: true
11 changes: 11 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#' @title Example RoBMA fit to Lui 2015 data
#'
#' @description RoBMA fit (with removed posterior samples) for
#' the example analysis on the Lui 2015 data example from AMPPS
#' (vignette at https://cran.r-project.org/web/packages/RoBMA/vignettes/Tutorial.html)
#'
#'
#' @format An RDS file
#'
#' @return An object of class RoBMA.
"exampleRobmaLui2015"
11 changes: 10 additions & 1 deletion R/robustbayesianmetaanalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,14 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU

return()
}
.robmaReadFittedModel <- function(options) {
if (tolower(gsub(" ", "", options[["pathToFittedModel"]])) == "examplerobmalui2015") {
data("exampleRobmaLui2015")
return(exampleRobmaLui2015)
} else {
try(readRDS(file = options[["pathToFittedModel"]]))
}
}
.robmaFitModel <- function(jaspResults, dataset, options) {

if (is.null(jaspResults[["model"]])) {
Expand All @@ -747,7 +755,7 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU

if (options[["inputType"]] == "fittedModel") {

fit <- try(readRDS(file = options[["pathToFittedModel"]]))
fit <- .robmaReadFittedModel(options)

if (jaspBase::isTryError(fit) && grepl("cannot open the connection", fit))
.quitAnalysis(gettext("The specified path does not lead to an existing file."))
Expand Down Expand Up @@ -1793,3 +1801,4 @@ RobustBayesianMetaAnalysis <- function(jaspResults, dataset, options, state = NU
names(priors) <- priorNames
return(priors)
}

Binary file added data/exampleRobmaLui2015.rda
Binary file not shown.

0 comments on commit e18493f

Please sign in to comment.