Title: | Discrete Beta Regression |
---|---|
Description: | Bayesian Beta Regression, adapted for bounded discrete responses, commonly seen in survey responses. Estimation is done via Markov Chain Monte Carlo sampling, using a Gibbs wrapper around univariate slice sampler (Neal (2003) <DOI:10.1214/aos/1056562461>), as implemented in the R package MfUSampler (Mahani and Sharabiani (2017) <DOI: 10.18637/jss.v078.c01>). |
Authors: | Alireza Mahani [cre, aut], Mansour Sharabiani [aut], Alex Bottle [aut], Cathy Price [aut] |
Maintainer: | Alireza Mahani <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.4.1 |
Built: | 2024-12-09 03:12:52 UTC |
Source: | https://github.com/cran/DBR |
Utility function to call MCMC diagnostic functions in the coda package
coda_wrapper(dbr_obj, coda_function, ...)
coda_wrapper(dbr_obj, coda_function, ...)
dbr_obj |
An object of class |
coda_function |
A function in the coda package, with first argument being an |
... |
Arguments to be passed to |
The output of coda_function
.
Mansour T.A. Sharabiani, Alireza S. Mahani
library("DBR") library("coda") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 50 , nburnin = 25 ) ) coda_wrapper(est, autocorr, lag = c(0, 5))
library("DBR") library("coda") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 50 , nburnin = 25 ) ) coda_wrapper(est, autocorr, lag = c(0, 5))
Discretised Beta Regression for Survey-Response Analysis
dbr( formula , data , control = dbr.control() , yunique = NULL , wghts = rep(1, nrow(data)) ) dbr.control( nsmp = 100 , nburnin = 50 , estimate_left_buffer = FALSE , estimate_right_buffer = FALSE , buffer_max = 5.0 )
dbr( formula , data , control = dbr.control() , yunique = NULL , wghts = rep(1, nrow(data)) ) dbr.control( nsmp = 100 , nburnin = 50 , estimate_left_buffer = FALSE , estimate_right_buffer = FALSE , buffer_max = 5.0 )
formula |
Standard |
data |
Data frame containing response and predictors as described in |
control |
List of parameters for controlling the MCMC estimation. |
yunique |
Vector of values/levels that the response variable can assume. If not specified, this will be extracted from the |
wghts |
Vector of weights to be applied during model estimation. Default is a uniform weight vector. |
nsmp |
Number of MCMC samples to collect, including the burnin phase. |
nburnin |
Number of initial MCMC samples to discard before calculating parameter estimates. |
estimate_left_buffer |
Boolean flag indicating whether to estimate a left buffer from the data. |
estimate_right_buffer |
Boolean flag indicating whether to estimate a right buffer from the data. |
buffer_max |
Maximum size of left/right buffer, only used if above flags are set to TRUE. |
An object of class dbr
, which is a list containing the following fields:
formula |
Same as input. |
control |
Same as input. |
yunique |
Same as input. |
wghts |
Same as input. |
est |
An internal object containing estimation results. Should not be accessed directly by user. Use |
data |
Same as input. |
Mansour T.A. Sharabiani, Alireza S. Mahani
library("DBR") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 50 , nburnin = 25 ) )
library("DBR") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 50 , nburnin = 25 ) )
Based on a survey of nearly 10,000 patients in UK health clinics during 2010-2014 to assess the quality of care they received.
data("pain")
data("pain")
A data frame with 1318 observations on the following 3 variables.
severity
Average of 4 responses, each on a 0-10 scale (11 levels). They measure patients' perception of pain severity - over the 7 days leading up to the survey - at (1) its worst, (2) at its least, (3) on average, and (4) right now.
interference
Average of 7 scores, each on a 0-10 scale (11 levels). These questions measure - over the 7 days leading up to the survey - the level of interference of pain in patient's life along the following dimensions: (1) general activity, (2) mood, (3) walking ability, (4) normal work (outside of home and housework), (5) relations with other people, (6) sleep and (7) enjoyment of life.
age
Age of respondents, in years.
Predict method for Discretised Beta Regression Fits
## S3 method for class 'dbr' predict( object , newdata = NULL , type = c("sample", "point") , ... )
## S3 method for class 'dbr' predict( object , newdata = NULL , type = c("sample", "point") , ... )
object |
Standard |
newdata |
Data frame containing the predictors, matching the |
type |
Whether to make point predictions or generate sample from the predictive distribution. |
... |
Further arguments passed to or from other methods. |
If type
is 'point', this will be a vector of same length as nrow(newdata)
, with unique values consistent with the dbr
call. If type
is 'sample', this will be a 2D array of size nrow(data)
x nsmp
.
Mansour T.A. Sharabiani, Alireza S. Mahani
## Not run: library("DBR") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 200 , nburnin = 100 ) ) predict(est, type = "point") ## End(Not run)
## Not run: library("DBR") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 200 , nburnin = 100 ) ) predict(est, type = "point") ## End(Not run)
Summary, print, plot and coef methods for Discretised Beta Regression Fits
## S3 method for class 'dbr' coef( object , prob = c(0.025, 0.5, 0.975) , ... ) ## S3 method for class 'dbr' print( x , ... ) ## S3 method for class 'dbr' summary( object , context , make_plot = TRUE , ... ) ## S3 method for class 'dbr' plot(x, ...)
## S3 method for class 'dbr' coef( object , prob = c(0.025, 0.5, 0.975) , ... ) ## S3 method for class 'dbr' print( x , ... ) ## S3 method for class 'dbr' summary( object , context , make_plot = TRUE , ... ) ## S3 method for class 'dbr' plot(x, ...)
object |
Result of call to |
x |
Result of call to |
prob |
Vector of probabilities at which to calculate the posterior quantiles of model parameters. |
make_plot |
Whether to generate the context-dependent plots in the |
context |
Dataframe with a single row, containing all columns needed for prediction. These values are used for producing pseudo-coefficient plots in the |
... |
Further arguments passed to the functions. |
For coef
, a 2D array of size length(prob)
x nVar
, where nVar
is the number of model parameters. The latter itself is composed of left and right buffers, precision parameter of beta distribution, and covariate coefficients. Note that if left and/or right buffers were not estimated by dbr
, their confidence interval will be identical to the point estimate. The print
method prints the formula used to call dbr
.
Mansour T.A. Sharabiani, Alireza S. Mahani
library("DBR") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 50 , nburnin = 25 ) ) print(est) plot(est) coef(est, prob = c(0.05, 0.5, 0.95)) summary(est, context = pain[2, ])
library("DBR") data("pain") est <- dbr( interference ~ severity + age , pain , control = dbr.control( nsmp = 50 , nburnin = 25 ) ) print(est) plot(est) coef(est, prob = c(0.05, 0.5, 0.95)) summary(est, context = pain[2, ])