Description Usage Arguments Value Examples
View source: R/bayescopulaglm.R
Sample from a GLM via Bayesian copula regression model. Uses random-walk Metropolis to update regression coefficients and dispersion parameters. Assumes Inverse Wishart prior on augmented data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
formula.list |
A J-dimensional list of formulas giving how the endpoints are related to the covariates |
family.list |
A J-dimensional list of families giving how each endpoint is distributed. See |
data |
A |
histdata |
Optional historical data set for power prior on β, φ |
b0 |
Optional power prior hyperparameter. Ignored if |
c0 |
A J-dimensional vector for β \mid φ prior covariance. If |
alpha0 |
A J-dimensional vector giving the shape hyperparameter for each dispersion parameter on the prior on φ. If |
gamma0 |
A J-dimensional vector giving the rate hyperparameter for each dispersion parameter on the prior on φ. If |
Gamma0 |
Initial value for correlation matrix. If |
S0beta |
A J-dimensional |
sigma0logphi |
A J-dimensional |
v0 |
An integer scalar giving degrees of freedom for Inverse Wishart prior. If |
V0 |
An integer giving inverse scale parameter for Inverse Wishart prior. If |
beta0 |
A J-dimensional |
phi0 |
A J-dimensional |
M |
Number of desired posterior samples after burn-in and thinning |
burnin |
burn-in parameter |
thin |
post burn-in thinning parameter |
adaptive |
logical indicating whether to use adaptive random walk MCMC to estimate parameters. This takes longer, but generally has a better acceptance rate |
A named list.
["betasample"]
gives a J-dimensional list of sampled coefficients as matrices.
["phisample"]
gives a M \times J matrix of sampled dispersion parameters.
["Gammasample"]
gives a J \times J \times M array of sampled correlation matrices.
["betaaccept"]
gives a M \times J matrix where each row indicates whether the proposal for the regression coefficient was accepted.
["phiaccept"]
gives a M \times J matrix where each row indicates whether the proposal for the dispersion parameter was accepted
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 | set.seed(1234)
n <- 100
M <- 100
x <- runif(n, 1, 2)
y1 <- 0.25 * x + rnorm(100)
y2 <- rpois(n, exp(0.25 * x))
formula.list <- list(y1 ~ 0 + x, y2 ~ 0 + x)
family.list <- list(gaussian(), poisson())
data = data.frame(y1, y2, x)
## Perform copula regression sampling with default
## (noninformative) priors
sample <- bayescopulaglm(
formula.list, family.list, data, M = M, burnin = 0, adaptive = F
)
## Regression coefficients
summary(do.call(cbind, sample$betasample))
## Dispersion parameters
summary(sample$phisample)
## Posterior mean correlation matrix
apply(sample$Gammasample, c(1,2), mean)
## Fraction of accepted betas
colMeans(sample$betaaccept)
## Fraction of accepted dispersion parameters
colMeans(sample$phiaccept)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.