scores_mixnorm | R Documentation |

Calculating scores for a mixture of normal distributions.

crps_mixnorm(y, m, s, w = NULL) crps_mixnorm_int(y, m, s, w = NULL, rel_tol = 1e-06) logs_mixnorm(y, m, s, w = NULL) dss_mixnorm(y, m, s, w = NULL)

`y` |
vector of observations. |

`m` |
matrix of mean parameters; rows represent observations, columns represent mixture components. |

`s` |
matrix of scale parameters; same structure as |

`w` |
optional; matrix of non-negative weights; same structure as |

`rel_tol` |
relative accuracy for numerical integration. |

`logs_mixnorm`

and `crps_mixnorm`

calculate scores via analytical formulas. `crps_mixnorm_int`

uses numerical integration for the CRPS; this can be faster if there are many mixture components (i.e., if `m`

, `s`

and `w`

have many columns). See examples below.

A vector of score values.

# Example 1: 100 observations, 15 mixture components mval <- matrix(rnorm(100*15), nrow = 100) sdval <- matrix(rgamma(100*15, shape = 2), nrow = 100) weights <- matrix(rep(1/15, 100*15), nrow = 100) y <- rnorm(100) crps1 <- crps_mixnorm(y = y, m = mval, s = sdval, w = weights) crps2 <- crps_mixnorm_int(y = y, m = mval, s = sdval, w = weights) ## Not run: # Example 2: 2 observations, 10000 mixture components mval <- matrix(rnorm(2*10000), nrow = 2) sdval <- matrix(rgamma(2*10000, shape = 2), nrow = 2) weights <- matrix(rep(1/10000, 2*10000), nrow = 2) y <- rnorm(2) # With many mixture components, numerical integration is much faster system.time(crps1 <- crps_mixnorm(y = y, m = mval, s = sdval, w = weights)) system.time(crps2 <- crps_mixnorm_int(y = y, m = mval, s = sdval, w = weights)) ## End(Not run)

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.