Nothing
#' Estimate Multiple Correlation Coefficients
#' (R-Squared and Adjusted R-Squared)
#' and Generate the Corresponding Sampling Distribution
#' Using Nonparametric Bootstrapping
#'
#' @author Ivan Jacob Agaloos Pesigan
#'
#' @details R-squared (\eqn{R^{2}}) and
#' adjusted R-squared (\eqn{\bar{R}^{2}})
#' is estimated from bootstrap samples.
#' Confidence intervals are generated by obtaining
#' percentiles corresponding to \eqn{100(1 - \alpha)\%}
#' from the generated sampling
#' distribution of \eqn{R^{2}} and \eqn{\bar{R}^{2}},
#' where \eqn{\alpha} is the significance level.
#'
#' @return Returns an object
#' of class `betanb` which is a list with the following elements:
#' \describe{
#' \item{call}{Function call.}
#' \item{args}{Function arguments.}
#' \item{thetahatstar}{Sampling distribution of
#' \eqn{R^{2}} and \eqn{\bar{R}^{2}}.}
#' \item{vcov}{Sampling variance-covariance matrix of
#' \eqn{R^{2}} and \eqn{\bar{R}^{2}}.}
#' \item{est}{Vector of estimated
#' \eqn{R^{2}} and \eqn{\bar{R}^{2}}.}
#' \item{fun}{Function used ("RSqNB").}
#' }
#'
#' @inheritParams BetaNB
#'
#' @examples
#' # Data ---------------------------------------------------------------------
#' data("nas1982", package = "betaNB")
#'
#' # Fit Model in lm ----------------------------------------------------------
#' object <- lm(QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = nas1982)
#'
#' # NB -----------------------------------------------------------------------
#' nb <- NB(
#' object,
#' R = 100, # use a large value e.g., 5000L for actual research
#' seed = 0508
#' )
#'
#' # RSqNB --------------------------------------------------------------------
#' out <- RSqNB(nb, alpha = 0.05)
#'
#' ## Methods -----------------------------------------------------------------
#' print(out)
#' summary(out)
#' coef(out)
#' vcov(out)
#' confint(out, level = 0.95)
#'
#' @family Beta Nonparametric Bootstrap Functions
#' @keywords betaNB rsq
#' @export
RSqNB <- function(object,
alpha = c(0.05, 0.01, 0.001)) {
stopifnot(
inherits(
x = object,
what = "nb"
)
)
fun <- "RSqNB"
est <- object$lm_process$rsq
foo <- function(x) {
rsq <- .RSqofSigma(
sigmacap = x,
k = object$lm_process$k
)
adj <- (
1 - (
1 - rsq
) * (
(
object$lm_process$n - 1
) / object$lm_process$df
)
)
return(
c(
rsq = rsq,
adj = adj
)
)
}
thetahatstar <- lapply(
X = object$thetahatstar,
FUN = foo
)
vcov <- stats::var(
do.call(
what = "rbind",
args = thetahatstar
)
)
colnames(vcov) <- rownames(vcov) <- names(est)
out <- list(
call = match.call(),
args = list(
object = object,
alpha = alpha
),
thetahatstar = thetahatstar,
jackknife = lapply(
X = object$jackknife,
FUN = foo
),
vcov = vcov,
est = est,
fun = fun
)
class(out) <- c(
"betanb",
class(out)
)
return(
out
)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.