Learn R Programming

BMA (version 3.12)

glib: Model uncertainty in generalized linear models using Bayes factors

Description

Function to evaluate Bayes factors and account for model uncertainty in generalized linear models.

Usage

glib(x, y, n = rep(1, nrow(x)), error = "poisson", link = "log", 
     scale = 1, models = NULL,  phi = c(1, 1.65, 5), psi = 1, nu = 0, 
     pmw = rep(1, nrow(models)), glimest = TRUE, glimvar = FALSE, 
     output.priorvar = FALSE, post.bymodel = TRUE, output.postvar = FALSE, 
     priormean = NULL, priorvar = NULL, nbest = 10, call = NULL, ...)

glib(g, scale = 1, phi = c(1, 1.65, 5), psi = 1, nu = 0, 
     glimest = TRUE, glimvar = FALSE, output.priorvar = F, 
     post.bymodel = TRUE, output.postvar = FALSE, priormean = NULL, 
     priorvar = NULL, call = NULL, ...)

as.bic.glm( g, phi.index=1)

Arguments

Value

  • glib returns an object of type glib, which is a list containing the following items:
  • inputsa list echoing the inputs (x,y,n,error,link,models,phi,psi,nu)
  • bfa list containing the model comparison results: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

synopsis

glib(x, ...)

item

  • posterior
  • glim.est
  • posterior.bymodel
  • prior
  • models
  • glm.out
  • call

describe

  • meanprior mean for the biggest model (this doesn't depend on phi)
  • varsimilar to corresponding member of posterior.bymodel.

code

bic.glm

Details

Function to evaluate Bayes factors and account for model uncertainty in generalized linear models. This also calculates posterior distributions from a set of reference proper priors. as.bic.glm creates a 'bic.glm' object from a 'glib' object.

References

Raftery, A.E. (1988). Approximate Bayes factors for generalized linear models. Technical Report no. 121, Department of Statistics, University of Washington. Raftery, Adrian E. (1995). Bayesian model selection in social research (with Discussion). Sociological Methodology 1995 (Peter V. Marsden, ed.), pp. 111-196, Cambridge, Mass.: Blackwells. An earlier version of this was issued as Working Paper 94-12, Center for Studies in Demography and Ecology, University of Washington, and this is available as a Postscript file at http://www.stat.washington.edu/tech.reports/bic.ps. Raftery, A.E. (1996). Approximate Bayes factors and accounting for model uncertainty in generalized linear models. Biometrika (83: 251-266). An earlier version of this was issued as Technical Report no. 255, Department of Statistics, University of Washington, and is available as a Postscript file at http://www.stat.washington.edu/tech.reports/tr255.ps.

See Also

bic.glm, summary.glib

Examples

Run this code
### Finney data
library(forward)
data(vaso)
x<- vaso[,1:2]
y<- vaso[,3]
n<- rep(1,times=length(y))

finney.models<- rbind(
    c(1, 0),
    c(0, 1),
    c(1, 1))

finney.glib <- glib (x,y,n, error="binomial", link="logit", models=finney.models, 
   glimvar=TRUE, output.priorvar=TRUE, output.postvar=TRUE)
summary(finney.glib)

finney.bic.glm<- as.bic.glm(finney.glib)
plot(finney.bic.glm,mfrow=c(2,1))

### Yates (teeth) data. 

x<- rbind(
    c(0, 0, 0),
    c(0, 1, 0),
    c(1, 0, 0),
    c(1, 1, 1))

y<-c(4, 16, 1, 21)
n<-c(1,1,1,1)

models<- rbind(
    c(1, 1, 0),
    c(1, 1, 1))

glib.yates <- glib (x,y,n,models=models,glimvar=TRUE,output.priorvar=TRUE,
   output.postvar=TRUE) 
summary(glib.yates)

### logistic regression with no models specified
library("MASS")
data(birthwt)
y<- birthwt$lo
x<- data.frame(birthwt[,-1])
x$race<- as.factor(x$race)
x$ht<- (x$ht>=1)+0
x<- x[,-9]
x$smoke <- as.factor(x$smoke)
x$ptl<- as.factor(x$ptl)
x$ht <- as.factor(x$ht)
x$ui <- as.factor(x$ui)

glib.birthwt<- glib(x,y, error="binomial", link = "logit")
summary(glib.birthwt)

glm.birthwt<- as.bic.glm(glib.birthwt)

imageplot.bma(glm.birthwt)

plot(glm.birthwt)

Run the code above in your browser using DataLab