Skip to content

Commit

Permalink
Added pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
nclJoshCowley committed Jun 8, 2024
1 parent 13546ae commit 0669927
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@

^README\.qmd$
^README\.Rmd$

^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
50 changes: 50 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ docs/
# translation temp files
po/*~
inst/doc
docs
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Maintainer: Josh Cowley <[email protected]>
Description:
Bayesian Mixture of Experts (MoE) applied to possibly left-censored
linear regression.
URL: https://ncljoshcowley.github.io/bmoe/
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand All @@ -37,3 +38,4 @@ Suggests:
testthat (>= 3.0.0),
tidyr,
quarto

48 changes: 35 additions & 13 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,58 @@ knitr::opts_chunk$set(
)
```

## Purpose

<!-- badges: start -->
<!-- badges: end -->

## Purpose

This repository contains an R package with a focus on Mixture of Experts (MoE)
applied to Bayesian linear and censored regression.

Originally used in a yet to be published thesis, **work is ongoing** to make
this publicly accessible package easier to use.

Tasks remaining include

* Adding `pkgdown` then improving documentation (`README`, vignettes, etc.),

* Possibly migrating to Stan to avoid the JAGS 'ones trick',

* Removing unnecessary code and dependencies,

* Submitting to CRAN for wider use.



## Installation

You can install the development version of `bmoe` from [GitHub](https://github.com/) with:
You can install the development version of `bmoe` from
[GitHub](https://github.com/nclJoshCowley/bmoe) with:

```{.r}
devtools::install_github("nclJoshCowley/bmoe", auth_token = ...)
remotes::install_github("nclJoshCowley/bmoe")
```



## Model Description

TODO: Include model description here.
We present the Mixture of Experts model as a finite mixture model of $K$
parametric linear regressions, where the concomitant weighting parameters
also depend on some predictors.

$$
f(\boldsymbol{y_i} | \boldsymbol{x}_i, \boldsymbol{\omega}, \boldsymbol{\theta})
= \sum_{k=1}^K
\eta_k(\boldsymbol{x}_i | \boldsymbol{\omega}_k)
f_k(\boldsymbol{y_i} | \boldsymbol{x}_i, \boldsymbol{\theta}_k)
$$

Each components' distribution is currently limited to
(conditionally independent) multiple linear regressions where each
response variable can potentially be left-censored.

<!-- TODO: Article to explain what this model is in semi-technical detail -->



Expand Down Expand Up @@ -98,15 +127,8 @@ For example, `y01 + y02 ~ x01 + x02 + x03 | x03` implies two response

### Reporting

Analysis reports can be generated from any fitted object and desired filename.
Analysis reports can be generated from any fitted object and desired file name.

```{.r}
bmoe::render_bmoe_fit(example_fit, "report-name")
```



## Future Work

Extend this `README` with more functionality including relabelling, prediction
and log likelihood.
71 changes: 47 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

## Purpose

<!-- badges: start -->
<!-- badges: end -->

## Purpose

This repository contains an R package with a focus on Mixture of Experts
(MoE) applied to Bayesian linear and censored regression.

Originally used in a yet to be published thesis, **work is ongoing** to
make this publicly accessible package easier to use.

Tasks remaining include

- Adding `pkgdown` then improving documentation (`README`, vignettes,
etc.),

- Possibly migrating to Stan to avoid the JAGS ‘ones trick’,

- Removing unnecessary code and dependencies,

- Submitting to CRAN for wider use.

## Installation

You can install the development version of `bmoe` from
[GitHub](https://github.com/) with:
[GitHub](https://github.com/nclJoshCowley/bmoe) with:

``` r
devtools::install_github("nclJoshCowley/bmoe", auth_token = ...)
remotes::install_github("nclJoshCowley/bmoe")
```

## Model Description

TODO: Include model description here.
We present the Mixture of Experts model as a finite mixture model of $K$
parametric linear regressions, where the concomitant weighting
parameters also depend on some predictors.

$$
f(\boldsymbol{y_i} | \boldsymbol{x}_i, \boldsymbol{\omega}, \boldsymbol{\theta})
= \sum_{k=1}^K
\eta_k(\boldsymbol{x}_i | \boldsymbol{\omega}_k)
f_k(\boldsymbol{y_i} | \boldsymbol{x}_i, \boldsymbol{\theta}_k)
$$

Each components’ distribution is currently limited to (conditionally
independent) multiple linear regressions where each response variable
can potentially be left-censored.

<!-- TODO: Article to explain what this model is in semi-technical detail -->

## Worked Example

Expand All @@ -36,18 +64,18 @@ example_sim <- bmoe::example_simulate_bmoe()

example_sim$data
#> # A tibble: 180 × 4
#> y01 x01 x02 x03
#> <dbl> <dbl> <dbl> <dbl>
#> 1 0.567 -2.59 -0.711 0.784
#> 2 -5.22 -0.940 -1.14 -1.74
#> 3 5.62 0.573 0.285 0.0480
#> 4 -0.730 -1.27 -1.84 -0.119
#> 5 3.97 0.777 0.120 0.769
#> 6 9.59 1.72 1.02 -0.127
#> 7 -4.38 -0.567 -0.826 0.186
#> 8 3.94 0.210 0.510 -0.508
#> 9 1.64 0.220 -0.349 1.64
#> 10 2.85 0.509 -0.105 1.36
#> y01 x01 x02 x03
#> <dbl> <dbl> <dbl> <dbl>
#> 1 -4.03 -1.07 -0.0269 -1.03
#> 2 1.26 -1.36 -1.34 0.901
#> 3 -4.38 1.37 -2.21 -0.277
#> 4 -0.490 -0.463 0.0581 0.0647
#> 5 -0.211 0.0454 -0.446 -0.406
#> 6 7.45 0.456 0.956 0.927
#> 7 4.92 1.03 1.78 2.56
#> 8 -0.140 -0.312 -0.428 0.222
#> 9 -0.162 0.195 0.0182 -0.836
#> 10 2.69 2.47 -1.46 -0.473
#> # ℹ 170 more rows
```

Expand Down Expand Up @@ -110,13 +138,8 @@ based on the linear predictor formed from `x03`.
### Reporting

Analysis reports can be generated from any fitted object and desired
filename.
file name.

``` r
bmoe::render_bmoe_fit(example_fit, "report-name")
```

## Future Work

Extend this `README` with more functionality including relabelling,
prediction and log likelihood.
5 changes: 5 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
url: https://ncljoshcowley.github.io/bmoe/

template:
bootstrap: 5

0 comments on commit 0669927

Please sign in to comment.