WPR2 | R Documentation |
W_p R^2
Function to Evaluate PerformanceThis function will calculate p-Wasserstein distances between the predictions of interest and the projected model.
WPR2(
predictions = NULL,
projected_model,
p = 2,
method = "exact",
base = NULL,
...
)
## S4 method for signature 'ANY,matrix'
WPR2(
predictions = NULL,
projected_model,
p = 2,
method = "exact",
base = NULL,
...
)
## S4 method for signature 'ANY,distcompare'
WPR2(
predictions = NULL,
projected_model,
p = 2,
method = "exact",
base = NULL,
...
)
## S4 method for signature 'ANY,list'
WPR2(
predictions = NULL,
projected_model,
p = 2,
method = "exact",
base = NULL,
...
)
## S4 method for signature 'ANY,WpProj'
WPR2(
predictions = NULL,
projected_model,
p = 2,
method = "exact",
base = NULL,
...
)
predictions |
Predictions of interest, likely from the original model |
projected_model |
A matrix of competing predictions, possibly from a WpProj fit, a WpProj fit itself, or a list of WpProj objects |
p |
Power of the Wasserstein distance to use in distance calculations |
method |
Method for calculating Wasserstein distance |
base |
The baseline result to compare to. If not provided, defaults to the model with no covariates and only an intercept. |
... |
Arguments passed to Wasserstein distance calculation. See |
W_p R ^2
values
if (rlang::is_installed("stats")) {
# this example is not a true posterior estimation, but is used for illustration
n <- 32
p <- 10
s <- 21
x <- matrix( stats::rnorm(n*p), nrow = n, ncol = p )
beta <- (1:10)/10
y <- x %*% beta + stats::rnorm(n)
post_beta <- matrix(beta, nrow=p, ncol=s) +
matrix(rnorm(p*s), p, s) # not a true posterior
post_mu <- x %*% post_beta
fit <- WpProj(X=x, eta=post_mu, power = 2.0)
out <- WPR2(predictions = post_mu, projected_model = fit,
base = rowMeans(post_mu) # same as intercept only projection
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.