.getDefaultNlsValues {MicrobialGrowth} | R Documentation |
Default NLS values
Description
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.
Usage
.getDefaultNlsValues(x, y, start = list(), lower = list(), upper = list())
Arguments
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. |
Details
default values are calculated as follows:
-
start
-
N0
: the minimum value ofy
-
Nmax
: the maximum value ofy
-
mu
:-
if length(y) <=
THRESHOLD_FEW_DATA: the greatest slope between two contiguous points (on loggedy
values) -
else
: the linear regression on data positioned in the middle ±25% of the amplitude on logged y
-
-
lambda
: the highest value ofx
which is within the lowest 5% of amplitude ofy
-
-
lower
-
N0
: the smallest value greater than zero calculated with1/.Machine$double.xmax
-
Nmax
: the mean value ofy
-
mu
: the amplitude ony
divided by the amplitude onx
-
lambda
:the minimum value ofx
-
-
upper
-
N0
: the mean value ofy
-
Nmax
: twice the max value ofy
-
mu
:-
if length(y) <=
THRESHOLD_FEW_DATA: the amplitude on loggedy
divided by the smallest step between two contiguousx
values -
else
: the greatest slope between two contiguous points (on loggedy
values)
-
-
lambda
: the maximum value ofx
-
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.
Value
the default values of start
, lower
and upper
for NLS regression.
Examples
# 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]