Description Usage Arguments Value Author(s) References See Also Examples
rglmb
is used to generate iid samples for Bayesian Generalized Linear Models.
The model is specified by providing a data vector, a design matrix,
the family (determining the likelihood function) and the pfamily (determining the
prior distribution).
1 2 3 4 |
n |
number of draws to generate. If |
y |
a vector of observations of length |
x |
for |
family |
a description of the error distribution and link
function to be used in the model. For |
pfamily |
a description of the prior distribution and associated constants to be used in the model. This
should be a pfamily function (see |
offset |
this can be used to specify an a priori known component to be included in the linear
predictor during fitting. This should be |
weights |
an optional vector of ‘prior weights’ to be used
in the fitting process. Should be |
digits |
the number of significant digits to use when printing. |
... |
For For |
rglmb
returns a object of class "rglmb"
. The function summary
(i.e., summary.rglmb
) can be used to obtain or print a summary of the results.
The generic accessor functions coefficients
, fitted.values
,
residuals
, and extractAIC
can be used to extract
various useful features of the value returned by rglmb
.
An object of class "rglmb"
is a list containing at least the following components:
coefficients |
a matrix of dimension |
coef.mode |
a vector of |
dispersion |
Either a constant provided as part of the call, or a vector of length |
Prior |
A list with the priors specified for the model in question. Items in the list may vary based on the type of prior |
prior.weights |
a vector of weights specified or implied by the model |
y |
a vector with the dependent variable |
x |
a matrix with the implied design matrix for the model |
famfunc |
Family functions used during estimation process |
iters |
an |
Envelope |
the envelope that was used during sampling |
The R implementation of rglmb
has been written by Kjell Nygren and
was built to be a Bayesian version of the glm
function but with a more minimalistic interface
than the glmb
function. It also borrows some of its structure from other random generating function
like rnorm
and hence the r
prefix.
Dobson, A. J. (1990) An Introduction to Generalized Linear Models. London: Chapman and Hall.
Hastie, T. J. and Pregibon, D. (1992) Generalized linear models. Chapter 6 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole. McCullagh P. and Nelder, J. A. (1989) Generalized Linear Models. London: Chapman and Hall.
Nygren, K.N. and Nygren, L.M (2006) Likelihood Subgradient Densities. Journal of the American Statistical Association. vol.101, no.475, pp 1144-1156. doi: 10.1198/016214506000000357.
Raiffa, Howard and Schlaifer, R (1961) Applied Statistical Decision Theory. Boston: Clinton Press, Inc.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. New York: Springer.
lm
and glm
for classical modeling functions.
family
for documentation of family functions used to specify priors.
pfamily
for documentation of pfamily functions used to specify priors.
Prior_Setup
, Prior_Check
for functions used to initialize and to check priors,
summary.glmb
, predict.glmb
, residuals.glmb
, simulate.glmb
,
extractAIC.glmb
, dummy.coef.glmb
and methods(class="glmb") for glmb
and the methods and generic functions for classes glm
and lm
from which class glmb
inherits.
Other glmbayes modeling functions:
glmb()
,
lmb()
,
rlmb()
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 | data(menarche2)
summary(menarche2)
plot(Menarche/Total ~ Age, data=menarche2)
Age2=menarche2$Age-13
x<-matrix(as.numeric(1.0),nrow=length(Age2),ncol=2)
x[,2]=Age2
y=menarche2$Menarche/menarche2$Total
wt=menarche2$Total
mu<-matrix(as.numeric(0.0),nrow=2,ncol=1)
mu[2,1]=(log(0.9/0.1)-log(0.5/0.5))/3
V1<-1*diag(as.numeric(2.0))
# 2 standard deviations for prior estimate at age 13 between 0.1 and 0.9
## Specifies uncertainty around the point estimates
V1[1,1]<-((log(0.9/0.1)-log(0.5/0.5))/2)^2
V1[2,2]=(3*mu[2,1]/2)^2 # Allows slope to be up to 3 times as large as point estimate
out<-rglmb(n = 1000, y=y, x=x, pfamily=dNormal(mu=mu,Sigma=V1), weights = wt,
family = binomial(logit))
summary(out)
# Add mean(out$iters to rglmb summary function)
mean(out$iters)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.