sufstat.Rd | R Documentation |
Sufficient statistics for various models.
RegressionSuf(X = NULL,
y = NULL,
xtx = crossprod(X),
xty = crossprod(X, y),
yty = sum(y^2),
n = length(y),
xbar = colMeans(X),
ybar = mean(y))
GaussianSuf(y)
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. |
ybar |
The (scalar) mean of the response variable y. |
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.
Steven L. Scott steve.the.bayesian@gmail.com
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.