Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Measures of Sturdiness of Regression Coefficients
Version:0.1.8
Encoding:UTF-8
Author:Carlos Cinelli [aut, cre]
Maintainer:Carlos Cinelli <carloscinelli@hotmail.com>
Description:Implements the s-values proposed by Ed. Leamer. It provides a context-minimal approach for sensitivity analysis using extreme bounds to assess the sturdiness of regression coefficients.
Imports:ggplot2, reshape2
License:GPL-3
Suggests:knitr, testthat
VignetteBuilder:knitr
LazyData:true
BugReports:https://github.com/carloscinelli/sValues/issues
RoxygenNote:7.3.2
NeedsCompilation:no
Packaged:2025-05-04 18:06:22 UTC; cinelli
Repository:CRAN
Date/Publication:2025-05-04 18:20:02 UTC

sValues: measures of the sturdiness of regression coefficients

Description

The R package sValuesimplements the measure of sturdiness of coefficients proposed by Leamer (2014) and discussed in Leamer (2015). The S-values try to provide a sensible framework to assess the sensitivity of coefficient estimates to model ambiguity.

Details

The main function of the package is thesValues function.

More information can be found on its help documentation, examples and vignette.

The package also includes an example dataset on economic growth.

Author(s)

Maintainer: Carlos Cinellicarloscinelli@hotmail.com

References

Leamer, E. (2014). S-values: Conventional context-minimal measures of the sturdiness of regression coefficients. Working Paper

Leamer, E. (2015). S-values and bayesian weighted all-subsets regressions. European Economic Review.

See Also

Useful links:


Extract sValues Model Coefficients/Statistics

Description

Extract sValues Model Coefficients/Statistics

Usage

## S3 method for class 'sValues'coef(object, type = "default", ...)betas(object)t_values(object)s_values(object)extreme_bounds(object)

Arguments

object

an object of classsValues.

type

which coefficient/statistic to extract? Current options are "betas", "t_values", "s_values", "extreme_bounds" and "default". See details.

...

further arguments passed to or from other methods.

Details

For thecoef function, the default is to extract the beta coefficients, t-values and s-values. You can can get each one of those individually by settingtype to either "betas", "t_values" or "s_values". You can also get the extreme bounds of the estimates by settingtype to "extreme_bounds". Finally, you can settype = "all" to get everything.

For each option ofcoef, there is an alternative helper function with the same name. That is,coef(x, "betas") is equivalent tobetas(x), orcoef(x, "extreme_bounds") is equivalenttoextreme_bounds(x).

Value

The function returns adata.frame with the estimates for each variable.

See Also

summary.sValues.

Examples

data(economic_growth)eg_sv <- sValues(GR6096 ~ ., data = economic_growth)eg_betas <- coef(eg_sv, "betas")eg_t_values <- coef(eg_sv, "t_values")eg_s_values <- coef(eg_sv, "s_values")eg_ext_bounds <- coef(eg_sv, "extreme_bounds")# get sturdy estimates for R2 bounds 0.5 - 1eg_s_values[abs(eg_s_values[3]) > 1, 3, drop = FALSE]

Economic Growth data

Description

Sala i Martin's (88 countries)Leamer's (87 countries)Original (139 countries)

Usage

economic_growtheconomic_growth_originaleconomic_growth_sala_i_martin

Format

An object of classdata.frame with 87 rows and 68 columns.

An object of classdata.frame with 139 rows and 68 columns.

An object of classdata.frame with 88 rows and 68 columns.


Plot method for S-values

Description

Plot methods for objects of the classsValues.

Usage

## S3 method for class 'sValues'plot(x, type = "t_s_plot", ...)

Arguments

x

an object of classsValues.

type

the type of the plot. Current options aret_s_plot which returnsa scatterplot of s-values vs t-values for all coefficients andbeta_plot which returnsa plot of the different estimates for the coefficients.

...

additional arguments to be passed to the plot functions. See details.

Details

Additional arguments:

t_s_plot

beta_plot

Value

It returns aggplot object with the requested plot.

Examples

# growth regressions exampledata(economic_growth)eg_sv <- sValues(GR6096 ~ ., data = economic_growth)plot(eg_sv, R2_bounds = c(0.5, 1))plot(eg_sv, R2_bounds = c(0.1, 1))plot(eg_sv, type = "beta_plot", variable = "OPENDEC1", error_bar = FALSE)plot(eg_sv, type = "beta_plot", variable = "OPENDEC1", error_bar = TRUE)

Succinct display of S-values results.

Description

Succinct display of S-values results.

Usage

## S3 method for class 'sValues'print(x, ..., print.length = 6)

Arguments

x

an object of classsValues.

...

further arguments passed to or from other methods.

print.length

how many variables to show in the screen?This is used for pretty printing. The default is 6.

Value

NULL

Examples

data(economic_growth)eg_sv <- sValues(GR6096 ~ ., data = economic_growth)eg_svstr(eg_sv)

S-values: conventional model ambiguity measures

Description

The functionsValues performs the extreme bound analysis proposed by Leamer (2014) and discussed in Leamer (2015). For further details see the package vignette.

Usage

sValues(  ...,  R2_bounds = c(0.1, 0.5, 1),  favorites = NULL,  R2_favorites = NULL,  scale = TRUE)## S3 method for class 'formula'sValues(  formula,  data,  R2_bounds = c(0.1, 0.5, 1),  favorites = NULL,  R2_favorites = NULL,  scale = TRUE,  ...)## S3 method for class 'matrix'sValues(  m,  R2_bounds = c(0.1, 0.5, 1),  favorites = NULL,  R2_favorites = NULL,  scale = TRUE,  ...)## S3 method for class 'data.frame'sValues(  df,  R2_bounds = c(0.1, 0.5, 1),  favorites = NULL,  R2_favorites = NULL,  scale = TRUE,  ...)

Arguments

...

arguments passed to other methods. The first argument should be aformula followed by adata.frame;alternatively, as a shortcut, you can omit theformula and provide only amatrix or adata.frame: in that case, the function will automatically consider the first column as the dependent variable and the rest as the independent variables.

R2_bounds

a numeric vector with two or more R2 bounds to be considered in the analysis. The default values arec(0.1, 0.5, 1), proposed by Leamer (2014).

favorites

optional - a character vector that specifies the "favorite" variables to be used in the analysis.These variables will have different lower and upper R2 bounds as defined in theR_favorites argument.

R2_favorites

optional - a numeric vector with two or more R2 bounds for the "favorite" variables.

scale

should the variables be scaled/standardized to zero mean and unit variance? The default isTRUE. If your data is already scaled/standardized you should set this toFALSE.

formula

an object of the classformula: a symbolic description of the model to be fitted.

data

needed only when you pass a formula as first parameter. An object of the classdata.frame containing the variables used in the analysis.

m

an object of classmatrix with the dependent variable in the first column followed by the covariates. The matrix must have column names.

df

an object of classdata.frame with the dependent variable in the first column followed by the covariates.

Value

sValues returns an object a list of class "sValues" containing the main results of the analysis:

References

Leamer, E. (2014). S-values: Conventional context-minimal measures of the sturdiness of regression coefficients. Working Paper

Leamer, E. (2015). S-values and bayesian weighted all-subsets regressions. European Economic Review.

See Also

coef.sValues to extract coefficients or statistics;

print.sValues for printing;

summary.sValues for summaries;

plot.sValues for plots.

Examples

# growth regressions example## All variables, No favoritesdata(economic_growth)eg_sv <- sValues(GR6096 ~ ., data = economic_growth)eg_sv # prints resultsplot(eg_sv, R2_bounds = c(0.5, 1))plot(eg_sv, type = "beta_plot", variable = "P60", error_bar = TRUE)coefs_eg <- coef(eg_sv) # extract coefficientscoefs_eg##  only 14 variableseg_sv_14 <-  sValues(GR6096 ~GDPCH60L + OTHFRAC + ABSLATIT +                        LT100CR + BRIT + GOVNOM1 + WARTIME +                        SCOUT + P60 + PRIEXP70 + OIL +                        H60 + POP1560 + POP6560, data = economic_growth)eg_sv_14coefs_eg_14 <- coef(eg_sv_14)## With 14 favorites among all variablesfavorites <- c("GDPCH60L", "OTHFRAC", "ABSLATIT", "LT100CR",               "BRIT", "GOVNOM1", "WARTIME", "SCOUT",               "P60", "PRIEXP70", "OIL", "H60",               "POP1560", "POP6560")eg_sv_fav <- sValues(GR6096 ~ ., data = economic_growth, R2_bounds = c(0.5, 1),                    favorites = favorites, R2_favorites = c(0.4, 0.8))eg_sv_favplot(eg_sv_fav, R2_bounds = c(0.5, 1))plot(eg_sv_fav, type = "beta_plot", variable = "P60", error_bar = TRUE)coefs_eg_fav <- coef(eg_sv_fav)coefs_eg_fav

str sValues

Description

str method forsValues.

Usage

## S3 method for class 'sValues'str(object, max.level = 1, ...)

Arguments

object

an object of classsValues.

max.level

maximal level of nesting which is applied for displaying nested structures. Default is 1.

...

further arguments passed to or from other methods.


summary sValues

Description

For now, this function is equivalent toprint.sValues.

Usage

## S3 method for class 'sValues'summary(object, ...)

Arguments

object

an object of classsValues.

...

further arguments passed to or from other methods.


[8]ページ先頭

©2009-2025 Movatter.jp