Skip to content

Commit

Permalink
fully silence model fits in vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
santikka committed May 30, 2024
1 parent 041e4f0 commit 6a01d3e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
19 changes: 17 additions & 2 deletions vignettes/dynamite_custom.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ to_vector(nu_raw) ~ student_t(df, 0, 1);
```
and add `real<lower=2> 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
Expand Down Expand Up @@ -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)
```

Expand Down
17 changes: 16 additions & 1 deletion vignettes/dynamite_simulation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6a01d3e

Please sign in to comment.