Learn R Programming

⚠️There's a newer version (0.7.4) of this package.Take me there.

R/iprior: An R package for I-prior regression

Based on the manuscript entitled "Regression with I-priors" by Wicher Bergsma [2017, unpublished]. In a linear regression setting, priors can be assigned to the regression function using a vector space framework, and the posterior estimate of the regression function obtained. An I-prior is defined as Gaussian with some prior mean (usually zero) and covariance kernel equal to the Fisher information for the regression function.

This package performs linear regression modelling using I-priors in R. It is intuitively designed to be similar to lm, with both formula and non-formula based input. The parameters of an I-prior model are the scale parameters of the reproducing kernel Hilbert space (RKHS) over the set of covariates, lambda, and the standard deviation of model errors, sigma. While the main interest of I-prior modelling is prediction, inference is also possible, e.g. via log-likelihood ratio tests.

For installation instructions and some examples of I-prior modelling, continue reading below. The package is documented with help files, and the wiki is a good source to view some discussion topics and further examples.

Installation

Install R/iprior either by downloading the latest CRAN release

install.packages("iprior")
library(iprior)

or the developmental version from this GitHub repository. R/iprior makes use of several C++ code, so as a prerequisite, you must have a working C++ compiler. To get it:

  • On Windows, install Rtools.
  • On Mac, install Xcode from the app store.
  • On Linux, sudo apt-get install r-base-dev or similar.

The easiest way to then install from this repo is by using the devtools package. Install this first.

install.packages("devtools")

Then, run the following code to install and attach the iprior package.

devtools::install_github("haziqjamil/iprior", build_vignettes = TRUE)
library(iprior)

Note: The option build_vignettes = TRUE builds the package vignettes for viewing, but takes slightly longer. Set build_vignettes = FALSE, or remove this option entirely, to skip building the vignettes.

Syntax

To fit an I-prior model to mod regressing y against x, where these are contained in the data frame dat, the following syntax are equivalent.

mod <- iprior(y ~ x, data = dat)  # formula based input
mod <- iprior(y = dat$y, x = dat$x)  # non-formula based input

The call to iprior() can be accompanied by model options in the form of model = list(), such as choosing the RKHS, number of scale parameters, and others. Control options for the EM algorithm fit is done through the option control = list(). Find the full list of options by typing ?iprior in R.

Resources

View the package vignettes by typing browseVignettes("iprior") in R. Also, visit the the wiki page for some usage examples and other topics of discussions.

Copy Link

Version

Install

install.packages('iprior')

Monthly Downloads

206

Version

0.6.5

License

GPL (>= 3.0)

Issues

Pull Requests

Stars

Forks

Maintainer

Haziq Jamil

Last Published

June 12th, 2017

Functions in iprior (0.6.5)

eigenCpp

Eigen decomposition of a matrix in C++.
fastSquare

Multiplying a symmetric matrix by itself in C++.
hsb

High school and beyond dataset
hsbsmall

High school and beyond dataset
pollution

Air pollution and mortality
predict

Predict for I-prior models.
iprior

Fit an I-prior regression model
ipriorColPal

Colour palette for iprior plots
progress

EM algorithm progression results for fitted ipriorMod objects
sigma

Obtain the standard deviation of the residuals 'sigma'
simdat

Random slopes model simulated data
slope

Recover the betas (slopes) of the regression curves
fastVDiag

Computing a quadratic matrix form in C++.
fbmOptim

Find the Hurst coefficient of a FBM I-prior model
ipriorOptim

Estimate an I-prior model using a combination of EM algorithm and direct optimisation
is.ipriorMod

Test for iprior objects
vary

Extract the variance of the responses
Hlam

Extract the scaled kernel matrix
datfbm

Simulated data to illustrate one-dimensional smoothing
logLik

Obtain the log-likelihood and deviance of an ipriorMod or ipriorKernel object
plot

Plots for ipriorMod objects
kernL

Load the kernel matrices of an I-prior model
kernel

Reproducing kernels for the I-prior package