R/stan_betareg.R
, R/stan_betareg.fit.R
stan_betareg.Rd
Beta regression modeling with optional prior distributions for the
coefficients, intercept, and auxiliary parameter phi
(if applicable).
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(autoscale = TRUE), prior_intercept = normal(autoscale = TRUE), prior_z = normal(autoscale = TRUE), prior_intercept_z = normal(autoscale = TRUE), prior_phi = exponential(autoscale = TRUE), 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(autoscale = TRUE), prior_intercept = normal(autoscale = TRUE), prior_z = normal(autoscale = TRUE), prior_intercept_z = normal(autoscale = TRUE), prior_phi = exponential(autoscale = TRUE), prior_PD = FALSE, algorithm = c("sampling", "optimizing", "meanfield", "fullrank"), adapt_delta = NULL, QR = FALSE )
formula, data, subset  Same as 


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 (nonhierarchical) regression coefficients. The default priors are described in the vignette
Prior
Distributions for rstanarm Models.
If not using the default,
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
Note: Unless 

prior_intercept  The prior distribution for the intercept (after centering all predictors, see note below). The default prior is described in the vignette
Prior
Distributions for rstanarm Models.
If not using the default, Note: If using a dense representation of the design matrix
i.e., if the 

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 
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.
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.
Ferrari, SLP and CribariNeto, F (2004). Beta regression for modeling rates and proportions. Journal of Applied Statistics. 31(7), 799815.
stanregmethods
and
betareg
.
The vignette for stan_betareg
.
http://mcstan.org/rstanarm/articles/
### 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 )#> Warning: nonzero return code in optimizing#> Error in chol.default(H) : #> the leading minor of order 2 is not positive definite#> Error in `colnames<`(`*tmp*`, value = new_names): attempt to set 'colnames' on an object with less than two dimensions#> Error in print(fit, digits = 2): object 'fit' not found