PIT_local | R Documentation |

Return local PIT-values. Centroids for localization is obtained by k-means method from stats package. The vicinity of such centroids are selected though a aproximate k-nearst neighboors method from RANN package.

```
PIT_local(
xcal,
ycal,
yhat,
mse,
clusters = 6,
p_neighbours = 0.2,
PIT = PIT_global
)
```

`xcal` |
features/covariates from calibration set |

`ycal` |
observations of calibration set |

`yhat` |
predicted outputs from the calibrations et |

`mse` |
Mean Squared Error of the model |

`clusters` |
Number of partitions to create for local calibration. Centroids calculated by k-means method. Default set to 6. |

`p_neighbours` |
Proportion of xcal to localize neighboors in the KNN method. Default is 0.2. |

`PIT` |
function to return the PIT-values. Default set to PIT_global() from this package. |

A tibble with five containing in the first column containing unique names for the partition, "y_cal", the second column containing the yhat the third the pit-values and the last the number of neighbors in each partition.

```
n <- 10000
split <- 0.8
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_local(xcal = x_cal, ycal=y_cal, yhat=y_hat, mse=MSE_cal)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.