Title: | Improved Shrinkage Estimations for Multiple Linear Regression |
---|---|
Description: | A variety of improved shrinkage estimators in the area of statistical analysis: unrestricted; restricted; preliminary test; improved preliminary test; Stein; and positive-rule Stein. More details can be found in chapter 7 of Saleh, A. K. Md. E. (2006) <ISBN: 978-0-471-56375-4>. |
Authors: | Mina Norouzirad [aut, cre], Danial Mazarei [aut], Ricardo Moura [aut] |
Maintainer: | Mina Norouzirad <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.0.9000 |
Built: | 2024-11-13 04:12:29 UTC |
Source: | https://github.com/mnrzrad/impshrinkage |
Heat evolved (cals/gm) in the setting of 13 samples of Portland cement with different percentage weight of chemical components.
A data.frame with 13 observations on the following 5 variables.
percentage weight in clinkers of 3CaO.Al2O3
percentage weight in clinkers of 3CaO.SiO2
percentage weight in clinkers of 4CaO.Al2O3.Fe2O3
percentage weight in clinkers of 2CaO.SiO2
heat evolved (calories/gram)
Woods, H., Steinour, H. H. and Starke, H. R. (1932) Effect of composition of Portland cement on heat evolved during hardening. Industrial Engineering and Chemistry, 24, 1207–1214.
data("cement") cement
data("cement") cement
Coefficients extracted from the model object improvedpreliminaryTest
## S3 method for class 'improvedpreliminaryTest' coefficients(object, ...) ## S3 method for class 'improvedpreliminaryTest' coef(object, ...)
## S3 method for class 'improvedpreliminaryTest' coefficients(object, ...) ## S3 method for class 'improvedpreliminaryTest' coef(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of coefficients.
coefficients.unrestricted
,
coefficients.restricted
,
coefficients.preliminaryTest
,
coefficients.stein
,
coefficients.positivestein
,
coef.unrestricted
,
coef.restricted
,
coef.positivestein
,
coef.stein
,
coef.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) coefficients(model) coef(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) coefficients(model) coef(model)
Coefficients extracted from the model object positivestein
## S3 method for class 'positivestein' coefficients(object, ...) ## S3 method for class 'positivestein' coef(object, ...)
## S3 method for class 'positivestein' coefficients(object, ...) ## S3 method for class 'positivestein' coef(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of coefficients.
coefficients.unrestricted
,
coefficients.restricted
,
coefficients.preliminaryTest
,
coefficients.improvedpreliminaryTest
,
coefficients.stein
,
coef.unrestricted
,
coef.restricted
,
coef.preliminaryTest
,
coef.improvedpreliminaryTest
,
coef.stein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) coefficients(model) coef(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) coefficients(model) coef(model)
Coefficients extracted from the model object preliminaryTest
## S3 method for class 'preliminaryTest' coefficients(object, ...) ## S3 method for class 'preliminaryTest' coef(object, ...)
## S3 method for class 'preliminaryTest' coefficients(object, ...) ## S3 method for class 'preliminaryTest' coef(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of coefficients.
coefficients.unrestricted
,
coefficients.restricted
,
coefficients.improvedpreliminaryTest
,
coefficients.stein
,
coefficients.positivestein
,
coef.unrestricted
,
coef.restricted
,
coef.improvedpreliminaryTest
.
coef.stein
,
coef.positivestein
.
#'
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) coefficients(model) coef(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) coefficients(model) coef(model)
Coefficients extracted from the model object restrcited
.
## S3 method for class 'restricted' coefficients(object, ...) ## S3 method for class 'restricted' coef(object, ...)
## S3 method for class 'restricted' coefficients(object, ...) ## S3 method for class 'restricted' coef(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of coefficients.
coefficients.unrestricted
,
coefficients.preliminaryTest
,
coefficients.improvedpreliminaryTest
,
coefficients.stein
,
coefficients.positivestein
,
coef.unrestricted
,
coef.preliminaryTest
,
coef.improvedpreliminaryTest
coef.stein
,
coef.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) coefficients(model) coef(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) coefficients(model) coef(model)
Coefficients extracted from the model object stein
## S3 method for class 'stein' coefficients(object, ...) ## S3 method for class 'stein' coef(object, ...)
## S3 method for class 'stein' coefficients(object, ...) ## S3 method for class 'stein' coef(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of coefficients.
coefficients.unrestricted
,
coefficients.restricted
,
coefficients.preliminaryTest
,
coefficients.improvedpreliminaryTest
,
coefficients.positivestein
,
coef.unrestricted
,
coef.restricted
,
coef.preliminaryTest
,
coef.improvedpreliminaryTest
,
coef.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) coefficients(model) coef(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) coefficients(model) coef(model)
Coefficients extracted from the model object unrestricted
.
## S3 method for class 'unrestricted' coefficients(object, ...) ## S3 method for class 'unrestricted' coef(object, ...)
## S3 method for class 'unrestricted' coefficients(object, ...) ## S3 method for class 'unrestricted' coef(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of coefficients.
coefficients.restricted
,
coefficients.preliminaryTest
,
coefficients.improvedpreliminaryTest
,
coefficients.stein
,
coefficients.positivestein
,
coef.restricted
,
coef.preliminaryTest
,
coef.improvedpreliminaryTest
coef.stein
,
coef.positivestein
.
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 model <- unrReg(X, y) coefficients(model) coef(model)
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 model <- unrReg(X, y) coefficients(model) coef(model)
Fitted values based on object improvedpreliminaryTest
.
## S3 method for class 'improvedpreliminaryTest' fitted(object, ...)
## S3 method for class 'improvedpreliminaryTest' fitted(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of fitted values.
fitted.unrestricted
,
fitted.restricted
,
fitted.preliminaryTest
,
fitted.stein
,
fitted.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) fitted(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) fitted(model)
Fitted values based on object positivestein
.
## S3 method for class 'positivestein' fitted(object, ...)
## S3 method for class 'positivestein' fitted(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of fitted values.
fitted.unrestricted
,
fitted.restricted
,
fitted.preliminaryTest
,
fitted.improvedpreliminaryTest
,
fitted.stein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) fitted(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) fitted(model)
Fitted values based on object preliminaryTest
.
## S3 method for class 'preliminaryTest' fitted(object, ...)
## S3 method for class 'preliminaryTest' fitted(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of fitted values.
fitted.unrestricted
,
fitted.restricted
,
fitted.improvedpreliminaryTest
,
fitted.stein
,
fitted.positivestein
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) fitted(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) fitted(model)
Fitted values based on object restrcited
.
## S3 method for class 'restricted' fitted(object, ...)
## S3 method for class 'restricted' fitted(object, ...)
object |
An object of class |
... |
Other arguments. |
Fitted values extracted from the object restricted
.
fitted.unrestricted
,
fitted.preliminaryTest
,
fitted.improvedpreliminaryTest
,
fitted.stein
,
fitted.positivestein
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) fitted(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) fitted(model)
Fitted values based on object stein
.
## S3 method for class 'stein' fitted(object, ...)
## S3 method for class 'stein' fitted(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of fitted values.
fitted.unrestricted
,
fitted.restricted
,
fitted.preliminaryTest
,
fitted.improvedpreliminaryTest
,
fitted.positivestein
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) fitted(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) fitted(model)
Fitted values based on object unrestricted
.
## S3 method for class 'unrestricted' fitted(object, ...)
## S3 method for class 'unrestricted' fitted(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of fitted values.
fitted.restricted
,
fitted.preliminaryTest
,
fitted.improvedpreliminaryTest
,
fitted.stein
,
fitted.positivestein
.
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 model <- unrReg(X, y) fitted(model)
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 model <- unrReg(X, y) fitted(model)
This function calculates the improved preliminary test estimator. When the error has a normal distribution, this estimator can be calculated by
and, when the error has a non-normal distribution, by
where denotes an indicator function and
is the preliminary test estimator; See
ptReg
is the unrestricted estimator; See
unrReg
.
is the restricted estimator; See
resReg
.
is the test statistic. See
teststat
;
is the upper
level critical value of
-distribution with
degrees of freedom, calculated using
qf
;
is the upper
level critical value of
-distribution with
degree of freedom, calculated using
qchisq
;
is the shrinkage factor;
is the significance level.
iptReg(X, y, H, h, alpha, d = NULL, is_error_normal = FALSE)
iptReg(X, y, H, h, alpha, d = NULL, is_error_normal = FALSE)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
H |
A given |
h |
A given |
alpha |
A given significance level. |
d |
(optional) If not provided (or set to |
is_error_normal |
logical value indicating whether the errors follow a
normal distribution. If |
The corresponding estimator of is
An object of class improvedpreliminaryTest
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.
Kaciranlar, S., Akdeniz, S. S. F., Styan, G. P. & Werner, H. J. (1999). A new biased estimators in linear regression and detailed analysis of the widely-analysed dataset on portland cement. Sankhya, Series B, 61(3), 443-459.
Kibria, B. M. Golam (2005). Applications of Some Improved Estimators in Linear Regression, Journal of Modern Applied Statistical Methods, 5(2), 367- 380.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) iptReg(X, y, H, h, alpha = 0.05) # H beta != h p <- ncol(X) H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) iptReg(X, y, H, h, alpha = 0.05) 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)) iptReg(X, y, H, h, alpha = 0.05) # Based on Kibria (2005) 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)) iptReg(X, y, H, h, alpha = 0.05)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) iptReg(X, y, H, h, alpha = 0.05) # H beta != h p <- ncol(X) H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) iptReg(X, y, H, h, alpha = 0.05) 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)) iptReg(X, y, H, h, alpha = 0.05) # Based on Kibria (2005) 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)) iptReg(X, y, H, h, alpha = 0.05)
Predicted values based on object improvedpreliminaryTest
.
## S3 method for class 'improvedpreliminaryTest' predict(object, newdata, ...)
## S3 method for class 'improvedpreliminaryTest' predict(object, newdata, ...)
object |
An object of class " |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Other arguments. |
A vector of predictions.
predict.unrestricted
,
predict.restricted
,
predict.preliminaryTest
,
predict.stein
,
predict.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) predict(model, X)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) predict(model, X)
Predicted values based on object positivestein
.
## S3 method for class 'positivestein' predict(object, newdata, ...)
## S3 method for class 'positivestein' predict(object, newdata, ...)
object |
An object of class " |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Other arguments. |
A vector of predictions.
predict.unrestricted
,
predict.restricted
,
predict.preliminaryTest
,
predict.improvedpreliminaryTest
,
predict.stein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) predict(model, X)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) predict(model, X)
Predicted values based on object preliminaryTest
.
## S3 method for class 'preliminaryTest' predict(object, newdata, ...)
## S3 method for class 'preliminaryTest' predict(object, newdata, ...)
object |
An object of class " |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Other arguments. |
A vector of predictions.
predict.unrestricted
,
predict.restricted
,
predict.improvedpreliminaryTest
,
predict.stein
,
predict.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) predict(model, X)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) predict(model, X)
Predicted values based on object restrcited
.
## S3 method for class 'restricted' predict(object, newdata, ...)
## S3 method for class 'restricted' predict(object, newdata, ...)
object |
An object of class |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Other arguments. |
A vector of predictions.
predict.unrestricted
,
predict.preliminaryTest
,
predict.improvedpreliminaryTest
,
predict.stein
,
predict.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) predict(model, X)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) predict(model, X)
Predicted values based on object stein
.
## S3 method for class 'stein' predict(object, newdata, ...)
## S3 method for class 'stein' predict(object, newdata, ...)
object |
An object of class " |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Other arguments. |
A vector of predictions.
predict.unrestricted
,
predict.restricted
,
predict.preliminaryTest
,
predict.improvedpreliminaryTest
,
predict.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) predict(model, X)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) predict(model, X)
Predicted values based on object unrestricted
.
## S3 method for class 'unrestricted' predict(object, newdata, ...)
## S3 method for class 'unrestricted' predict(object, newdata, ...)
object |
An object of class |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Other arguments. |
A vector of predictions.
predict.restricted
,
predict.preliminaryTest
,
predict.improvedpreliminaryTest
,
predict.stein
,
predict.positivestein
.
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 model <- unrReg(X, y) predict(model, X)
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 model <- unrReg(X, y) predict(model, X)
This function calculates the positive-rule Stein estimator. This estimator is an improved version of the Stein estimator, where only the positive part of the shrinking factor is considered. It may be calculated by
where denotes an indicator function and
is the Stein estimator; See
stReg
.
is the unrestricted estimator; See
unrReg
.
is the restricted estimator; See
resReg
.
is the test statistic. See
teststat
;
is the shrinkage factor.
prstReg(X, y, H, h, d = NULL, is_error_normal = FALSE)
prstReg(X, y, H, h, d = NULL, is_error_normal = FALSE)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
H |
A given |
h |
A given |
d |
(optional) If not provided (or set to |
is_error_normal |
logical value indicating whether the errors follow a
normal distribution. If |
The corresponding estimator of is given by
An object of class pst
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.
Kaciranlar, S., Akdeniz, S. S. F., Styan, G. P. & Werner, H. J. (1999). A new biased estimators in linear regression and detailed analysis of the widely-analysed dataset on portland cement. Sankhya, Series B, 61(3), 443-459.
Kibria, B. M. Golam (2005). Applications of Some Improved Estimators in Linear Regression, Journal of Modern Applied Statistical Methods, 5(2), 367- 380.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) prstReg(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(1, nrow(H)) prstReg(X, y, H, h) 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)) prstReg(X, y, H, h) # Based on Kibria (2005) 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)) prstReg(X, y, H, h)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) prstReg(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(1, nrow(H)) prstReg(X, y, H, h) 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)) prstReg(X, y, H, h) # Based on Kibria (2005) 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)) prstReg(X, y, H, h)
This function calculates the preliminary test. When the error has a normal distribution, the test statistic is given by
and, if the error has a non-normal distribution, is given by
where denotes an indicator function and
is the unrestricted estimator; See
unrReg
.
is the restricted estimator; See
resReg
.
is the test statistic. See
teststat
;
is the upper
level critical value of
-distribution with
degrees of freedom, calculated using
qf
;
is the upper
level critical value of
-distribution with
degree of freedom, calculated using
qchisq
;
: the significance level.
ptReg(X, y, H, h, alpha, is_error_normal = FALSE)
ptReg(X, y, H, h, alpha, is_error_normal = FALSE)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
H |
A given |
h |
A given |
alpha |
A given significance level. |
is_error_normal |
logical value indicating whether the errors follow
a normal distribution. If |
The corresponding estimator of is
An object of class preliminaryTest
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.
Kaciranlar, S., Akdeniz, S. S. F., Styan, G. P. & Werner, H. J. (1999). A new biased estimators in linear regression and detailed analysis of the widely-analysed dataset on portland cement. Sankhya, Series B, 61(3), 443-459.
Kibria, B. M. Golam (2005). Applications of Some Improved Estimators in Linear Regression, Journal of Modern Applied Statistical Methods, 5(2), 367- 380.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) ptReg(X, y, H, h, alpha = 0.05) # H beta != h p <- ncol(X) H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) ptReg(X, y, H, h, alpha = 0.05) 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)) ptReg(X, y, H, h, alpha = 0.05) # Based on Kibria (2005) 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)) ptReg(X, y, H, h, alpha = 0.05)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) ptReg(X, y, H, h, alpha = 0.05) # H beta != h p <- ncol(X) H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) ptReg(X, y, H, h, alpha = 0.05) 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)) ptReg(X, y, H, h, alpha = 0.05) # Based on Kibria (2005) 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)) ptReg(X, y, H, h, alpha = 0.05)
Residuals values based on model object improvedpreliminaryTest
.
## S3 method for class 'improvedpreliminaryTest' residuals(object, ...)
## S3 method for class 'improvedpreliminaryTest' residuals(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of residuals.
residuals.unrestricted
,
residuals.restricted
,
residuals.preliminaryTest
,
residuals.stein
,
residuals.positivestein
,
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) residuals(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- iptReg(X, y, H, h, alpha = 0.05) residuals(model)
Residuals values based on model object positivestein
.
## S3 method for class 'positivestein' residuals(object, ...)
## S3 method for class 'positivestein' residuals(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of residuals.
residuals.unrestricted
,
residuals.restricted
,
residuals.preliminaryTest
,
residuals.improvedpreliminaryTest
,
residuals.stein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) residuals(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- prstReg(X, y, H, h) residuals(model)
Residuals values based on model object preliminaryTest
.
## S3 method for class 'preliminaryTest' residuals(object, ...)
## S3 method for class 'preliminaryTest' residuals(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of residuals.
residuals.unrestricted
,
residuals.restricted
,
residuals.improvedpreliminaryTest
,
residuals.stein
,
residuals.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) residuals(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- ptReg(X, y, H, h, alpha = 0.05) residuals(model)
Residuals values based on model object restricted
.
## S3 method for class 'restricted' residuals(object, ...)
## S3 method for class 'restricted' residuals(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of residuals.
residuals.unrestricted
,
residuals.preliminaryTest
,
residuals.improvedpreliminaryTest
,
residuals.stein
,
residuals.positivestein
.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) residuals(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- resReg(X, y, H, h) residuals(model)
Residuals values based on model object stein
.
## S3 method for class 'stein' residuals(object, ...)
## S3 method for class 'stein' residuals(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of residuals.
residuals.unrestricted
,
residuals.restricted
,
residuals.preliminaryTest
,
residuals.improvedpreliminaryTest
,
residuals.positivestein
,.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) residuals(model)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nr = 3, nc = p, byrow = TRUE) h <- rep(0, nrow(H)) model <- stReg(X, y, H, h) residuals(model)
Residuals values based on model object unrestricted
.
## S3 method for class 'unrestricted' residuals(object, ...)
## S3 method for class 'unrestricted' residuals(object, ...)
object |
An object of class |
... |
Other arguments. |
A vector of residuals.
residuals.restricted
,
residuals.preliminaryTest
,
residuals.improvedpreliminaryTest
residuals.stein
,
residuals.positivestein
.
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 model <- unrReg(X, y) residuals(model)
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 model <- unrReg(X, y) residuals(model)
This function calculates the restricted estimator using
where
is the unrestricted estimator; See
unrReg
.
represents a subspace of the parameter space induced
by the non-sample information. Here,
is a known
matrix, and
is a known
-vector.
resReg(X, y, H, h)
resReg(X, y, H, h)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
H |
A given |
h |
A given |
#' The corresponding estimator of is
An object of class restricted
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.
Kaciranlar, S., Akdeniz, S. S. F., Styan, G. P. & Werner, H. J. (1999). A new biased estimators in linear regression and detailed analysis of the widely-analysed dataset on portland cement. Sankhya, Series B, 61(3), 443-459.
Kibria, B. M. Golam (2005). Applications of Some Improved Estimators in Linear Regression, Journal of Modern Applied Statistical Methods, 5(2), 367- 380.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) resReg(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) resReg(X, y, H, h) 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)) resReg(X, y, H, h) # Based on Kibria (2005) 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)) resReg(X, y, H, h)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) resReg(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) resReg(X, y, H, h) 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)) resReg(X, y, H, h) # Based on Kibria (2005) 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)) resReg(X, y, H, h)
This function generates a toy example. The error term, ,
and the design matrix,
, are simulated from standard normal
distributions,
, using the
rnorm
function. Given the true parameter vector, , the response vector,
, is calculated as
simdata(n, p, beta, seed = NULL)
simdata(n, p, beta, seed = NULL)
n |
Number of observations. |
p |
Number of variables. |
beta |
Regression parameter. |
seed |
(Optional) The random seed for reproducibility. Default is |
A list containing the following components:
a matrix of dimensions n x p
.
a numeric vector of length n
.
Saleh, A. K. Md. Ehsanes. (2006). Theory of Preliminary Test and Stein‐Type Estimation With Applications, Wiley.
simulated_data <- simdata(n = 100, p = 5, beta = c(2, 1, 3, 0, 5)) X <- simulated_data$X y <- simulated_data$y X y
simulated_data <- simdata(n = 100, p = 5, beta = c(2, 1, 3, 0, 5)) X <- simulated_data$X y <- simulated_data$y X y
This function can be used to calculate the Stein estimator using
where
is the unrestricted estimator; See
unrReg
.
is the restricted estimator; See
resReg
.
is the test statistic. See
teststat
;
is the shrinkage factor.
stReg(X, y, H, h, d = NULL, is_error_normal = FALSE)
stReg(X, y, H, h, d = NULL, is_error_normal = FALSE)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
H |
A given |
h |
A given |
d |
(Optional) If not provided (or set to |
is_error_normal |
logical value indicating whether the errors follow a
normal distribution. If |
The corresponding estimator of is
An object of class stein
is a list containing at least the following components:
coef
A vector of coefficients.
residuals
The residuals, that is, the response values minus the 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.
Kaciranlar, S., Akdeniz, S. S. F., Styan, G. P. & Werner, H. J. (1999). A new biased estimators in linear regression and detailed analysis of the widely-analysed dataset on portland cement. Sankhya, Series B, 61(3), 443-459.
Kibria, B. M. Golam (2005). Applications of Some Improved Estimators in Linear Regression, Journal of Modern Applied Statistical Methods, 5(2), 367- 380.
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) stReg(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) stReg(X, y, H, h) 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)) stReg(X, y, H, h) # Based on Kibria (2005) 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)) stReg(X, y, H, h)
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 p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) stReg(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) stReg(X, y, H, h) 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)) stReg(X, y, H, h) # Based on Kibria (2005) 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)) stReg(X, y, H, h)
This function calculates the test statistics, assuming
. When the error has a normal distribution,
it is defined as
and when the error has a non-normal distribution, as
where
is the unrestricted estimator; See
unrReg
.
is the number of restrictions, i.e., the number of rows of known matrix
;
is the corresponding unrestricted estimator of
.
teststat(X, y, H, h, is_error_normal = FALSE)
teststat(X, y, H, h, is_error_normal = FALSE)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
H |
A given |
h |
A given |
is_error_normal |
logical value indicating whether the errors follow a
normal distribution. If |
The value of the test statistic.
Saleh, A. K. Md. Ehsanes. (2006). Theory of Preliminary Test and Stein‐Type Estimation With Applications, Wiley.
Kaciranlar, S., Akdeniz, S. S. F., Styan, G. P. & Werner, H. J. (1999). A new biased estimators in linear regression and detailed analysis of the widely-analysed dataset on portland cement. Sankhya, Series B, 61(3), 443-459.
Kibria, B. M. Golam (2005). Applications of Some Improved Estimators in Linear Regression, Journal of Modern Applied Statistical Methods, 5(2), 367- 380.
n_obs <- 100 p_vars <- 5 beta <- c(2, 1, 3, 0, 5) simulated_data <- simdata(n = n_obs, p_vars, beta) X <- simulated_data$X y <- simulated_data$y p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) teststat(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) teststat(X, y, H, h) 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)) teststat(X, y, H, h) # Based on Kibria (2005) 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)) teststat(X, y, H, h)
n_obs <- 100 p_vars <- 5 beta <- c(2, 1, 3, 0, 5) simulated_data <- simdata(n = n_obs, p_vars, beta) X <- simulated_data$X y <- simulated_data$y p <- ncol(X) # H beta = h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(0, nrow(H)) teststat(X, y, H, h) # H beta != h H <- matrix(c(1, 1, -1, 0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1, 0), nrow = 3, ncol = p, byrow = TRUE) h <- rep(1, nrow(H)) teststat(X, y, H, h) 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)) teststat(X, y, H, h) # Based on Kibria (2005) 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)) teststat(X, y, H, h)
This function calculates the unrestricted estimator as
where denotes the transpose of a matrix. It is important to note that the
input matrices
and
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)
unrReg(X, y)
X |
Matrix with input observations, of dimension |
y |
Vector with response observations of size |
The corresponding unrestricted estimator of is
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)
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)