fit_nlsb: Nonlinear Slope Break Fit

Description Usage Arguments Details Examples

Description

Fits a piecewise nonlinear curve with one breakpoint There is one breakpoint, it is estimated using strucchange::breakpoints

Usage

1
fit_nlsb(WSEw, h = 10, maxiter = 100)

Arguments

WSEw

WSEw data (at a given level of exposure)

h

minimum distance from either of the WSE-w curve where the breakpoint is constrained to be

Details

See attributes(fit)$ef for error flags. Value 0 means no error, 1 means not enough data points, 2 means singular gradient at initial guess for nlsLM 9999 means utter failure

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
rWSEw <- readRDS("./Outputs/p4_newfits/rWSEw.rds")
r <- 5
WSEw <- observe(rWSEw[[r]], exposure = 0.4)
plot(WSE~w, WSEw)
nn <- length(WSEw$w)
fits <- fit_nlsb(WSEw)
sb.ind <- attributes(fits)$sb.ind
lines(WSEw$w[1:sb.ind], predict(fits[[1]]))
lines(WSEw$w[sb.ind:nn], predict(fits[[2]]))
Find an error case and see if it is handled better now
Did not manage to actually find such an error case
z0.error <- readRDS("./Outputs/p4_newfits/z0_error.rds")
z0.error.nlsb <- z0.error$nlsb
r <- 4
k <- 9
z0.error.nlsb[r,k,]
m <- 12
fit1 <- fit_nlsb(WSEw_obs[[k]][[m]])

jschap1/WSEw documentation built on May 12, 2019, 10:50 a.m.