Commit 02f6c688 authored by luroth's avatar luroth
Browse files

spline fitting optimized

parent 523e640c
...@@ -67,17 +67,17 @@ fit_scam_spline_weights <- function(x, y, w, k = NA, bs = "mpi", label = NULL, o ...@@ -67,17 +67,17 @@ fit_scam_spline_weights <- function(x, y, w, k = NA, bs = "mpi", label = NULL, o
spline <- NULL spline <- NULL
try( try(
spline <- R.utils::withTimeout(scam(y ~ s(as.numeric(x), k = k, bs = bs), optimizer = optimizer, weights = w), timeout=0.3) spline <- R.utils::withTimeout(scam(y ~ s(as.numeric(x), k = k, bs = bs), optimizer = optimizer, weights = w), timeout=1)
) )
if (is.null(spline)) { if (is.null(spline)) {
print("decreasing k") print("decreasing k")
try( try(
spline <- R.utils::withTimeout(scam(y ~ s(as.numeric(x), k = k - 1, bs = bs), optimizer = optimizer, weights = w), timeout=0.3) spline <- R.utils::withTimeout(scam(y ~ s(as.numeric(x), k = k - 1, bs = bs), optimizer = optimizer, weights = w), timeout=1)
) )
if (is.null(spline)) { if (is.null(spline)) {
print("2. time decreasing k") print("2. time decreasing k")
try( try(
spline <- R.utils::withTimeout(scam(y ~ s(as.numeric(x), k = k - 2, bs = bs), optimizer = optimizer, weights = w), timeout=0.3) spline <- R.utils::withTimeout(scam(y ~ s(as.numeric(x), k = k - 2, bs = bs), optimizer = optimizer, weights = w), timeout=1)
) )
if (is.null(spline)) { if (is.null(spline)) {
spline <- scam(y ~ s(as.numeric(x), k = 8, bs = bs), optimizer = optimizer) spline <- scam(y ~ s(as.numeric(x), k = 8, bs = bs), optimizer = optimizer)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment