betaNB: Example Using the DeltaRSqNB Function
Ivan Jacob Agaloos Pesigan
Source:vignettes/example-delta-r-sq-nb.Rmd
example-delta-r-sq-nb.RmdConfidence 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::nas1982Regression
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.0589 5000 0.0828 0.3131
#> PCTGRT 0.1177 0.0486 5000 0.0360 0.2259
#> PCTSUPP 0.0569 0.0337 5000 0.0089 0.1345Bias 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.0589 5000 0.0917 0.3335
#> PCTGRT 0.1177 0.0486 5000 0.0440 0.2437
#> PCTSUPP 0.0569 0.0337 5000 0.0117 0.1522Bias 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.0589 5000 0.0957 0.3392
#> PCTGRT 0.1177 0.0486 5000 0.0477 0.2545
#> PCTSUPP 0.0569 0.0337 5000 0.0108 0.1463coef
Return the vector of estimates.
coef(out)
#> NARTIC PCTGRT PCTSUPP
#> 0.1858925 0.1176542 0.0568722vcov
Return the sampling covariance matrix.
vcov(out)
#> NARTIC PCTGRT PCTSUPP
#> NARTIC 0.0034691706 -0.0002535082 -0.0002448919
#> PCTGRT -0.0002535082 0.0023620847 -0.0002433746
#> PCTSUPP -0.0002448919 -0.0002433746 0.0011351322confint
Return confidence intervals.
Percentile Confidence Intervals
confint(out, level = 0.95, type = "pc")
#> 2.5 % 97.5 %
#> NARTIC 0.08278082 0.3130850
#> PCTGRT 0.03598906 0.2259309
#> PCTSUPP 0.00888793 0.1345443Bias Corrected Confidence Intervals
confint(out, level = 0.95, type = "bc")
#> 2.5 % 97.5 %
#> NARTIC 0.09173452 0.3334696
#> PCTGRT 0.04395415 0.2437100
#> PCTSUPP 0.01172624 0.1521928Bias Corrected and Accelerated Confidence Intervals
confint(out, level = 0.95, type = "bca")
#> 2.5 % 97.5 %
#> NARTIC 0.09569846 0.3392472
#> PCTGRT 0.04766694 0.2544546
#> PCTSUPP 0.01078521 0.1463342