Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseline data simulation #218

Merged
merged 24 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9003
rev: v0.3.2.9019
hooks:
- id: style-files
args: []
- id: roxygenize
additional_dependencies:
- knitr
- stan-dev/cmdstanr@*release
- mvtnorm
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
Expand Down Expand Up @@ -49,11 +51,11 @@ repos:
- id: no-browser-statement
- id: deps-in-desc
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.3
rev: v3.0.1
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ["--maxkb=200"]
Expand All @@ -79,7 +81,7 @@ repos:
files: '\.Rhistory|\.RData|\.Rds|\.rds$'
# `exclude: <regex>` to allow committing specific files.
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2
rev: v0.34.0
hooks:
- id: markdownlint
args:
Expand Down
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ Imports:
glue,
methods,
graphics,
posterior
posterior,
generics,
Matrix,
mvtnorm
Suggests:
survival,
flexsurv,
Expand Down Expand Up @@ -121,6 +124,7 @@ Collate:
'sim_is_null_effect_covered.R'
'sim_is_true_effect_covered.R'
'sim_samplesize.R'
'simulate_data.R'
'simvar_class.R'
'trim_data_matrix.R'
'uniform_prior.R'
Expand Down
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
# Generated by roxygen2: do not edit by hand

export(add_covariates)
export(baseline_covariates)
export(bernoulli_prior)
export(beta_prior)
export(bin_var)
export(binary_cutoff)
export(borrowing_details)
export(cauchy_prior)
export(check_cmdstanr)
export(check_data_matrix_has_columns)
export(cont_var)
export(covariance_matrix)
export(create_analysis_obj)
export(create_baseline_object)
export(create_data_matrix)
export(create_simulation_obj)
export(eval_constraints)
export(exp_surv_dist)
export(exponential_prior)
export(gamma_prior)
export(generate)
export(get_cmd_stan_models)
export(get_quantiles)
export(get_results)
export(get_vars)
export(half_cauchy_prior)
Expand All @@ -41,9 +47,12 @@ export(treatment_details)
export(uniform_prior)
export(variable_dictionary)
export(weib_ph_surv_dist)
exportMethods(generate)
exportMethods(mcmc_sample)
import(checkmate)
import(cmdstanr)
importFrom(Matrix,nearPD)
importFrom(generics,generate)
importFrom(graphics,axis)
importFrom(graphics,lines)
importFrom(graphics,par)
Expand All @@ -53,7 +62,9 @@ importFrom(methods,callNextMethod)
importFrom(methods,is)
importFrom(methods,new)
importFrom(methods,show)
importFrom(mvtnorm,rmvnorm)
importFrom(stats,complete.cases)
importFrom(stats,formula)
importFrom(stats,model.matrix)
importFrom(stats,pnorm)
importFrom(stats,setNames)
9 changes: 6 additions & 3 deletions R/cmdstan.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#' Check Stan
#'
#' @description Check whether `cmdstanr` is available and prints version and logistic example.
#' @param check_sampling Compile and sample from the "logistic" example model.
#'
#' @export
#'
#' @examples
#' check_cmdstanr()
check_cmdstanr <- function() {
check_cmdstanr <- function(check_sampling = FALSE) {
cat("cmdstan version: \n")
print(cmdstan_version())

cat("Example program:\n")
print_example_program(example = c("logistic"))

cat("Example program results:\n")
cmdstanr_example("logistic", quiet = FALSE, chains = 1)
if (check_sampling) {
cat("Example program results:\n")
cmdstanr_example("logistic", quiet = FALSE, chains = 1)
}
}
11 changes: 10 additions & 1 deletion R/generics.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Plot Prior Objects
#'
#' Plot prior distributions as densities. Continuous distributions are plotted as curves and
Expand Down Expand Up @@ -85,3 +84,13 @@ setGeneric("get_results", function(object) standardGeneric("get_results"))
#' @export
#'
setGeneric("get_cmd_stan_models", function(object) standardGeneric("get_cmd_stan_models"))

#' Generate Data from Object
#'
#' @param x object
#' @param ... Other arguments passed to methods
#'
#' @rdname generate
#'
#' @export
setGeneric("generate", function(x, ...) standardGeneric("generate"))
Loading
Loading