Description Usage Arguments Details Value Author(s) See Also Examples
Bayesian functions for ordered logistic or probit modeling with independent normal, t, or Cauchy prior distribution for the coefficients.
1 2 3 4 5 6 7 8 9 10 11 12 13  bayespolr(formula, data, weights, start, ...,
subset, na.action, contrasts = NULL,
Hess = TRUE, model = TRUE,
method = c("logistic", "probit", "cloglog", "cauchit"),
drop.unused.levels=TRUE,
prior.mean = 0,
prior.scale = 2.5,
prior.df = 1,
prior.counts.for.bins = NULL,
min.prior.scale=1e12,
scaled = TRUE,
maxit = 100,
print.unnormalized.log.posterior = FALSE)

formula 
a formula expression as for regression models, of the form

data 
an optional data frame in which to interpret the variables
occurring in 
weights 
optional case weights in fitting. Default to 1. 
start 
initial values for the parameters. This is in the format

... 
additional arguments to be passed to 
subset 
expression saying which subset of the rows of the data should be used in the fit. All observations are included by default. 
na.action 
a function to filter missing data. 
contrasts 
a list of contrasts to be used for some or all of the factors appearing as variables in the model formula. 
Hess 
logical for whether the Hessian (the observed information matrix) should be returned. 
model 
logical for whether the model matrix should be returned. 
method 
logistic or probit or complementary loglog or cauchit (corresponding to a Cauchy latent variable and only available in R >= 2.1.0). 
drop.unused.levels 
default 
prior.mean 
prior mean for the coefficients: default is 0. Can be a vector of length equal to the number of predictors (not counting the intercepts). If it is a scalar, it is expanded to the length of this vector. 
prior.scale 
prior scale for the coefficients: default is 2.5. Can be a vector of length equal to the number of predictors (not counting the intercepts). If it is a scalar, it is expanded to the length of this vector. 
prior.df 
for t distribution: default is 1 (Cauchy).
Set to 
prior.counts.for.bins 
default is 
min.prior.scale 
Minimum prior scale for the coefficients: default is 1e12. 
scaled 
if 
maxit 
integer giving the maximal number of IWLS iterations, default is 100. This can also be controlled by 
print.unnormalized.log.posterior 
display the unnormalized log posterior
likelihood for bayesglm fit, default= 
The program is a simple alteration of polr
in
VR
version 7.231 that augments the
loglikelihood with the log of the t prior distributions for the
coefficients.
We use Studentt prior distributions for the coefficients. The prior distributions for the intercepts (the cutpoints) are set so they apply to the value when all predictors are set to their mean values.
If scaled=TRUE, the scales for the prior distributions of the
coefficients are determined as follows: For a predictor with only one
value, we just use prior.scale
. For a predictor with two
values, we use prior.scale/range(x).
For a predictor with more than two values, we use prior.scale/(2*sd(x)).
See polr
for details.
prior.mean 
prior means for the cofficients. 
prior.scale 
prior scales for the cofficients. 
prior.df 
prior dfs for the cofficients. 
prior.counts.for.bins 
prior counts for the cutpoints. 
Andrew Gelman [email protected]; YuSung Su [email protected]; Maria Grazia Pittau [email protected]
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60  M1 < polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
display (M1)
M2 < bayespolr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing,
prior.scale=Inf, prior.df=Inf) # Same as M1
display (M2)
M3 < bayespolr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
display (M3)
M4 < bayespolr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing,
prior.scale=2.5, prior.df=1) # Same as M3
display (M4)
M5 < bayespolr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing,
prior.scale=2.5, prior.df=7)
display (M5)
M6 < bayespolr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing,
prior.scale=2.5, prior.df=Inf)
display (M6)
# Assign priors
M7 < bayespolr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing,
prior.mean=rep(0,6), prior.scale=rep(2.5,6), prior.df=c(1,1,1,7,7,7))
display (M7)
#### Another example
y < factor (rep (1:10,1:10))
x < rnorm (length(y))
x < x  mean(x)
M8 < polr (y ~ x)
display (M8)
M9 < bayespolr (y ~ x, prior.scale=Inf, prior.df=Inf, prior.counts.for.bins=0)
display (M9) # same as M1
M10 < bayespolr (y ~ x, prior.scale=Inf, prior.df=Inf, prior.counts.for.bins=10000)
display (M10)
#### Another example
y < factor (rep (1:3,1:3))
x < rnorm (length(y))
x < x  mean(x)
M11 < polr (y ~ x)
display (M11)
M12 < bayespolr (y ~ x, prior.scale=Inf, prior.df=Inf, prior.counts.for.bins=0)
display (M12) # same as M1
M13 < bayespolr (y ~ x, prior.scale=Inf, prior.df=Inf, prior.counts.for.bins=1)
display (M13)
M14 < bayespolr (y ~ x, prior.scale=Inf, prior.df=Inf, prior.counts.for.bins=10)
display (M14)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.