Skip to content

Commit

Permalink
Merge pull request #214 from easystats/dev
Browse files Browse the repository at this point in the history
CRAN submission
  • Loading branch information
DominiqueMakowski authored Aug 6, 2019
2 parents 5b95078 + 81d6ffb commit 67dc003
Show file tree
Hide file tree
Showing 32 changed files with 229 additions and 193 deletions.
4 changes: 2 additions & 2 deletions R/bayesfactor_inclusion.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ bayesfactor_inclusion.BFBayesFactor <- function(models, match_models = FALSE, pr
tmp_terms <- make_terms(df.model$Modelnames[m])
if (length(tmp_terms) > 0) {
missing_terms <- !tmp_terms %in% colnames(df.model) # For R < 3.6.0
if (any(missing_terms)) df.model[,tmp_terms[missing_terms]] <- NA # For R < 3.6.0
if (any(missing_terms)) df.model[, tmp_terms[missing_terms]] <- NA # For R < 3.6.0
df.model[m, tmp_terms] <- TRUE
}
}
Expand Down Expand Up @@ -240,4 +240,4 @@ bayesfactor_inclusion.BFBayesFactor <- function(models, match_models = FALSE, pr
}

temp
}
}
2 changes: 1 addition & 1 deletion R/bayesfactor_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bayesfactor_parameters <- function(posterior, prior = NULL, direction = "two-sid

#' @rdname bayesfactor_parameters
#' @export
bayesfactor_savagedickey <- function(posterior, prior = NULL, direction = "two-sided", null = 0, verbose = TRUE, hypothesis = NULL,...) {
bayesfactor_savagedickey <- function(posterior, prior = NULL, direction = "two-sided", null = 0, verbose = TRUE, hypothesis = NULL, ...) {
.Deprecated("bayesfactor_parameters")

dots <- list(...)
Expand Down
12 changes: 6 additions & 6 deletions R/ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@
#' ci(df, method = "HDI", ci = c(.80, .89, .95))
#'
#' library(rstanarm)
#' model <- stan_glm(mpg ~ wt + gear, data = mtcars, chains = 2, iter = 200)
#' model <- stan_glm(mpg ~ wt, data = mtcars, chains = 2, iter = 200)
#' ci(model, method = "ETI", ci = c(.80, .89))
#' ci(model, method = "HDI", ci = c(.80, .89))
#'
#' library(emmeans)
#' model <- emtrends(model, ~1, "wt")
#' ci(model, method = "ETI")
#' ci(model, method = "HDI")
#' \dontrun{
#' library(brms)
#' model <- brms::brm(mpg ~ wt + cyl, data = mtcars)
Expand All @@ -50,6 +45,11 @@
#' bf <- ttestBF(x = rnorm(100, 1, 1))
#' ci(bf, method = "ETI")
#' ci(bf, method = "HDI")
#'
#' library(emmeans)
#' model <- emtrends(model, ~1, "wt")
#' ci(model, method = "ETI")
#' ci(model, method = "HDI")
#' }
#'
#' @export
Expand Down
1 change: 0 additions & 1 deletion R/estimate_density.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,3 @@ density_at <- function(posterior, x, precision = 2^10, method = "kernel", ...) {
density <- estimate_density(posterior, precision = precision, method = method, ...)
stats::approx(density$x, density$y, xout = x)$y
}

10 changes: 6 additions & 4 deletions R/p_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
#' # Robustness to density estimation method
#' set.seed(333)
#' data <- data.frame()
#' for(iteration in 1:250){
#' for (iteration in 1:250) {
#' x <- rnorm(1000, 1, 1)
#' result <- data.frame("Kernel" = p_map(x, method = "kernel"),
#' "KernSmooth" = p_map(x, method = "KernSmooth"),
#' "logspline" = p_map(x, method = "logspline"))
#' result <- data.frame(
#' "Kernel" = p_map(x, method = "kernel"),
#' "KernSmooth" = p_map(x, method = "KernSmooth"),
#' "logspline" = p_map(x, method = "logspline")
#' )
#' data <- rbind(data, result)
#' }
#' data$KernSmooth <- data$Kernel - data$KernSmooth
Expand Down
7 changes: 2 additions & 5 deletions R/reshape_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@
#' reshape_ci(reshape_ci(x))
#' @importFrom stats reshape
#' @export
reshape_ci <- function(x){
reshape_ci <- function(x) {


# Long to wide ----------------
if ("CI_low" %in% names(x) & "CI_high" %in% names(x) & "CI" %in% names(x)) {

ci_position <- which(names(x) == "CI")

# Reshape
if (length(unique(x$CI)) > 1) {

if (!"Parameter" %in% names(x)) {
x$Parameter <- x$CI
remove_parameter <- TRUE
Expand Down Expand Up @@ -56,8 +54,7 @@ reshape_ci <- function(x){


# Wide to long --------------
} else{

} else {
if (!"Parameter" %in% names(x)) {
x$Parameter <- 1:nrow(x)
remove_parameter <- TRUE
Expand Down
7 changes: 3 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@
#' Used in describe_posterior
#' @keywords internal
.reoder_rows <- function(x, out, ci = NULL) {

if(!is.data.frame(out) || nrow(out) == 1){
if (!is.data.frame(out) || nrow(out) == 1) {
return(out)
}

if(is.null(ci)){
if (is.null(ci)) {
refdata <- point_estimate(x, centrality = "median", dispersion = FALSE)
order <- refdata$Parameter
out <- out[match(order, out$Parameter), ]
} else{
} else {
uncertainty <- ci(x, ci = ci)
order <- paste0(uncertainty$Parameter, uncertainty$CI)
out <- out[match(order, paste0(out$Parameter, out$CI)), ]
Expand Down
6 changes: 0 additions & 6 deletions R/utils_hdi_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,3 @@
class(dat) <- unique(c(paste0("bayestestR_", fun), paste0("see_", fun), class(dat)))
dat
}






2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions docs/articles/example2.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/indicesEstimationComparison.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pandoc: 2.7.2
pandoc: 2.7.1
pkgdown: 1.3.0
pkgdown_sha: ~
articles:
Expand Down
Loading

0 comments on commit 67dc003

Please sign in to comment.