Skip to content

Commit

Permalink
Fixed jitter so s2 is always within bounds, and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinErickson committed Feb 16, 2024
1 parent 8394bce commit e76d581
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 83 deletions.
14 changes: 10 additions & 4 deletions R/kernel_Factor.R
Expand Up @@ -350,7 +350,10 @@ FactorKernel <- R6::R6Class(
vec <- c()
}
if (s2_est) {
vec <- c(vec, self$logs2 + jitter*rnorm(1))
vec <- c(vec, max(min(self$logs2 + jitter * rnorm(1),
self$logs2_upper),
self$logs2_lower)
)
}
vec
},
Expand All @@ -362,13 +365,16 @@ FactorKernel <- R6::R6Class(
param_optim_start0 = function(jitter=F, y, p_est=self$p_est,
s2_est=self$s2_est) {
if (p_est) {
vec <- pmin(pmax(rep(0, length(self$p)) + jitter*rnorm(length(self$p), 0, .1),
self$p_lower), self$p_upper)
vec <- pmin(
pmax(rep(0, length(self$p)) + jitter*rnorm(length(self$p), 0, .1),
self$p_lower), self$p_upper)
} else {
vec <- c()
}
if (s2_est) {
vec <- c(vec, self$logs2 + jitter*rnorm(1))
vec <- c(vec, max(min(self$logs2 + jitter * rnorm(1),
self$logs2_upper),
self$logs2_lower))
}
vec
},
Expand Down

0 comments on commit e76d581

Please sign in to comment.