Skip to content

Commit 0a2fc6f

Browse files
committed
Update specification.R
1 parent daa2c86 commit 0a2fc6f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

R/specification.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,17 +560,21 @@ distribution_init_pars <- function(res, spec) {
560560
distribution <- spec$distribution$type
561561
if (distribution != "norm") {
562562
spec <- distribution_modelspec(na.omit(res), distribution = distribution)
563-
mod <- estimate(spec)
564-
cf <- coef(mod)
563+
mod <- try(estimate(spec, use_hessian = FALSE), silent = TRUE)
564+
if (inherits(mod,'try-error')) {
565+
cf <- c("skew" = 1, "shape" = ifelse(distribution == "std", 4.1, 2.1))
566+
} else {
567+
cf <- coef(mod)
568+
}
565569
if (distribution == "std") {
566570
skew <- 0
567-
shape <- coef(mod)["shape"]
571+
shape <- cf["shape"]
568572
tmp <- rbind(
569573
data.table(parameters = "skew", initial = skew, lower = 0, upper = 0, estimate = 0, scale = 1, group = "distribution", equation = "[D]", symbol = "\\zeta"),
570574
data.table(parameters = "shape", initial = shape, lower = 2.01, upper = 100, estimate = 1, scale = 1, group = "distribution", equation = "[D]", symbol = "\\nu"))
571575
} else if (distribution == "jsu") {
572-
skew <- coef(mod)["skew"]
573-
shape <- coef(mod)["shape"]
576+
skew <- cf["skew"]
577+
shape <- cf["shape"]
574578
tmp <- rbind(
575579
data.table(parameters = "skew", initial = skew, lower = -20, upper = 20, estimate = 1, scale = 1, group = "distribution", equation = "[D]", symbol = "\\zeta"),
576580
data.table(parameters = "shape", initial = shape, lower = 0.1, upper = 100, estimate = 1, scale = 1, group = "distribution", equation = "[D]", symbol = "\\nu"))
@@ -584,6 +588,7 @@ distribution_init_pars <- function(res, spec) {
584588
return(tmp)
585589
}
586590

591+
587592
lambda_init <- function(y, frequency = 1)
588593
{
589594
f <- tstransform(lambda = NA)

0 commit comments

Comments
 (0)