# Introduction to **rstanemax**

This small package performs simple sigmoidal Emax model fit using Stan, without the need of writing Stan model code, inspired by **rstanarm** package.

**rstanarm** package (link) is a very flexible, general purpose tool to perform various Bayesian modeling with formula notations, such as generalized mixed effect models or joint models. One small gap it has is in nonlinear model fitting, where it only accepts nonlinear functions defined in stats package with `SS`

prefixes (link). Unfortunately the (sigmoidal) Emax model, one of the most commonly used nonlinear functions in the field of pharmacometrics, is not among the available functions. The **rstanarm** package also seems to be assuming that we fit nonlinear mixed effect models, but not simple nonlinear models without mixed effects.

I hope this **rstanemax** package will fill the niche gap, allow for easier implementation of Emax model in Bayesian framework, and enable routine uses in the pharmacokinetic/pharmacodynamic field.

This package was build using **rstantools** (link) following a very helpful step-by-step guide (link) on creating a package that depends on RStan.

# Installation

Before installing this package from source, you first have to install RStan and C++ Toolchain.

RStan Getting Started

Also, you have to follow the instruction below if you are using Windows PC.

Installing RStan from source on Windows

After this step you should be able to install the package from GitHub using **devtools**.

```
install.packages(c("devtools"))
library(devtools)
devtools::install_github("yoshidk6/rstanemax")
```

See this blog post (written in Japanese) if the above process doesnâ€™t work.

# How to use

This GitHub pages contains function references and vignette.

## Load **rstanemax**

`library(rstanemax)`

## Run model with a sample dataset

```
data(exposure.response.sample)
fit.emax <- stan_emax(response ~ exposure, data = exposure.response.sample)
fit.emax
```