The function PGLogit
fits logistic models to binomial data using Polya-Gamma latent variables.
PGLogit(formula, weights = 1, data = parent.frame(), n.samples,
n.omp.threads = 1, fit.rep = FALSE, sub.sample, verbose = TRUE, ...)
An object of class PGLogit
which is a list comprising:
a coda
object of posterior samples for
the regression coefficients.
if fit.rep=TRUE
, regression fitted values from posterior samples
specified using sub.sample
.
if fit.rep=TRUE
, 0.5, 0.025, and 0.975 quantiles of the y.hat.samples
.
if fit.rep=TRUE
, replicated outcome from posterior samples
specified using sub.sample
.
if fit.rep=TRUE
, 0.5, 0.025, and 0.975
quantiles of the y.rep.samples
.
if fit.rep=TRUE
, the subset index specified with sub.sample
.
MCMC sampler execution time reported using proc.time()
.
The return object will include additional objects used for subsequent prediction and/or model fit evaluation.
a symbolic description of the regression model to be fit. See example below.
specifies the number of trials for each observation. The default is 1 trial for each observation. Valid arguments are a scalar value that specifies the number of trials used if all observations have the same number of trials, and a vector of length \(n\) that specifies the number of trials for each observation when there are differences in the number of trials.
an optional data frame containing the variables in the
model. If not found in data, the variables are taken from
environment(formula)
, typically the environment from which PGLogit
is called.
the number of posterior samples to collect.
a positive integer indicating
the number of threads to use for SMP parallel processing. The package must
be compiled for OpenMP support. For most Intel-based machines, we
recommend setting n.omp.threads
up to the number of
hyperthreaded cores. Note, n.omp.threads
> 1 might not
work on all systems.
if TRUE
, regression fitted and replicate data will be
returned. The argument sub.sample
controls which MCMC samples
are used to generate the fitted and replicated data.
an optional list that specifies the samples used
for fit.rep
. Valid tags are start
,
end
, and thin
. Given the value associated with the tags,
the sample subset is selected using seq(as.integer(start),
as.integer(end), by=as.integer(thin))
. The default values are
start=floor(0.5*n.samples)
, end=n.samples
and thin=1
.
if TRUE
, model specification and progress of the
sampler is printed to the screen. Otherwise, nothing is printed to
the screen.
currently no additional arguments.
Andrew O. Finley finleya@msu.edu,
Abhirup Datta abhidatta@jhu.edu,
Sudipto Banerjee sudipto@ucla.edu
Polson, N.G., J.G. Scott, and J. Windle. (2013) Bayesian Inference for Logistic Models Using Polya-Gamma Latent Variables. Journal of the American Statistical Association, 108:1339-1349.
##Generate binary data
set.seed(1)
n <- 100
x <- cbind(1, rnorm(n), runif(n,0,1))
beta <- c(0.1,-5, 5)
p <- 1/(1+exp(-(x%*%beta)))
##Assume 5 trials per outcome
weights <- rep(5, n)
y <- rbinom(n, size=weights, prob=p)
m <- PGLogit(y~x-1, weights = rep(5, n), n.samples = 1000)
summary(m)
Run the code above in your browser using DataLab