From 6a01d3e5bad85645129ad3a4e40236aea2ba5580 Mon Sep 17 00:00:00 2001 From: Santtu Tikka Date: Thu, 30 May 2024 15:26:27 +0300 Subject: [PATCH] fully silence model fits in vignettes --- vignettes/dynamite_custom.Rmd | 19 +++++++++++++++++-- vignettes/dynamite_simulation.Rmd | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/vignettes/dynamite_custom.Rmd b/vignettes/dynamite_custom.Rmd index 300f829..43a67f4 100644 --- a/vignettes/dynamite_custom.Rmd +++ b/vignettes/dynamite_custom.Rmd @@ -56,7 +56,15 @@ to_vector(nu_raw) ~ student_t(df, 0, 1); ``` and add `real df;` to the parameters block. Now we can call the `dynamite` with our new model code, using the `custom_stan_model` argument, which accepts either a `character` string containing the model code or a path to a `.stan` file. -```{r customfit, message=FALSE, error=FALSE, warning=FALSE} +```{r customfitactual, echo=FALSE, eval=TRUE, message=FALSE, error=FALSE, warning=FALSE} +invisible(capture.output({ + fit <- dynamite( + dformula = f, data = gaussian_example, time = "time", group = "id", + custom_stan_model = "custom_code.stan", chains = 1, refresh = 0 + ) +})) +``` +```{r customfit, echo=TRUE, eval=FALSE} fit <- dynamite( dformula = f, data = gaussian_example, time = "time", group = "id", custom_stan_model = "custom_code.stan", chains = 1, refresh = 0 @@ -107,8 +115,15 @@ d <- get_data(fit) Like `get_code()`, this method is available for both `dynamiteformula` and `dynamitefit` objects. With the custom code and the corresponding input data, we can call the variational algorithm of `rstan`: -```{r vbfit, message=FALSE, error=FALSE, warning=FALSE} +```{r vbmodelactual, echo=FALSE, eval=TRUE, message=FALSE, error=FALSE, warning=FALSE} +invisible(capture.output({ + model <- rstan::stan_model("custom_code.stan") +})) +``` +```{r vbmodel, echo=TRUE, eval=FALSE} model <- rstan::stan_model("custom_code.stan") +``` +```{r vbfit} fit_vb <- rstan::vb(model, data = d, iter = 1e5, refresh = 0) ``` diff --git a/vignettes/dynamite_simulation.Rmd b/vignettes/dynamite_simulation.Rmd index 5a001f2..50a3ed9 100644 --- a/vignettes/dynamite_simulation.Rmd +++ b/vignettes/dynamite_simulation.Rmd @@ -175,7 +175,22 @@ init <- list( We fit the model with these fixed values. -```{r gaussianfit, message=FALSE, error=FALSE, warning=FALSE} +```{r gaussianfitactual, echo=FALSE, eval=TRUE, message=FALSE, error=FALSE, warning=FALSE} +invisible(capture.output({ + gaussian_simulation_fit <- dynamite( + dformula = f, + data = d, + time = "time", + group = "id", + chains = 1, + iter = 1, + algorithm = "Fixed_param", + refresh = 0, + init = list(init), + ) +})) +``` +```{r gaussianfit, echo=TRUE, eval=FALSE} gaussian_simulation_fit <- dynamite( dformula = f, data = d,