gg_PIT_global {recalibratiNN} | R Documentation |
Plots Density Distributions of PIT-values for global calibration diagnose.
Description
A function based on ggplot2 to observe the global the density of PIT-values. For more detailed edition of layers a posteriori, please refer to ggplot2 User Guide.
Usage
gg_PIT_global(
pit,
type = "density",
fill = "steelblue4",
alpha = 0.8,
print_p = TRUE
)
Arguments
pit |
vector of pit values |
type |
either "density" or "histogram" to change type of graph. |
fill |
The color to fill the density plot. The default is 'stealblue4. |
alpha |
The opacity of the density plot filling. Default is set to 0.8. |
print_p |
Logical value indicating whether or not to print the p-value of ks.test() |
Value
a ggplot density graph
Examples
n <- 10000
split <- 0.8
# generating heterocedastic data
mu <- function(x1){
10 + 5*x1^2
}
sigma_v <- function(x1){
30*x1
}
x <- runif(n, 1, 10)
y <- rnorm(n, mu(x), sigma_v(x))
x_train <- x[1:(n*split)]
y_train <- y[1:(n*split)]
x_cal <- x[(n*split+1):n]
y_cal <- y[(n*split+1):n]
model <- lm(y_train ~ x_train)
y_hat <- predict(model, newdata=data.frame(x_train=x_cal))
MSE_cal <- mean((y_hat - y_cal)^2)
pit <- PIT_global(ycal=y_cal, yhat=y_hat, mse=MSE_cal)
gg_PIT_global(pit)
[Package recalibratiNN version 0.2.0 Index]