Code Monkey home page Code Monkey logo

sbic's Introduction

sBIC Package

Purpose

This package allows you to compute the singilar Bayesian information criterion as described in Drton and Plummer (2017) for collections of the following model types:

  1. Binomial mixtures
  2. Gaussian mixtures
  3. Latent class analysis
  4. Gaussian latent forests
  5. Reduced rank regression
  6. Factor analysis

All of these models, excluding Gaussian latent forests, are described in the above paper. For details regardings the use of the sBIC with Gaussian latent forests see Drton et al (2014).

Object oriented approach

This package makes extensive use of the R.oo package (Bengtsson 2003) which allows for the use of some object oriented principles in R. While not strictly necessary to use this package it may be helpful to read sections 1 and 2 of Bengstsson (2003) which serve as an introduction to R.oo.

An important consequence of the use of R.oo is that objects in the sBIC package use call by reference semantics and are modified by calling their associated methods.

Example

Each collection of models is defined as its own class. As an example for how to use the package we will compute the sBIC for a collection of Gaussian mixture models with at most 8 components:

set.seed(123)

Create an object representing a collection of Gaussian mixture models with at most 8 components in 2 dimensions.

library(sBIC)
gms = GaussianMixtures(maxNumComponents = 8, dim = 2, restarts = 100)

Generate some simulated data, a mixture of 3 bivariate normals.

library(MASS)
n = 175
class = sample(0:2, n, replace = TRUE)
X = (class == 0) * mvrnorm(n, mu = c(0, 0), Sigma = diag(2)) +
    (class == 1) * mvrnorm(n, mu = c(2.5, 2.5), Sigma = diag(1.3, 2)) +
    (class == 2) * mvrnorm(n, mu = c(-3, 2.5), Sigma = diag(1.2, 2))

Compute the sBIC on the mixture models with the randomly generated data.

sBIC(X, gms)

Notice that the BIC too strongly penalizes the (true) model with 3 components.

References

  • Bengtsson, H. (2003)The R.oo package - Object-Oriented Programming with References Using Standard R Code, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), ISSN 1609-395X, Hornik, K.; Leisch, F. & Zeileis, A. (eds.) URL https://www.r-project.org/conferences/DSC-2003/Proceedings/Bengtsson.pdf
  • Drton M, Lin S, Weihs L and Zwiernik P. (2014) Marginal likelihood and model selection for Gaussian latent tree and forest models. arXiv preprint arXiv:1412.8285.
  • Drton M. and Plummer M. (2017), A Bayesian information criterion for singular models. J. R. Statist. Soc. B; 79: 1-38. Also available as arXiv preprint arXiv:1309.0911

sbic's People

Contributors

lucaweihs avatar martynplummer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sbic's Issues

throw() is moving from R.methodsS3 to R.oo

Hi, throw() in R.methodsS3 is deprecated and will soon be removed. Please update your code to use throw() in the R.oo package instead. It'll work the same. The fix is to update:

sBIC/R/sbic.R

Lines 16 to 17 in d793c46

#' @importFrom R.oo Object setConstructorS3 extend
#' @importFrom R.methodsS3 setMethodS3 throw

to

 #' @importFrom R.oo Object setConstructorS3 extend throw
 #' @importFrom R.methodsS3 setMethodS3 

and re-roxygenize.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.