Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sufstat

Sufficient Statistics


Description

Sufficient statistics for various models.

Usage

RegressionSuf(X = NULL,
                y = NULL,
                xtx = crossprod(X),
                xty = crossprod(X, y),
                yty = sum(y^2),
                n = length(y),
                xbar = colMeans(X))

  GaussianSuf(y)

Arguments

X

The predictor matrix for a regression problem.

y

The data, or the regression response variable.

xtx

The cross product of the design matrix. "X transpose X."

xty

The cross product of the design matrix with the response vector. "X transpose y."

yty

The sum of the squares of the response vector. "y transpose y."

n

The sample size.

xbar

A vector giving the average of each column in the predictor matrix.

Value

The returned value is a function containing the sufficient statistics for a regression model. Arguments are checked to ensure they have legal values. List names match the names expected by underlying C++ code.

Author(s)

Examples

X <- cbind(1, matrix(rnorm(3 * 100), ncol = 3))
  y <- rnorm(100)

  ## Sufficient statistics can be computed from raw data, if it is
  ## available.
  suf1 <- RegressionSuf(X, y)

  ## The individual components can also be computed elsewhere, and
  ## provided as arguments.  If n is very large, this can be a
  ## substantial coomputational savings.
  suf2 <- RegressionSuf(xtx = crossprod(X),
                        xty = crossprod(X, y),
                        yty = sum(y^2),
                        n = 100,
                        xbar = colMeans(X))

Boom

Bayesian Object Oriented Modeling

v0.9.7
LGPL-2.1 | file LICENSE
Authors
Steven L. Scott is the sole author and creator of the BOOM project. Some code in the BOOM libraries has been modified from other open source projects. These include Cephes (obtained from Netlib, written by Stephen L. Moshier), NEWUOA (M.J.D Powell, obtained from Powell's web site), and a modified version of the R math libraries (R core development team). Original copyright notices have been maintained in all source files. In these cases, copyright claimed by Steven L. Scott is limited to modifications made to the original code. Google claims copyright for code written while Steven L. Scott was employed at Google from 2008 - 2018, but BOOM is not an officially supported Google project.
Initial release
2021-02-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.