Monthly Gaussian mixture with two components

Monthly Gaussian mixture with two components

Note

Version 1.0.0

Public fields

control

List to contain custom control parameters.

mu1

Function, see monthlyParams.

mu2

Function, see monthlyParams.

sd1

Function, see monthlyParams.

sd2

Function, see monthlyParams.

prob

Function, see monthlyParams.

Active bindings

data

A tibble with the following columns:

date

Time series of dates.

Month

Vector of Month.

x

Time series used for fitting.

w

Time series of weights.

means

Matrix of means where a row represents a month and a column a mixture component.

sd

Matrix of std. deviations where a row represents a month and a column a mixture component.

p

Matrix of probabilities where a row represents a month and a column a mixture component.

model

Named List with 12 gaussianMixture objects.

loglik

Numeric, total log-likelihood.

fitted

A tibble with the classified series

moments

A tibble with the theoric moments. It contains:

Month

Month of the year.

mean

Theoric monthly expected value of the mixture model.

variance

Theoric monthly variance of the mixture model.

skewness

Theoric monthly skewness.

kurtosis

Theoric monthly kurtosis.

nobs

Number of observations used for fitting.

loglik

Monthly log-likelihood.

coefficients

A tibble with the fitted parameters.

std.errors

A tibble with the fitted std.errors

tidy

A tibble with the fitted std.errors

Methods


Method new()

Initialize a solarMixture object

Usage

solarMixture$new(
  components = 2,
  method = "mixtools",
  maxit = 10000,
  maxrestarts = 1000,
  abstol = 1e-08
)

Arguments

components

(integer(1)), number of components.

method

Character, package used to fit the parameters. Can be mixtools or mclust.

maxit

(integer(1)) Numeric, maximum number of iterations.

maxrestarts

(integer(1)) Numeric, maximum number of restarts.

abstol

(numeric(1)) Numeric, absolute level for convergence.


Method set_time_series()

Set the time series internally

Usage

solarMixture$set_time_series(x, dates, weights)

Arguments

x

vector

dates

date vector

weights

observations weights, if a weight is equal to zero the observation is excluded, otherwise is included with unitary weight.


Method fit()

Fit the parameters with mclust package

Usage

solarMixture$fit(
  x,
  date,
  weights,
  method = "mixtools",
  mu_target = rep(NA, 12),
  var_target = rep(NA, 12)
)

Arguments

x

vector

date

date vector

weights

observations weights, if a weight is equal to zero the observation is excluded, otherwise is included with unitary weight. When missing all the available observations will be used.

method

Character, package used to fit the parameters. Can be mclust or mixtools.

mu_target

Numeric vector with length 12, target mean of the mixture to match.

var_target

Numeric vector with length 12, target variance of the mixture to match.


Method update()

Update means, sd, p .

Usage

solarMixture$update(means, sd, p)

Arguments

means

Numeric matrix of means parameters.

sd

Numeric matrix of std. deviation parameters.

p

Numeric matrix of probability parameters.


Method update_logLik()

Apply the $update_logLik() method to all the gaussianMixture models

Usage

solarMixture$update_logLik()


Method filter()

Apply the $filter() method to all the gaussianMixture models

Usage

solarMixture$filter()


Method Hessian()

Apply the $Hessian() method to all the gaussianMixture models

Usage

solarMixture$Hessian()


Method logLik()

Log-likelihood

Usage

solarMixture$logLik(x, date)

Arguments

x

vector

date

dates


Method grades()

Compute the grades

Usage

solarMixture$grades(x, date)

Arguments

x

vector

date

dates


Method VaR()

Compute the VaR with certain confidence levels

Usage

solarMixture$VaR(date, alpha = 0.05)

Arguments

date

dates

alpha

confidence levels for the VaR

x

vector


Method ES()

Compute the VaR with certain confidence levels

Usage

solarMixture$ES(date, alpha = 0.05)

Arguments

date

dates

alpha

confidence levels for the VaR

x

vector


Method print()

Print method for solarMixture class.

Usage

solarMixture$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

solarMixture$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Model fit
model <- solarModel$new(spec)
model$fit()
#> No outliers!
# Inputs
x <- model$data$u_tilde
w <- model$data$weights
date <- model$data$date
# Solar Mixture object
sm <- solarMixture$new()
sm$fit(x, date, w)
params <- sm$parameters
sm$std.errors
#> # A tibble: 12 × 7
#>    Month    mu1    mu2    sd1    sd2     p1     p2
#>    <int>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
#>  1     1 0.0801 0.0436 0.0459 0.0381 0.0482 0.0482
#>  2     2 0.110  0.0323 0.0674 0.0476 0.0518 0.0518
#>  3     3 0.106  0.0392 0.0667 0.0297 0.0405 0.0405
#>  4     4 0.126  0.0585 0.0623 0.0487 0.0624 0.0624
#>  5     5 0.129  0.0446 0.0597 0.0394 0.0463 0.0463
#>  6     6 0.158  0.0437 0.0596 0.0379 0.0488 0.0488
#>  7     7 0.138  0.0311 0.0637 0.0302 0.0443 0.0443
#>  8     8 0.216  0.0397 0.0750 0.0565 0.0716 0.0716
#>  9     9 0.124  0.0341 0.0594 0.0320 0.0417 0.0417
#> 10    10 0.144  0.0447 0.0425 0.0418 0.0516 0.0516
#> 11    11 0.158  0.0715 0.0811 0.0441 0.0683 0.0683
#> 12    12 0.134  0.0562 0.0573 0.0837 0.0860 0.0860
# params[1,]$mu1 <- params[1,]$mu1*0.9
# sm$update(means = params[,c(2,3)])