rmse: compute the (normalized) root mean squared error for a greta...

View source: R/rmse.r

rmseR Documentation

compute the (normalized) root mean squared error for a greta regression model

Description

Compute the root mean squared error of a greta model

Usage

rmse(y, pred, draws, summary = TRUE, probs = c(0.1, 0.9), norm = FALSE)

Arguments

y

a greta array, the response variables

pred

a greta array, the linear predictor

draws

a greta_mcmc_list object, posterior draws as returned from calling greta sampling algorithm (ie mcmc)

summary

a logical, if TRUE (default) the function output summary statistics (mean, sd, 80% credible intervals) for the R2, if FALSE the raw values are returned

probs

a vector of two numeric specifying the lower and upper limits for the credible intervals (default to 0.1, 0.9), only used if summary=TRUE

norm

a logical, whether to normalize the RMSE by the mean of the response variable

Details

Note that when normalized RMSE (norm=TRUE), is compute as follow: nRMSE = RMSE / mean(y)

Value

If summary=TRUE a 1 x C matrix is returned (C = length(probs) + 2) containing summary statistics of Bayesian R-squared values. If summary = FALSE the posterior samples of the R-squared values are returned as a numeric vector of length S (S is the number of samples)

Examples

## Not run: 
intercept <- normal(0, 1)
slope <- normal(0, 1)
sd_resid <- cauchy(0, 1, truncation = c(0, 100))

x <- runif(100)
y <- as_data(rnorm(100, 1 + 2 * x, 1))

pred <- intercept + slope * x
distribution(y) <- normal(pred, sd_resid)

m <- model(intercept, slope, sd_resid)
drr <- mcmc(m)

rmse(y, pred, drr)

## End(Not run)

lionel68/greta.checks documentation built on July 30, 2022, 11:39 a.m.