From 4238827a7485ddbd3e736b3bb67f2422d6f135e2 Mon Sep 17 00:00:00 2001 From: Joe Brown Date: Mon, 12 Feb 2024 23:32:50 -0500 Subject: [PATCH] editing documentation before pull reequest --- R/RMSE_calc.R | 5 +++-- R/score_bayesian.R | 16 +++++++++++----- man/RMSE_calc.Rd | 8 +++++++- man/score_bayesian.Rd | 23 +++++++++++++++-------- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/R/RMSE_calc.R b/R/RMSE_calc.R index 6d08d41..45eaee5 100644 --- a/R/RMSE_calc.R +++ b/R/RMSE_calc.R @@ -8,7 +8,9 @@ #' @param sigma A single value or vector of error terms the same length as y. #' A single value will apply a constant error term. User can provide a vector #' of error terms to incorporate time-varying error into the RMSE calculation. -#' +#' `sigma` default assume homoscedasticity of residuals and applies a constant +#' error term equal to the standard deviation of observed data (scoring criterion). + #' @return Returns a vector of RMSE values #' @export #' @@ -16,7 +18,6 @@ #' x <- c(1:5) #' y <- c(5:9) #' -#' # constant error #' RMSE_calc(x, y) RMSE_calc <- function(x, y, sigma = sd(y)) { # Check if all values are NA diff --git a/R/score_bayesian.R b/R/score_bayesian.R index 9695d27..a1daca2 100644 --- a/R/score_bayesian.R +++ b/R/score_bayesian.R @@ -10,11 +10,17 @@ #' @param m A Matrix of values. The first column of the matrix should be #' a vector of observed data for a give variable. Subsequent vectors should be #' representative of modeled values for a given variable. -#' @param sigma Numeric value (optional). The standard deviation parameter for -#' the normal distribution used in the Bayesian analysis. If not provided, the -#' function will automatically compute it as the standard deviation of the -#' Root Mean Square Error (RMSE). A smaller value of `sigma` will make the -#' Bayesian analysis give more weight to models with lower RMSE values. +#' @param sigma Numeric value (optional). A single value or vector of error terms +#' the same length as y. A single value will apply a constant error term. User +#' can provide a vector of error terms to incorporate time-varying error +#' to the RMSE calculation. `sigma` default assume homoscedasticity of residuals +#' and applies a constant error term equal to the standard deviation of observed +#' data (scoring criterion). +#' @param sensitivity A multiplier that adjusts the sensitivity of the likelihood +#' values to increasing RMSE. If not provided, the function will automatically +#' calculate the sensitivity as one unit of standard deviation of the RMSE results. +#' A smaller sensitivity value will make the Bayesian analysis give more weight +#' to models with lower RMSE values. #' #' @note Note: In Bayesian statistics, the choice of `sigma` can significantly #' impact the results and conclusions of the analysis. Users are encouraged to diff --git a/man/RMSE_calc.Rd b/man/RMSE_calc.Rd index 859ef05..52f4d15 100644 --- a/man/RMSE_calc.Rd +++ b/man/RMSE_calc.Rd @@ -4,12 +4,18 @@ \alias{RMSE_calc} \title{Calculating Root Mean Square Error (RMSE)} \usage{ -RMSE_calc(x, y) +RMSE_calc(x, y, sigma = sd(y)) } \arguments{ \item{x}{A vector of modeled data values} \item{y}{A vector of observed data values} + +\item{sigma}{A single value or vector of error terms the same length as y. +A single value will apply a constant error term. User can provide a vector +of error terms to incorporate time-varying error into the RMSE calculation. +`sigma` default assume homoscedasticity of residuals and applies a constant +error term equal to the standard deviation of observed data (scoring criterion).} } \value{ Returns a vector of RMSE values diff --git a/man/score_bayesian.Rd b/man/score_bayesian.Rd index 74adc04..8b3f864 100644 --- a/man/score_bayesian.Rd +++ b/man/score_bayesian.Rd @@ -4,18 +4,25 @@ \alias{score_bayesian} \title{Computing Model Scores as Posterior Probabilities using Bayesian Inference} \usage{ -score_bayesian(m, sigma = NULL) +score_bayesian(m, sigma = NULL, sensitivity = NULL) } \arguments{ \item{m}{A Matrix of values. The first column of the matrix should be a vector of observed data for a give variable. Subsequent vectors should be representative of modeled values for a given variable.} -\item{sigma}{Numeric value (optional). The standard deviation parameter for -the normal distribution used in the Bayesian analysis. If not provided, the -function will automatically compute it as the standard deviation of the -Root Mean Square Error (RMSE). A smaller value of `sigma` will make the -Bayesian analysis give more weight to models with lower RMSE values.} +\item{sigma}{Numeric value (optional). A single value or vector of error terms +the same length as y. A single value will apply a constant error term. User +can provide a vector of error terms to incorporate time-varying error +to the RMSE calculation. `sigma` default assume homoscedasticity of residuals +and applies a constant error term equal to the standard deviation of observed +data (scoring criterion).} + +\item{sensitivity}{A multiplier that adjusts the sensitivity of the likelihood +values to increasing RMSE. If not provided, the function will automatically +calculate the sensitivity as one unit of standard deviation of the RMSE results. +A smaller sensitivity value will make the Bayesian analysis give more weight +to models with lower RMSE values.} } \value{ Returns a vector of scores with a length equal to the number of @@ -38,8 +45,8 @@ specific use case. } \examples{ # creating sample matrix -mat <- matrix(data = 1:15, nrow = 5, ncol = 3) +mat <- matrix(data = 1:20, nrow = 5, ncol = 4) # scoring with a decay rate of 2 -score_bayesian(mat, sigma = 2) +score_bayesian(mat, sensitivity = 2) }