View source: R/mainFunctions.R
| fitAndCategorize | R Documentation |
Fits the sigmoidal and double-sigmoidal models to the data and then categorizes the data according to which model fits best.
fitAndCategorize(
dataInput,
dataInputName = NA,
n_runs_min_sm = 20,
n_runs_max_sm = 500,
n_runs_min_dsm = 20,
n_runs_max_dsm = 500,
showDetails = FALSE,
startList_sm = list(maximum = 1, slopeParam = 1, midPoint = 0.33),
lowerBounds_sm = c(maximum = 0.3, slopeParam = 0.01, midPoint = -0.52),
upperBounds_sm = c(maximum = 1.5, slopeParam = 180, midPoint = 1.15),
min_Factor_sm = 1/2^20,
n_iterations_sm = 1000,
startList_dsm = list(finalAsymptoteIntensityRatio = 0, maximum = 1, slope1Param = 1,
midPoint1Param = 0.33, slope2Param = 1, midPointDistanceParam = 0.29),
lowerBounds_dsm = c(finalAsymptoteIntensityRatio = 0, maximum = 0.3, slope1Param =
0.01, midPoint1Param = -0.52, slope2Param = 0.01, midPointDistanceParam = 0.04),
upperBounds_dsm = c(finalAsymptoteIntensityRatio = 1, maximum = 1.5, slope1Param = 180,
midPoint1Param = 1.15, slope2Param = 180, midPointDistanceParam = 0.63),
min_Factor_dsm = 1/2^20,
n_iterations_dsm = 1000,
threshold_intensity_range = 0.1,
threshold_minimum_for_intensity_maximum = 0.3,
threshold_bonus_sigmoidal_AIC = 0,
threshold_sm_tmax_IntensityRatio = 0.85,
threshold_dsm_tmax_IntensityRatio = 0.75,
threshold_AIC = -10,
threshold_t0_max_int = 1e+10,
stepSize = 1e-05,
startList_sm_h0 = list(maximum = 1, slopeParam = 1, midPoint = 0.33, h0 = 0),
lowerBounds_sm_h0 = c(maximum = 0.3, slopeParam = 0.01, midPoint = -0.52, h0 = -0.1),
upperBounds_sm_h0 = c(maximum = 1.5, slopeParam = 180, midPoint = 1.15, h0 = 0.3),
startList_dsm_h0 = list(finalAsymptoteIntensityRatio = 0, maximum = 1, slope1Param = 1,
midPoint1Param = 0.33, slope2Param = 1, midPointDistanceParam = 0.29, h0 = 0),
lowerBounds_dsm_h0 = c(finalAsymptoteIntensityRatio = 0, maximum = 0.3, slope1Param =
0.01, midPoint1Param = -0.52, slope2Param = 0.01, midPointDistanceParam = 0.04, h0 =
-0.1),
upperBounds_dsm_h0 = c(finalAsymptoteIntensityRatio = 1, maximum = 1.5, slope1Param =
180, midPoint1Param = 1.15, slope2Param = 180, midPointDistanceParam = 0.63, h0 =
0.3),
use_h0 = FALSE,
...
)
dataInput |
Unnormalized input data that will be fitted then transferred into relevant functions |
dataInputName |
Name of data set (Default is 'NA'). |
n_runs_min_sm |
This number indicates the lower limit of the successful fitting attempts for sigmoidal model. It should be smaller than the upper limit of the fitting attempts (n_runs_max_sm). Default is 20 |
n_runs_max_sm |
This number indicates the upper limit of the fitting attempts for sigmoidal model. Default is 500 |
n_runs_min_dsm |
This number indicates the lower limit of the successful fitting attempts for double sigmoidal model. It should be smaller than the upper limit of the fitting attempts (n_runs_max_dsm). Default is 20 |
n_runs_max_dsm |
This number indicates the upper limit of the fitting attempts for sigmoidal model for double sigmoidal model. Default is 500 |
showDetails |
Logical if TRUE prints details of intermediate steps of individual fits (Default is FALSE). |
startList_sm |
The vector containing the initial set of parameters that sigmoidal fit algorithm tries for the first fit attempt. The vector is composed of three elements; 'maximum', 'slopeParam' and, 'midPoint'. Detailed explanations of those parameters can be found in vignettes. Defaults are maximum = 1, slopeParam = 1 and, midPoint = 0.33. The numbers are in normalized time intensity scale. |
lowerBounds_sm |
The lower bounds for the randomly generated start parameters for the sigmoidal fit. The vector is composed of three elements; 'maximum', 'slopeParam' and, 'midPoint'. Detailed explanations of those parameters can be found in vignettes. Defaults are maximum = 0.3, slopeParam = 0.01, and midPoint = -0.52. The numbers are in normalized time intensity scale. |
upperBounds_sm |
The upper bounds for the randomly generated start parameters for the sigmoidal fit. The vector is composed of three elements; 'maximum', 'slopeParam' and, 'midPoint'. Detailed explanations of those parameters can be found in vignettes. Defaults are maximum = 1.5, slopeParam = 180, midPoint = 1.15. The numbers are in normalized time intensity scale. |
min_Factor_sm |
Defines the minimum step size used by the sigmoidal fit algorithm. Default is 1/2^20. |
n_iterations_sm |
Defines maximum number of iterations used by the sigmoidal fit algorithm. Default is 1000 |
startList_dsm |
The vector containing the initial set of parameters that double sigmoidal fit algorithm tries for the first fit attempt. The vector is composed of six elements; 'finalAsymptoteIntensityRatio', 'maximum', 'slope1Param', 'midPoint1Param' , 'slope2Param', and 'midPointDistanceParam'. Detailed explanations of those parameters can be found in vignettes. Defaults are finalAsymptoteIntensityRatio = 0, maximum = 1, slope1Param = 1, midPoint1Param = 0.33, slope2Param = 1, and midPointDistanceParam=0.29. The numbers are in normalized time intensity scale. |
lowerBounds_dsm |
The lower bounds for the randomly generated start parameters for double sigmoidal fit. The vector is composed of six elements; 'finalAsymptoteIntensityRatio', 'maximum', 'slope1Param', 'midPoint1Param' , 'slope2Param', and 'midPointDistanceParam'. Detailed explanations of those parameters can be found in vignettes. Defaults are finalAsymptoteIntensityRatio = 0, maximum = 0.3, slope1Param = .01, midPoint1Param = -0.52, slope2Param = .01, and midPointDistanceParam = 0.04. The numbers are in normalized time intensity scale. |
upperBounds_dsm |
The upper bounds for the randomly generated start parameters for double sigmoidal fit. The vector is composed of six elements; 'finalAsymptoteIntensityRatio', 'maximum', 'slope1Param', 'midPoint1Param' , 'slope2Param', and 'midPointDistanceParam'. Detailed explanations of those parameters can be found in vignettes. Defaults are finalAsymptoteIntensityRatio = 1, maximum = 1.5, slope1Param = 180, midPoint1Param = 1.15, slope2Param = 180, and midPointDistanceParam = 0.63. The numbers are in normalized time intensity scale. |
min_Factor_dsm |
Defines the minimum step size used by the double sigmoidal fit algorithm. Default is 1/2^20. |
n_iterations_dsm |
Define maximum number of iterations used by the double sigmoidal fit algorithm. Default is 1000 |
threshold_intensity_range |
Minimum for intensity range, i.e. it is the lower limit for the allowed difference between the maximum and minimum of the intensities (Default is 0.1, and the values are based on actual, not the normalized data.). |
threshold_minimum_for_intensity_maximum |
Minimum allowed value for intensity maximum. (Default is 0.3, and the values are based on actual, not the normalized data.). |
threshold_bonus_sigmoidal_AIC |
Bonus AIC points for sigmoidal fit. Negative values help the sigmoidal model to win. Only helps in competition between sigmoidal and double sigmoidal fit at decision step "9", i.e. if none of the models fail in any of the tests and stay as a candidate until the last step (Default is 0). |
threshold_sm_tmax_IntensityRatio |
The threshold for the minimum intensity ratio between the intensity of the last observed time points and theoretical maximum intensity of the sigmoidal curve. If the value is below the threshold, then the data can not be represented with the sigmoidal model. (Default is 0.85) |
threshold_dsm_tmax_IntensityRatio |
The threshold for the minimum intensity ratio between the intenstiy of the last observed time points and maximum intensity of the double sigmoidal curve. If the value is above the threshold, then the data can not be represented with the double sigmoidal model. (Default is 0.75) |
threshold_AIC |
Maximum AIC value in order to have a meaningful fit (Default is -10). |
threshold_t0_max_int |
Maximum allowed intensity of the fitted curve at time equal to zero (t=0). (Default is 1E10, and the values are based on actual, not the normalized data.). |
stepSize |
Step size used by the fitting algorithm. Smaller numbers give more accurate results than larger numbers, and larger numbers give the results faster than small numbers. The default value is 0.00001. |
startList_sm_h0 |
The vector containing the initial set of parameters that sigmoidal fit algorithm tries for the first fit attempt. The vector is composed of four elements; 'maximum', 'slopeParam', 'midPoint', and 'h0'. Detailed explanations of those parameters can be found in vignettes. Defaults are maximum = 1, slopeParam = 1 and, midPoint = 0.33, h0 = 0. The numbers are in normalized time intensity scale. |
lowerBounds_sm_h0 |
The lower bounds for the randomly generated start parameters for the sigmoidal fit. The vector is composed of four elements; 'maximum', 'slopeParam', 'midPoint', and 'h0'. Detailed explanations of those parameters can be found in vignettes. Defaults are maximum = 0.3, slopeParam = 0.01, midPoint = -0.52, and h0 = -0.1. The numbers are in normalized time intensity scale. |
upperBounds_sm_h0 |
The upper bounds for the randomly generated start parameters for the sigmoidal fit. The vector is composed of four elements; 'maximum', 'slopeParam', 'midPoint', and 'h0'. Detailed explanations of those parameters can be found in vignettes. Defaults are maximum = 1.5, slopeParam = 180, midPoint = 1.15, and h0 = 0.3. The numbers are in normalized time intensity scale. |
startList_dsm_h0 |
The vector containing the initial set of parameters that double sigmoidal fit algorithm tries for the first fit attempt. The vector is composed of seven elements; 'finalAsymptoteIntensityRatio', 'maximum', 'slope1Param', 'midPoint1Param' , 'slope2Param', 'midPointDistanceParam', and 'h0'. Detailed explanations of those parameters can be found in vignettes. Defaults are finalAsymptoteIntensityRatio = 0, maximum = 1, slope1Param = 1, midPoint1Param = 0.33, slope2Param = 1, midPointDistanceParam=0.29, h0 = 0. The numbers are in normalized time intensity scale. |
lowerBounds_dsm_h0 |
The lower bounds for the randomly generated start parameters for double sigmoidal fit. The vector is composed of seven elements; 'finalAsymptoteIntensityRatio', 'maximum', 'slope1Param', 'midPoint1Param' , 'slope2Param', 'midPointDistanceParam', and 'h0'. Detailed explanations of those parameters can be found in vignettes. Defaults are finalAsymptoteIntensityRatio = 0, maximum = 0.3, slope1Param = .01, midPoint1Param = -0.52, slope2Param = .01, midPointDistanceParam = 0.04, and h0 = -0.1. The numbers are in normalized time intensity scale. |
upperBounds_dsm_h0 |
The upper bounds for the randomly generated start parameters for double sigmoidal fit. The vector is composed of seven elements; 'finalAsymptoteIntensityRatio', 'maximum', 'slope1Param', 'midPoint1Param' , 'slope2Param', 'midPointDistanceParam', and 'h0'. Detailed explanations of those parameters can be found in vignettes. Defaults are finalAsymptoteIntensityRatio = 1, maximum = 1.5, slope1Param = 180, midPoint1Param = 1.15, slope2Param = 180, midPointDistanceParam = 0.63, and h0 = 0.3. The numbers are in normalized time intensity scale. |
use_h0 |
Boolean which decides whether to fix the lower asymptote of h0 at 0 (FALSE, default) or to freely estimate h0 (TRUE) |
... |
All other arguments that model functions ("sigmoidalFitFunction" and, "doublesigmoidalFitFunction") may need. |
Returns the parameters related with the curve fitted to the input data.
# runif() is used here for consistency with previous versions of the sicegar package. However,
# rnorm() will generate symmetric errors, producing less biased numerical parameter estimates.
# We recommend errors generated with rnorm() for any simulation studies on sicegar.
# Example 1
time <- seq(3, 24, 0.5)
#simulate intensity data and add noise
noise_parameter <- 0.2
intensity_noise <- stats::runif(n = length(time), min = 0, max = 1) * noise_parameter
intensity <- sicegar::doublesigmoidalFitFormula(time,
finalAsymptoteIntensityRatio = .3,
maximum = 4,
slope1Param = 1,
midPoint1Param = 7,
slope2Param = 1,
midPointDistanceParam = 8)
intensity <- intensity + intensity_noise
dataInput <- data.frame(intensity = intensity, time = time)
fitObj <- sicegar::fitAndCategorize(dataInput = dataInput)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.