Skip to contents

Estimate R-Squared and Adjusted R-Squared and the Corresponding Sampling Covariance Matrix

Usage

RSqSandwich(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class betasandwich, that is, the output of the BetaHC(), BetaN(), or BetaADF() functions.

alpha

Numeric vector. Significance level \(\alpha\).

Value

Returns an object of class essandwich which is a list with the following elements:

call

Function call.

fit

The argument object.

args

Function arguments.

vcov

Sampling covariance matrix of R-squared and adjusted R-squared.

est

Vector of R-squared and adjusted R-squared.

fun

Function used ("RSqSandwich").

Details

The sampling covariance matrix is obtained by the delta method from the sampling covariance matrix of the standardized parameters stored in object (normal-theory, asymptotically distribution-free, or heteroskedasticity-consistent).

Let \(\boldsymbol{\beta}^{\ast}\) be the vector of standardized slopes, \(\boldsymbol{R}_{x}\) the correlation matrix of the regressors, \(r^{jj}\) the \(j\)th diagonal element of \(\boldsymbol{R}_{x}^{-1}\), and \(R^{2} = \boldsymbol{\beta}^{\ast\prime} \boldsymbol{R}_{x} \boldsymbol{\beta}^{\ast}\). The R-squared and the adjusted R-squared are $$R^{2} = \boldsymbol{\beta}^{\ast\prime} \boldsymbol{R}_{x} \boldsymbol{\beta}^{\ast}, \quad \bar{R}^{2} = 1 - \left( 1 - R^{2} \right) \frac{n - 1}{n - k},$$ where \(n\) is the sample size and \(k\) is the number of parameters in the regression model, including the intercept. For an effect size \(g\left( \boldsymbol{\theta}^{\ast} \right)\) that is a function of the standardized parameters, the sampling variance is approximated by the delta method, $$\widehat{\operatorname{var}} \left( \hat{g} \right) = \boldsymbol{J}_{g} \, \widehat{\boldsymbol{\Sigma}}_{\boldsymbol{\theta}^{\ast}} \, \boldsymbol{J}_{g}^{\prime},$$ where \(\boldsymbol{J}_{g}\) is the Jacobian of \(g\) and \(\widehat{\boldsymbol{\Sigma}}_{\boldsymbol{\theta}^{\ast}}\) is the sampling covariance matrix from BetaHC(), BetaADF(), or BetaN().

Author

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaSandwich")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# BetaHC -------------------------------------------------------------------
std <- BetaHC(object = object)

# RSqSandwich --------------------------------------------------------------
out <- RSqSandwich(object = std)

## Methods -----------------------------------------------------------------
print(x = out)
#> Call:
#> RSqSandwich(object = std)
#> 
#> R-squared and adjusted R-squared with HC3 standard errors:
#>        est     se       z p  0.05%   0.5%   2.5%  97.5%  99.5% 99.95%
#> rsq 0.8045 0.0573 14.0286 0 0.6158 0.6568 0.6921 0.9169 0.9522 0.9932
#> adj 0.7906 0.0614 12.8662 0 0.5884 0.6323 0.6701 0.9110 0.9488 0.9928
summary(object = out)
#> Call:
#> RSqSandwich(object = std)
#> 
#> R-squared and adjusted R-squared with HC3 standard errors:
#>        est     se       z p  0.05%   0.5%   2.5%  97.5%  99.5% 99.95%
#> rsq 0.8045 0.0573 14.0286 0 0.6158 0.6568 0.6921 0.9169 0.9522 0.9932
#> adj 0.7906 0.0614 12.8662 0 0.5884 0.6323 0.6701 0.9110 0.9488 0.9928
coef(object = out)
#>       rsq       adj 
#> 0.8045263 0.7905638 
vcov(object = out)
#>             rsq         adj
#> rsq 0.003288894 0.003523815
#> adj 0.003523815 0.003775516
confint(object = out, level = 0.95)
#>         2.5 %    97.5 %
#> rsq 0.6921245 0.9169280
#> adj 0.6701334 0.9109943