Description Usage Arguments Details Value References See Also Examples

Beta regression modeling with optional prior distributions for the
coefficients, intercept, and auxiliary parameter `phi`

(if applicable).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | ```
stan_betareg(
formula,
data,
subset,
na.action,
weights,
offset,
link = c("logit", "probit", "cloglog", "cauchit", "log", "loglog"),
link.phi = NULL,
model = TRUE,
y = TRUE,
x = FALSE,
...,
prior = normal(),
prior_intercept = normal(),
prior_z = normal(),
prior_intercept_z = normal(),
prior_phi = exponential(),
prior_PD = FALSE,
algorithm = c("sampling", "optimizing", "meanfield", "fullrank"),
adapt_delta = NULL,
QR = FALSE
)
stan_betareg.fit(
x,
y,
z = NULL,
weights = rep(1, NROW(x)),
offset = rep(0, NROW(x)),
link = c("logit", "probit", "cloglog", "cauchit", "log", "loglog"),
link.phi = NULL,
...,
prior = normal(),
prior_intercept = normal(),
prior_z = normal(),
prior_intercept_z = normal(),
prior_phi = exponential(),
prior_PD = FALSE,
algorithm = c("sampling", "optimizing", "meanfield", "fullrank"),
adapt_delta = NULL,
QR = FALSE
)
``` |

`formula, data, subset` |
Same as `data` is specified (and is a data frame) many
post-estimation functions (including `update` , `loo` ,
`kfold` ) are not guaranteed to work properly. | |||||||||||

`na.action` |
Same as | |||||||||||

`link` |
Character specification of the link function used in the model
for mu (specified through | |||||||||||

`link.phi` |
If applicable, character specification of the link function
used in the model for | |||||||||||

`model, offset, weights` |
Same as | |||||||||||

`x, y` |
In | |||||||||||

`...` |
Further arguments passed to the function in the rstan
package ( | |||||||||||

`prior` |
The prior distribution for the regression coefficients.
See the priors help page for details on the families and
how to specify the arguments for all of the functions in the table above.
To omit a prior —i.e., to use a flat (improper) uniform prior—
| |||||||||||

`prior_intercept` |
The prior distribution for the intercept.
| |||||||||||

`prior_z` |
Prior distribution for the coefficients in the model for
| |||||||||||

`prior_intercept_z` |
Prior distribution for the intercept in the model
for | |||||||||||

`prior_phi` |
The prior distribution for | |||||||||||

`prior_PD` |
A logical scalar (defaulting to | |||||||||||

`algorithm` |
A string (possibly abbreviated) indicating the
estimation approach to use. Can be | |||||||||||

`adapt_delta` |
Only relevant if | |||||||||||

`QR` |
A logical scalar defaulting to | |||||||||||

`z` |
For |

The `stan_betareg`

function is similar in syntax to
`betareg`

but rather than performing maximum
likelihood estimation, full Bayesian estimation is performed (if
`algorithm`

is `"sampling"`

) via MCMC. The Bayesian model adds
priors (independent by default) on the coefficients of the beta regression
model. The `stan_betareg`

function calls the workhorse
`stan_betareg.fit`

function, but it is also possible to call the
latter directly.

A stanreg object is returned
for `stan_betareg`

.

A stanfit object (or a slightly modified
stanfit object) is returned if `stan_betareg.fit`

is called directly.

Ferrari, SLP and Cribari-Neto, F (2004). Beta regression for
modeling rates and proportions. *Journal of Applied Statistics*.
31(7), 799–815.

`stanreg-methods`

and
`betareg`

.

The vignette for `stan_betareg`

.
http://mc-stan.org/rstanarm/articles/

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
### Simulated data
N <- 200
x <- rnorm(N, 2, 1)
z <- rnorm(N, 2, 1)
mu <- binomial(link = "logit")$linkinv(1 + 0.2*x)
phi <- exp(1.5 + 0.4*z)
y <- rbeta(N, mu * phi, (1 - mu) * phi)
hist(y, col = "dark grey", border = FALSE, xlim = c(0,1))
fake_dat <- data.frame(y, x, z)
fit <- stan_betareg(
y ~ x | z, data = fake_dat,
link = "logit",
link.phi = "log",
algorithm = "optimizing" # just for speed of example
)
print(fit, digits = 2)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.