Last data update: 2014.03.03

R: Drawing Shrinkage and Posterior Interval Plots
plot.gbpR Documentation

Drawing Shrinkage and Posterior Interval Plots

Description

plot(gbp.object) draws shrinkage and posterior interval plots

Usage

## S3 method for class 'gbp'
plot(x, sort = TRUE, ...)

Arguments

x

a resultant object of gbp function.

sort

TRUE or FALSE flag. If TRUE, the interval plot (second plot) will be drawn by the order of se for Gaussian, or of n for Binomial and Poisson data. If FALSE, it will be by the order of data input. Default is TRUE.

...

further arguments passed to other methods.

Details

As for the argument x, if the result of gbp is designated to b like "b <- gbp(z, n, model = "binomial")", the argument x is supposed to be b.

This function produces two plots containing information about the prior, sample, and posterior means.

The first plot is a shrinkage plot representing sample means (black circle) on the upper horizontal line and prior (blue line) and posterior means (red circle) on the lower horizontal line. The aim of this plot is to get a sense of the magnitude of the shrinkage and to observe if any change in ordering of the groups has occurred. Crossovers (changes of order) are noted by a black square as indicated in the legend. If the points plotted have the same value then a sunflower plot is produced where each petal (line protruding from the point) represent the count of points with that value. The plot also aims to incorporate the uncertainty and the lengths of the violet and green lines are proportional to the standard error and the posterior standard deviation respectively.

The final plot shows interval estimates of all the groups (units) in a dataset. Two short horizontal ticks at both ends of each black vertical line indicate 97.5% and 2.5% quantiles of a posterior distribution for each group (Normal for Gaussian, Beta for Binomial, and Gamma for Poisson). Red dots (posterior mean) are between black circles (sample mean) and blue line(s) (prior mean) as a result of shrinkage (regression toward the mean).

If we want to see the interval plot (the second plot) NOT sorted by the order of se for Gaussian, or of n for Binomial and Poisson data, plot(b, sort = FALSE) will show this plot by the order of data input.

Value

Two plots described in details will be displayed.

Author(s)

Hyungsuk Tak, Joseph Kelly, and Carl Morris

Examples


  data(hospital)

  z <- hospital$d
  n <- hospital$n
  y <- hospital$y
  se <- hospital$se
  
  
  ###################################################################################
  # We do not have any covariates and do not know a mean of the prior distribution. #
  ###################################################################################

    ###############################################################
    # Gaussian Regression Interactive Multilevel Modeling (GRIMM) #
    ###############################################################

    g <- gbp(y, se, model = "gaussian")
    plot(g)
    plot(g, sort = FALSE)

    ###############################################################
    # Binomial Regression Interactive Multilevel Modeling (BRIMM) #
    ###############################################################

    b <- gbp(z, n, model = "binomial")
    plot(b)
    plot(b, sort = FALSE)

    ##############################################################
    # Poisson Regression Interactive Multilevel Modeling (PRIMM) #
    ##############################################################

    p <- gbp(z, n, mean.PriorDist = 0.03, model = "poisson")
    plot(p)
    plot(p, sort = FALSE)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Rgbp)
Loading required package: sn
Loading required package: stats4

Attaching package: 'sn'

The following object is masked from 'package:stats':

    sd

Loading required package: mnormt
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Rgbp/plot.gbp.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot.gbp
> ### Title: Drawing Shrinkage and Posterior Interval Plots
> ### Aliases: plot.gbp
> ### Keywords: methods
> 
> ### ** Examples
> 
> 
>   data(hospital)
> 
>   z <- hospital$d
>   n <- hospital$n
>   y <- hospital$y
>   se <- hospital$se
>   
>   
>   ###################################################################################
>   # We do not have any covariates and do not know a mean of the prior distribution. #
>   ###################################################################################
> 
>     ###############################################################
>     # Gaussian Regression Interactive Multilevel Modeling (GRIMM) #
>     ###############################################################
> 
>     g <- gbp(y, se, model = "gaussian")
>     plot(g)
>     plot(g, sort = FALSE)
> 
>     ###############################################################
>     # Binomial Regression Interactive Multilevel Modeling (BRIMM) #
>     ###############################################################
> 
>     b <- gbp(z, n, model = "binomial")
>     plot(b)
>     plot(b, sort = FALSE)
> 
>     ##############################################################
>     # Poisson Regression Interactive Multilevel Modeling (PRIMM) #
>     ##############################################################
> 
>     p <- gbp(z, n, mean.PriorDist = 0.03, model = "poisson")
>     plot(p)
>     plot(p, sort = FALSE)
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>