.getDefaultNlsValues | R Documentation |
Gives default values for NLS regression from x
and y
values.
The method of calculating default values differs depending on the amount of data available in y
.
Default values can be pre-set by providing them in the start
, lower
and upper
arguments.
.getDefaultNlsValues(x, y, start = list(), lower = list(), upper = list())
x |
index series or time series. |
y |
values or list of values to regress (should not be logged, must be strictly greater than zero). |
start |
a named list of starting estimates. The coefficients specified in this list will not be calculated. |
lower |
a named list of lower bounds. The coefficients specified in this list will not be calculated. |
upper |
a named list of upper bounds. The coefficients specified in this list will not be calculated. |
default values are calculated as follows:
start
N0
: the minimum value of y
Nmax
: the maximum value of y
mu
:
if length(y) <=
THRESHOLD_FEW_DATA: the greatest slope between two contiguous points (on logged y
values)
else
: the linear regression on data positioned in the middle ±25% of the amplitude on logged y
lambda
: the highest value of x
which is within the lowest 5% of amplitude of y
lower
N0
: the smallest value greater than zero calculated with 1/.Machine$double.xmax
Nmax
: the mean value of y
mu
: the amplitude on y
divided by the amplitude on x
lambda
:the minimum value of x
upper
N0
: the mean value of y
Nmax
: twice the max value of y
mu
:
if length(y) <=
THRESHOLD_FEW_DATA: the amplitude on logged y
divided by the smallest step between two contiguous x
values
else
: the greatest slope between two contiguous points (on logged y
values)
lambda
: the maximum value of x
Note that it is possible, particularly when there is little data, that linear regression for start$mu
is not possible, hence the presence of condition with THRESHOLD_FEW_DATA.
the default values of start
, lower
and upper
for NLS regression.
# Example data
x = c(0.00, 5.26, 10.53, 15.79, 21.05, 26.32, 31.58, 36.84, 42.11, 47.37, 52.63,
57.89, 63.16, 68.42, 73.68, 78.95, 84.21, 89.47, 94.74, 100.00)
y = c(0.15, 0.15, 0.15, 0.16, 0.19, 0.26, 0.38, 0.58, 0.85, 1.18, 1.53, 1.86,
2.15, 2.38, 2.55, 2.66, 2.78, 2.85, 2.89, 2.93)
# Simple example
values = .getDefaultNlsValues(x, y)
cat("N0=", values$start$N0, " with limits [", values$lower$N0, ", ", values$upper$N0,"]", sep="")
## N0=0.15 with limits [5.562685e-309, 1.4315]
# Example with specifying a starting value (which will therefore not be calculated)
values = .getDefaultNlsValues(x, y, start=list(N0=0.1))
cat("N0=", values$start$N0, " with limits [", values$lower$N0, ", ", values$upper$N0,"]", sep="")
## N0=0.1 with limits [5.562685e-309, 1.4315]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.