konfound_output

Quarto

suppressWarnings({
  library(githubinstall)
  library(evaluate)
  library(haven)
  library(tidyverse)
  devtools::install_local("/Users/jihoonchoi/Documents/GitHub/konfound", force = TRUE)
  library(konfound) })
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

── R CMD build ─────────────────────────────────────────────────────────────────
* checking for file ‘/private/var/folders/gl/9nbm4d7s0zv_7r1wcdpj_kv80000gn/T/RtmpbNatIP/file22802a21dc0b/konfound/DESCRIPTION’ ... OK
* preparing ‘konfound’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
  NB: this package now depends on R (>= 3.5.0)
  WARNING: Added dependency on R >= 3.5.0 because serialized objects in
  serialize/load version 3 cannot be read in older versions of R.
  File(s) containing such objects:
    ‘konfound/data/binary_dummy_data.rda’
* building ‘konfound_1.0.2.tar.gz’
Sensitivity analysis as described in Frank, 
Maroulis, Duong, and Kelcey (2013) and in 
Frank (2000).
For more information visit http://konfound-it.com.

Model 1

auto = read_dta("auto.dta")

m1 <- lm(mpg ~ weight + displacement + gear_ratio, data = auto)

summary(m1)

Call:
lm(formula = mpg ~ weight + displacement + gear_ratio, data = auto)

Residuals:
    Min      1Q  Median      3Q     Max 
-6.8220 -2.0305 -0.5961  1.0858 13.6341 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  37.564106   6.564394   5.722 2.40e-07 ***
weight       -0.006534   0.001176  -5.556 4.67e-07 ***
displacement  0.007686   0.011578   0.664    0.509    
gear_ratio    0.645258   1.598012   0.404    0.688    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.477 on 70 degrees of freedom
Multiple R-squared:  0.6537,    Adjusted R-squared:  0.6389 
F-statistic: 44.05 on 3 and 70 DF,  p-value: 4.161e-16
konfound(m1, weight, to_return = "table")
Dependent variable is mpg 
For interpretation, check out to_return = 'print'.
X represents weight, Y represents mpg, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term         estimate std.error statistic p.value   itcv
  <chr>           <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)    37.6       6.56      5.72    0     NA    
2 weight         -0.007     0.001    -5.56    0      0.132
3 displacement    0.008     0.012     0.664   0.509  0.631
4 gear_ratio      0.645     1.60      0.404   0.688  0.468

$Unconditional_Impact
# A tibble: 2 × 4
  term         `Cor(vX)` `Cor(vY)` Impact
  <chr>            <dbl>     <dbl>  <dbl>
1 displacement     0.895    -0.706 -0.632
2 gear_ratio      -0.759     0.616 -0.468

$Partial_Impact
# A tibble: 2 × 4
  term         `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                    <dbl>             <dbl>          <dbl>
1 gear_ratio             -0.0701            0.0789        -0.0055
2 displacement            0.729            -0.442         -0.323 
konfound(m1, displacement, to_return = "raw_output")
For interpretation, check out to_return = 'print'.
$obs_r
[1] 0.07909545

$act_r
[1] 0.07909545

$critical_r
[1] 0.2318834

$r_final
[1] 0.2318834

$rxcv
[1] 0.1347717

$rycv
[1] -0.2078861

$rxcvGz
[1] 0.352176

$rycvGz
[1] -0.352176

$itcvGz
[1] -0.1240279

$itcv
[1] -0.02801717

$r2xz
[1] 0.8535538

$r2yz
[1] 0.6515573

$benchmark_corr_product
[1] 0.5561392

$itcv_ratio_to_benchmark
[1] 0.05037798

$beta_threshold
[1] 0.02309179

$beta_threshold_verify
[1] 0.02309179

$perc_bias_to_change
[1] 66.71543

$RIR_primary
[1] 49

$RIR_perc
[1] 66.71543

$Fig_ITCV


$Fig_RIR

konfound(m1, gear_ratio, to_return = "table")
Dependent variable is mpg 
For interpretation, check out to_return = 'print'.
X represents gear_ratio, Y represents mpg, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term         estimate std.error statistic p.value   itcv
  <chr>           <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)    37.6       6.56      5.72    0     NA    
2 weight         -0.007     0.001    -5.56    0      0.613
3 displacement    0.008     0.012     0.664   0.509  0.585
4 gear_ratio      0.645     1.60      0.404   0.688  0.049

$Unconditional_Impact
# A tibble: 2 × 4
  term         `Cor(vX)` `Cor(vY)` Impact
  <chr>            <dbl>     <dbl>  <dbl>
1 weight          -0.759    -0.807  0.613
2 displacement    -0.829    -0.706  0.585

$Partial_Impact
# A tibble: 2 × 4
  term         `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                    <dbl>             <dbl>          <dbl>
1 weight                 -0.0701           -0.556          0.0389
2 displacement           -0.514             0.0634        -0.0326

Model 2

lifeexp = read_dta("lifeexp.dta")

m2 <- lm(mpg ~ wt + hp + gear, data = mtcars)

summary(m2)

Call:
lm(formula = mpg ~ wt + hp + gear, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.3712 -1.9017 -0.3444  0.9883  6.0655 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 32.013657   4.632264   6.911 1.64e-07 ***
wt          -3.197811   0.846546  -3.777 0.000761 ***
hp          -0.036786   0.009891  -3.719 0.000888 ***
gear         1.019981   0.851408   1.198 0.240963    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.574 on 28 degrees of freedom
Multiple R-squared:  0.8352,    Adjusted R-squared:  0.8176 
F-statistic: 47.31 on 3 and 28 DF,  p-value: 4.334e-11
konfound(m2, wt, to_return = "table")
Dependent variable is mpg 
For interpretation, check out to_return = 'print'.
X represents wt, Y represents mpg, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   32.0       4.63       6.91   0     NA    
2 wt            -3.20      0.847     -3.78   0.001  0.096
3 hp            -0.037     0.01      -3.72   0.001  0.511
4 gear           1.02      0.851      1.20   0.241  0.28 

$Unconditional_Impact
# A tibble: 2 × 4
  term  `Cor(vX)` `Cor(vY)` Impact
  <chr>     <dbl>     <dbl>  <dbl>
1 hp        0.659    -0.776 -0.511
2 gear     -0.583     0.480 -0.280

$Partial_Impact
# A tibble: 2 × 4
  term  `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>             <dbl>             <dbl>          <dbl>
1 gear             -0.670             0.612         -0.410
2 hp                0.726            -0.823         -0.598
konfound(m2, hp, to_return = "table")
Dependent variable is mpg 
For interpretation, check out to_return = 'print'.
X represents hp, Y represents mpg, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   32.0       4.63       6.91   0     NA    
2 wt            -3.20      0.847     -3.78   0.001  0.572
3 hp            -0.037     0.01      -3.72   0.001  0.113
4 gear           1.02      0.851      1.20   0.241  0.06 

$Unconditional_Impact
# A tibble: 2 × 4
  term  `Cor(vX)` `Cor(vY)`  Impact
  <chr>     <dbl>     <dbl>   <dbl>
1 wt        0.659    -0.868 -0.572 
2 gear     -0.126     0.480 -0.0604

$Partial_Impact
# A tibble: 2 × 4
  term  `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>             <dbl>             <dbl>          <dbl>
1 gear              0.423           -0.0639         -0.027
2 wt                0.726           -0.825          -0.599
konfound(m2, gear, to_return = "table")
Dependent variable is mpg 
For interpretation, check out to_return = 'print'.
X represents gear, Y represents mpg, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   32.0       4.63       6.91   0     NA    
2 wt            -3.20      0.847     -3.78   0.001  0.506
3 hp            -0.037     0.01      -3.72   0.001  0.098
4 gear           1.02      0.851      1.20   0.241  0.032

$Unconditional_Impact
# A tibble: 2 × 4
  term  `Cor(vX)` `Cor(vY)` Impact
  <chr>     <dbl>     <dbl>  <dbl>
1 wt       -0.583    -0.868 0.506 
2 hp       -0.126    -0.776 0.0976

$Partial_Impact
# A tibble: 2 × 4
  term  `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>             <dbl>             <dbl>          <dbl>
1 wt               -0.670            -0.751          0.504
2 hp                0.423            -0.547         -0.231

Model 3

data(longley)

# Fit a linear regression model
m3 <- lm(Employed ~ GNP + Unemployed + Population, data = longley)

summary(m3)

Call:
lm(formula = Employed ~ GNP + Unemployed + Population, data = longley)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.86541 -0.28638 -0.00244  0.23951  1.09949 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)  
(Intercept) 66.157747  23.855700   2.773   0.0169 *
GNP          0.047616   0.017014   2.799   0.0161 *
Unemployed  -0.003854   0.003315  -1.162   0.2677  
Population  -0.153892   0.266420  -0.578   0.5742  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.5387 on 12 degrees of freedom
Multiple R-squared:  0.9812,    Adjusted R-squared:  0.9765 
F-statistic: 208.5 on 3 and 12 DF,  p-value: 1.293e-10
konfound(m3, GNP, to_return = "table")
Dependent variable is Employed 
For interpretation, check out to_return = 'print'.
X represents GNP, Y represents Employed, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   66.2      23.9       2.77    0.017 NA    
2 GNP            0.048     0.017     2.80    0.016  0.003
3 Unemployed    -0.004     0.003    -1.16    0.268  0.304
4 Population    -0.154     0.266    -0.578   0.574  0.952

$Unconditional_Impact
# A tibble: 2 × 4
  term       `Cor(vX)` `Cor(vY)` Impact
  <chr>          <dbl>     <dbl>  <dbl>
1 Unemployed     0.604     0.502  0.304
2 Population     0.991     0.960  0.952

$Partial_Impact
# A tibble: 2 × 4
  term       `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                  <dbl>             <dbl>          <dbl>
1 Population             0.995             0.979          0.974
2 Unemployed            -0.787            -0.774          0.609
konfound(m3, Unemployed, to_return = "table")
Dependent variable is Employed 
For interpretation, check out to_return = 'print'.
X represents Unemployed, Y represents Employed, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   66.2      23.9       2.77    0.017 NA    
2 GNP            0.048     0.017     2.80    0.016  0.594
3 Unemployed    -0.004     0.003    -1.16    0.268  0.009
4 Population    -0.154     0.266    -0.578   0.574  0.659

$Unconditional_Impact
# A tibble: 2 × 4
  term       `Cor(vX)` `Cor(vY)` Impact
  <chr>          <dbl>     <dbl>  <dbl>
1 GNP            0.604     0.984  0.594
2 Population     0.687     0.960  0.659

$Partial_Impact
# A tibble: 2 × 4
  term       `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                  <dbl>             <dbl>          <dbl>
1 Population             0.826            -0.598         -0.494
2 GNP                   -0.787             0.855         -0.672
konfound(m3, Population, to_return = "table")
Dependent variable is Employed 
For interpretation, check out to_return = 'print'.
X represents Population, Y represents Employed, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   66.2      23.9       2.77    0.017 NA    
2 GNP            0.048     0.017     2.80    0.016  0.975
3 Unemployed    -0.004     0.003    -1.16    0.268  0.345
4 Population    -0.154     0.266    -0.578   0.574  0.003

$Unconditional_Impact
# A tibble: 2 × 4
  term       `Cor(vX)` `Cor(vY)` Impact
  <chr>          <dbl>     <dbl>  <dbl>
1 GNP            0.991     0.984  0.975
2 Unemployed     0.687     0.502  0.345

$Partial_Impact
# A tibble: 2 × 4
  term       `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                  <dbl>             <dbl>          <dbl>
1 GNP                    0.995             0.987          0.982
2 Unemployed             0.826            -0.638         -0.527

Model 4

data(swiss)

# Fit a linear regression model
m4 <- lm(Fertility ~ Education + Agriculture + Catholic, data = swiss)

summary(m4)

Call:
lm(formula = Fertility ~ Education + Agriculture + Catholic, 
    data = swiss)

Residuals:
    Min      1Q  Median      3Q     Max 
-15.178  -6.548   1.379   5.822  14.840 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 86.22502    4.73472  18.211  < 2e-16 ***
Education   -1.07215    0.15580  -6.881 1.91e-08 ***
Agriculture -0.20304    0.07115  -2.854  0.00662 ** 
Catholic     0.14520    0.03015   4.817 1.84e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 7.728 on 43 degrees of freedom
Multiple R-squared:  0.6423,    Adjusted R-squared:  0.6173 
F-statistic: 25.73 on 3 and 43 DF,  p-value: 1.089e-09
konfound(m4, Education, to_return = "table")
Dependent variable is Fertility 
For interpretation, check out to_return = 'print'.
X represents Education, Y represents Fertility, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   86.2       4.74      18.2    0     NA    
2 Education     -1.07      0.156     -6.88   0      0.402
3 Agriculture   -0.203     0.071     -2.85   0.007  0.226
4 Catholic       0.145     0.03       4.82   0      0.071

$Unconditional_Impact
# A tibble: 2 × 4
  term        `Cor(vX)` `Cor(vY)`  Impact
  <chr>           <dbl>     <dbl>   <dbl>
1 Agriculture    -0.640     0.353 -0.226 
2 Catholic       -0.154     0.464 -0.0713

$Partial_Impact
# A tibble: 2 × 4
  term        `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                   <dbl>             <dbl>          <dbl>
1 Catholic                0.146             0.376         0.0548
2 Agriculture            -0.638             0.206        -0.131 
# Error case
konfound(m4, Agriculture, to_return = "table")
Dependent variable is Fertility 
For interpretation, check out to_return = 'print'.
Error in solve.default(cvx): system is computationally singular: reciprocal condition number = 2.19513e-17
konfound(m4, Catholic, to_return = "table")
Dependent variable is Fertility 
For interpretation, check out to_return = 'print'.
X represents Catholic, Y represents Fertility, v represents each covariate.
First table is based on unconditional correlations, second table is based on
partial correlations.
$Main_Output
# A tibble: 4 × 6
  term        estimate std.error statistic p.value   itcv
  <chr>          <dbl>     <dbl>     <dbl>   <dbl>  <dbl>
1 (Intercept)   86.2       4.74      18.2    0     NA    
2 Education     -1.07      0.156     -6.88   0      0.102
3 Agriculture   -0.203     0.071     -2.85   0.007  0.142
4 Catholic       0.145     0.03       4.82   0      0.284

$Unconditional_Impact
# A tibble: 2 × 4
  term        `Cor(vX)` `Cor(vY)` Impact
  <chr>           <dbl>     <dbl>  <dbl>
1 Education      -0.154    -0.664  0.102
2 Agriculture     0.401     0.353  0.142

$Partial_Impact
# A tibble: 2 × 4
  term        `Partial Cor(vX)` `Partial Cor(vY)` Partial_Impact
  <chr>                   <dbl>             <dbl>          <dbl>
1 Agriculture             0.398            -0.124        -0.0495
2 Education               0.146            -0.609        -0.0888