unrReg {ImpShrinkage} | R Documentation |
This function calculates the unrestricted estimator as
\hat{\beta}^{U} = (X^{\top} X)^{-1} X^{\top} y
where ^{\top}
denotes the transpose of a matrix. It is important to note that the
input matrices X
and y
should be standardized, for example, by
using scale
. Alternatively, the user can employ
lm
to obtain this estimator, but it is crucial to
remember to set intercept = FALSE
.
unrReg(X, y)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
The corresponding unrestricted estimator of \sigma^2
is
s^2 = \frac{1}{n-p}(y-X\hat{\beta}^{U})^{\top}(y - X\hat{\beta}^{U}).
An object of class unrestricted
is a list containing at least the following components:
coef
A named vector of coefficients.
residuals
The residuals, that is, the response values minus fitted values.
s2
The estimated variance.
fitted.values
The fitted values.
Saleh, A. K. Md. Ehsanes. (2006). Theory of Preliminary Test and Stein‐Type Estimation With Applications, Wiley.
data(cement)
n_obs <- 100
p_vars <- 5
beta <- c(2, 1, 3, 0, 5)
simulated_data <- simdata(n = n_obs, p = p_vars, beta)
X <- simulated_data$X
y <- simulated_data$y
unrReg(X, y)
data(cement)
X <- as.matrix(cbind(1, cement[, 1:4]))
y <- cement$y
# Based on Kaciranlar et al. (1999)
H <- matrix(c(0, 1, -1, 1, 0), nrow = 1, ncol = 5, byrow = TRUE)
h <- rep(0, nrow(H))
unrReg(X, y)
H <- matrix(c(0, 1, -1, 1, 0, 0, 0, 1, -1, -1, 0, 1, -1, 0, -1), nrow = 3, ncol = 5, byrow = TRUE)
h <- rep(0, nrow(H))
unrReg(X, y)