Skip to content

Commit

Permalink
docs: Added coef function to readme, updated sample size a bit and tr…
Browse files Browse the repository at this point in the history
…ied to change the performance vignette to run faster
  • Loading branch information
mathiaslj committed Dec 8, 2024
1 parent 97431ba commit d90c8f5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ importFrom(stats,gaussian)
importFrom(stats,is.empty.model)
importFrom(stats,model.matrix)
importFrom(stats,model.response)
importFrom(stats,rnorm)
importFrom(stats,setNames)
importFrom(stats,time)
2 changes: 2 additions & 0 deletions R/mcmcglm-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#' @importFrom stats is.empty.model
#' @importFrom stats model.matrix
#' @importFrom stats model.response
#' @importFrom stats rnorm
#' @importFrom stats setNames
#' @importFrom stats time
## usethis namespace: end
NULL
7 changes: 6 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ withr::local_seed(42)

We first simulate some data from a linear model to use for showcasing the use of `mcmcglm` for a gaussian family.
```{r, label = data-generation}
n <- 100
n <- 1000
x1 <- rnorm (n)
x2 <- rbinom (n, 1, .5)
b0 <- 1
Expand Down Expand Up @@ -75,6 +75,11 @@ summarising the call of the function with averages of the samples of each parame

### Investigating results

The averages shown in the print method of the object can be retrieved with the generic `coef` like so:
```{r, label = gaussian-coef}
coef(norm)
```

The full data set of samples can be accessed with the `samples` function:
```{r, label = gaussian-samples}
head(samples(norm))
Expand Down
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We first simulate some data from a linear model to use for showcasing
the use of `mcmcglm` for a gaussian family.

``` r
n <- 100
n <- 1000
x1 <- rnorm (n)
x2 <- rbinom (n, 1, .5)
b0 <- 1
Expand Down Expand Up @@ -77,26 +77,35 @@ norm
#>
#> Average of parameter samples:
#> (Intercept) X1 X2
#> 1 1.081188 1.563513 1.733437
#> 1 1.011134 1.490459 2.026047
```

summarising the call of the function with averages of the samples of
each parameter in the GLM model.

### Investigating results

The averages shown in the print method of the object can be retrieved
with the generic `coef` like so:

``` r
coef(norm)
#> (Intercept) X1 X2
#> 1 1.011134 1.490459 2.026047
```

The full data set of samples can be accessed with the `samples`
function:

``` r
head(samples(norm))
#> (Intercept) X1 X2 iteration burnin
#> 1 -1.096156 0.04905045 -1.1984959 0 TRUE
#> 2 5.150198 2.27939313 -2.0547715 1 TRUE
#> 3 1.171198 2.10736753 -1.4556810 2 TRUE
#> 4 2.201093 1.02283189 0.1304377 3 TRUE
#> 5 1.761626 1.99163723 0.3076245 4 TRUE
#> 6 1.715483 1.29845999 1.5699513 5 TRUE
#> (Intercept) X1 X2 iteration burnin
#> 1 0.6173367 -0.004541141 -0.09125636 0 TRUE
#> 2 2.6508146 0.281295470 0.68343132 1 TRUE
#> 3 0.8240996 0.324627659 2.30889073 2 TRUE
#> 4 0.8170086 1.028326905 2.20351455 3 TRUE
#> 5 0.8777350 1.592074284 2.16115289 4 TRUE
#> 6 0.9092187 1.442872350 2.02913214 5 TRUE
```

A trace plot can be seen with the function `trace_plot`:
Expand Down
Binary file modified man/figures/README-gaussian-trace-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions vignettes/performance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ withr::local_seed(42)
### Using default slice function
```{r run-compare-nvars}
res <- compare_eta_comptime_across_nvars(
n_vars = c(2, seq(from = 500, to = 1000, by = 500)),
n_samples = 10,
burnin = 1,
w = 0.5,
parallelise = TRUE)
n_vars = c(2, seq(from = 20, to = 200, by = 20)),
n_samples = 1,
burnin = 0,
w = 0.5)
```

```{r show-compare}
Expand Down

0 comments on commit d90c8f5

Please sign in to comment.