PGLogit {spNNGP} | R Documentation |
Function for Fitting Logistic Models using Polya-Gamma Latent Variables
Description
The function PGLogit
fits logistic models to binomial data using Polya-Gamma latent variables.
Usage
PGLogit(formula, weights = 1, data = parent.frame(), n.samples,
n.omp.threads = 1, fit.rep = FALSE, sub.sample, verbose = TRUE, ...)
Arguments
formula |
a symbolic description of the regression model to be fit. See example below. |
weights |
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 |
data |
an optional data frame containing the variables in the
model. If not found in data, the variables are taken from
|
n.samples |
the number of posterior samples to collect. |
n.omp.threads |
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 |
fit.rep |
if |
sub.sample |
an optional list that specifies the samples used
for |
verbose |
if |
... |
currently no additional arguments. |
Value
An object of class PGLogit
which is a list comprising:
p.beta.samples |
a |
y.hat.samples |
if |
y.hat.quants |
if |
y.rep.samples |
if |
y.rep.quants |
if |
s.indx |
if |
run.time |
MCMC sampler execution time reported using |
The return object will include additional objects used for subsequent prediction and/or model fit evaluation.
Note
Some of the underlying code used for generating random number from the Polya-Gamma distribution is taken from the pgdraw package written by Daniel F. Schmidt and Enes Makalic. Their code implements Algorithm 6 in PhD thesis of Jesse Bennett Windle (2013) https://repositories.lib.utexas.edu/handle/2152/21842.
Author(s)
Andrew O. Finley finleya@msu.edu,
Abhirup Datta abhidatta@jhu.edu,
Sudipto Banerjee sudipto@ucla.edu
References
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.
Examples
##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)