R/betaMC-mc-rmse.R

Defines functions .MCRMSE

#' Monte Carlo Simulation Root Mean Square Error
#'
#' @details
#' \deqn{
#'   \mathrm{RMSE}_{\matnrm{MC}}
#'    =
#'    \left[
#'      R^{-1}
#'      \left(
#'        \sum_{r = 1}^{R}
#'        \boldsymbol{\hat{\theta}}_{r}
#'        -
#'        \boldsymbol{\hat{\theta}}
#'      \right)^{2}
#'    \right]^{\frac{1}{2}}
#' }
#'
#' @inheritParams BetaMC
#'
#' @family Beta Monte Carlo Functions
#' @keywords eval internal
#' @noRd
.MCRMSE <- function(object) {
  return(
    sqrt(
      colMeans(
        do.call(
          what = "rbind",
          args = lapply(
            X = object$thetahatstar,
            FUN = function(i,
                           est) {
              return(
                (
                  c(
                    i$coef,
                    i$sigmasq,
                    i$vechsigmacapx
                  )
                  -
                    est
                )^2
              )
            },
            est = c(
              object$lm_process$beta,
              object$lm_process$sigmasq,
              object$lm_process$vechsigmacapx
            )
          )
        )
      )
    )
  )
}

Try the betaMC package in your browser

Any scripts or data that you put into this service are public.

betaMC documentation built on June 24, 2024, 9:08 a.m.