Skip to content

Commit

Permalink
small additions
Browse files Browse the repository at this point in the history
  • Loading branch information
topipa committed Aug 27, 2023
1 parent 99ca341 commit 071dc66
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contributing to IWMM

If you have any ideas for improving this project, or want to contribute something,
feel free to open an issue or pull request.

## Pull request process

* New code should follow the tidyverse [style guide](http://style.tidyverse.org).
You can use the [styler](https://CRAN.R-project.org/package=styler) package to
apply these styles, but please don't restyle code that has nothing to do with
your PR.
* You can use lintr::lint_package() to check for any styling issues
* You can run styler::style_pkg() to automatically fix styling issues
* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with
[Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd-formatting.html),
for documentation.
* We use [testthat](https://cran.r-project.org/package=testthat) for testing.
5 changes: 4 additions & 1 deletion R/example_iwmm_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ iwmm_examples <- function() {
}",
data = list(
N = as.integer(10),
x = c(1.4395244, 1.7698225, 3.5587083, 2.0705084, 2.1292877, 2.4609162, 0.7349388, 1.3131471, 1.5543380, 23.7150650)
x = c(
1.4395244, 1.7698225, 3.5587083, 2.0705084, 2.1292877,
2.4609162, 0.7349388, 1.3131471, 1.5543380, 23.7150650
)
)
)
)
Expand Down
7 changes: 5 additions & 2 deletions R/moment_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ moment_match.matrix <- function(x,
}

if (is.null(expectation_fun)) {
list("draws" = draws, "log_weights" = lw, "pareto_k" = k)
adapted_draws <- list("draws" = draws, "log_weights" = lw, "pareto_k" = k)
} else {
lwf <- compute_lwf(draws, lw, expectation_fun, log_expectation_fun, ...)
psisf <- suppressWarnings(loo::psis(lwf))
Expand Down Expand Up @@ -360,12 +360,15 @@ moment_match.matrix <- function(x,
expectation <- colSums(w * expectation_fun(draws, ...))
}

list(
adapted_draws <- list(
"expectation" = expectation,
"pareto_k" = k,
"pareto_kf" = kf,
"draws" = draws,
"log_weights" = lw
)
}
class(adapted_draws) <- c("adapted_draws", class(adapted_draws))

return(adapted_draws)
}
6 changes: 6 additions & 0 deletions man/moment_match.stanfit.Rd

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

0 comments on commit 071dc66

Please sign in to comment.