betaNB: Example Using the DeltaRSqNB Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-delta-r-sq-nb.Rmd
example-delta-r-sq-nb.Rmd
Confidence intervals for improvement in R-squared are generated using
the DeltaRSqNB()
function from the betaNB
package. In this example, we use the data set and the model used in betaNB: Example Using the BetaNB
Function.
df <- betaNB::nas1982
Regression
Fit the regression model using the lm()
function.
object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = df)
Nonparametric Bootstrap
nb <- NB(object)
Improvement in R-squared
Normal-Theory Approach
out <- DeltaRSqNB(nb, alpha = 0.05)
Methods
summary
Summary of the results of DeltaRSqNB()
.
Percentile Confidence Intervals
summary(out, type = "pc")
#> est se R 2.5% 97.5%
#> NARTIC 0.1859 0.0589 5000 0.0841 0.3118
#> PCTGRT 0.1177 0.0488 5000 0.0355 0.2260
#> PCTSUPP 0.0569 0.0340 5000 0.0086 0.1376
Bias Corrected Confidence Intervals
summary(out, type = "bc")
#> est se R 2.5% 97.5%
#> NARTIC 0.1859 0.0589 5000 0.0940 0.3382
#> PCTGRT 0.1177 0.0488 5000 0.0417 0.2450
#> PCTSUPP 0.0569 0.0340 5000 0.0108 0.1437
Bias Corrected and Accelerated Confidence Intervals
summary(out, type = "bca")
#> est se R 2.5% 97.5%
#> NARTIC 0.1859 0.0589 5000 0.0980 0.3472
#> PCTGRT 0.1177 0.0488 5000 0.0458 0.2577
#> PCTSUPP 0.0569 0.0340 5000 0.0094 0.1406
coef
Return the vector of estimates.
coef(out)
#> NARTIC PCTGRT PCTSUPP
#> 0.1858925 0.1176542 0.0568722
vcov
Return the sampling covariance matrix.
vcov(out)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0034719935 -0.0001997241 -0.0002035929
#> PCTGRT -0.0001997241 0.0023856009 -0.0002806881
#> PCTSUPP -0.0002035929 -0.0002806881 0.0011554583
confint
Return confidence intervals.
Percentile Confidence Intervals
confint(out, level = 0.95, type = "pc")
#> 2.5 % 97.5 %
#> NARTIC 0.084086820 0.3118446
#> PCTGRT 0.035487360 0.2259744
#> PCTSUPP 0.008636416 0.1375862
Bias Corrected Confidence Intervals
confint(out, level = 0.95, type = "bc")
#> 2.5 % 97.5 %
#> NARTIC 0.09397235 0.3382464
#> PCTGRT 0.04174721 0.2449696
#> PCTSUPP 0.01077619 0.1436647
Bias Corrected and Accelerated Confidence Intervals
confint(out, level = 0.95, type = "bca")
#> 2.5 % 97.5 %
#> NARTIC 0.098014885 0.3472307
#> PCTGRT 0.045816598 0.2577377
#> PCTSUPP 0.009402403 0.1406139