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")
#> Call:
#> DeltaRSqNB(object = nb, alpha = 0.05)
#>
#> Improvement in R-squared
#> type = "pc"
#> est se R 2.5% 97.5%
#> NARTIC 0.1859 0.0601 5000 0.0817 0.3149
#> PCTGRT 0.1177 0.0500 5000 0.0345 0.2280
#> PCTSUPP 0.0569 0.0339 5000 0.0083 0.1346
Bias Corrected Confidence Intervals
summary(out, type = "bc")
#> Call:
#> DeltaRSqNB(object = nb, alpha = 0.05)
#>
#> Improvement in R-squared
#> type = "bc"
#> est se R 2.5% 97.5%
#> NARTIC 0.1859 0.0601 5000 0.0927 0.3427
#> PCTGRT 0.1177 0.0500 5000 0.0436 0.2486
#> PCTSUPP 0.0569 0.0339 5000 0.0108 0.1456
Bias Corrected and Accelerated Confidence Intervals
summary(out, type = "bca")
#> Call:
#> DeltaRSqNB(object = nb, alpha = 0.05)
#>
#> Improvement in R-squared
#> type = "bca"
#> est se R 2.5% 97.5%
#> NARTIC 0.1859 0.0601 5000 0.0958 0.3536
#> PCTGRT 0.1177 0.0500 5000 0.0474 0.2630
#> PCTSUPP 0.0569 0.0339 5000 0.0100 0.1405
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.0036135787 -0.0002846977 -0.0002311248
#> PCTGRT -0.0002846977 0.0024977969 -0.0002545603
#> PCTSUPP -0.0002311248 -0.0002545603 0.0011515539
confint
Return confidence intervals.
Percentile Confidence Intervals
confint(out, level = 0.95, type = "pc")
#> 2.5 % 97.5 %
#> NARTIC 0.08165068 0.3148952
#> PCTGRT 0.03453754 0.2279909
#> PCTSUPP 0.00827500 0.1346119
Bias Corrected Confidence Intervals
confint(out, level = 0.95, type = "bc")
#> 2.5 % 97.5 %
#> NARTIC 0.09272353 0.3426821
#> PCTGRT 0.04360572 0.2486299
#> PCTSUPP 0.01080113 0.1456063
Bias Corrected and Accelerated Confidence Intervals
confint(out, level = 0.95, type = "bca")
#> 2.5 % 97.5 %
#> NARTIC 0.095784560 0.3535939
#> PCTGRT 0.047404358 0.2629505
#> PCTSUPP 0.009967509 0.1404835