Giter VIP home page Giter VIP logo

glmproj's Introduction

glmproj

An R package to perform projection predictive variable selection for generalized linear models fitted with rstanarm.

The method is described and evaluated in comparison to many other methods in Piironen and Vehtari (2016).

Currently, the supported models (family objects in R) include Gaussian, Binomial and Poisson families. See the examples in the vignettes directory.

Installation

if (!require(devtools)) {
	install.packages("devtools")
	library(devtools)
}
devtools::install_github('paasim/glmproj', build_vignettes = TRUE)

Example

rm(list=ls())
library(glmproj)
library(rstanarm)
options(mc.cores = parallel::detectCores())
set.seed(1)

# Gaussian and Binomial examples from the glmnet-package
data('df_gaussian', package = 'glmproj')
#data('df_binom', package = 'glmproj')

# fit the full model with a sparsifying prior
fit <- stan_glm(y ~ x, family = gaussian(), data = df_gaussian,
                prior = hs(df = 1, global_scale=0.03), iter = 500, seed = 1)
#fit <- stan_glm(y ~ x, family = binomial(), data = df_binom
#                prior = hs(df = 1, global_scale=0.03), iter = 500, seed = 1)


# perform the variable selection
fit_v <- varsel(fit)

# print the results
varsel_statistics(fit_v)

# project the parameters for model sizes nv = 3,5 variables 
fit_p <- project(fit_v, nv = c(3, 5))
proj_coef(fit_p)

# perform cross-validation for the variable selection
fit_cv <- cv_varsel(fit, cv_method='LOO')

# plot the results
varsel_plot(fit_cv)

References

Dupuis, J. A. and Robert, C. P. (2003). Variable selection in qualitative models via an entropic explanatory power. Journal of Statistical Planning and Inference, 111(1-2):77–94.

Goutis, C. and Robert, C. P. (1998). Model choice in generalised linear models: a Bayesian approach via Kullback–Leibler projections. Biometrika, 85(1):29–37.

Juho Piironen and Aki Vehtari (2016). Comparison of Bayesian predictive methods for model selection. Statistics and Computing, (online).

glmproj's People

Contributors

avehtari avatar bgoodri avatar jgabry avatar jpiironen avatar paasim avatar

Watchers

 avatar  avatar

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.