Skip to contents

Calculates intesities for given time points (x) by using sigmoidal fit model and parameters (maximum, slopeParam, and midpoint).

Usage

sigmoidalFitFormula(x, maximum, slopeParam, midPoint)

Arguments

x

the "time" (time) column of the dataframe.

maximum

the maximum intensity that the sigmoidal function can reach while time approaches infinity.

slopeParam

the slope parameter of the sigmoidal function at the steppest point.

midPoint

the x axis value of the steppest point in the function.

Value

Returns the predicted intensities for given time points with the given sigmoidal fit parameters.

Examples


time <- seq(3, 24, 0.5)

#simulate intensity data and add noise
noise_parameter <- 0.1
intensity_noise <- stats::runif(n = length(time), min = 0, max = 1) * noise_parameter
intensity <- sigmoidalFitFormula(time, maximum = 4, slopeParam = 1, midPoint = 8)
intensity <- intensity + intensity_noise

dataInput <- data.frame(intensity = intensity, time = time)
normalizedInput <- normalizeData(dataInput)
parameterVector <- sigmoidalFitFunction(normalizedInput, tryCounter = 2)

#Check the results
if(parameterVector$isThisaFit){
 intensityTheoretical <- sigmoidalFitFormula(time,
                                             maximum = parameterVector$maximum_Estimate,
                                             slopeParam = parameterVector$slopeParam_Estimate,
                                             midPoint = parameterVector$midPoint_Estimate)

 comparisonData <- cbind(dataInput, intensityTheoretical)

 require(ggplot2)
 ggplot(comparisonData) +
   geom_point(aes(x = time, y = intensity)) +
   geom_line(aes(x = time, y = intensityTheoretical)) +
   expand_limits(x = 0, y = 0)
}

if(!parameterVector$isThisaFit){
  print(parameterVector)
}
#>   maximum_N_Estimate maximum_Std_Error maximum_t_value maximum_Pr_t
#> 1                 NA                NA              NA           NA
#>   slopeParam_N_Estimate slopeParam_Std_Error slopeParam_t_value slopeParam_Pr_t
#> 1                    NA                   NA                 NA              NA
#>   midPoint_N_Estimate midPoint_Std_Error midPoint_t_value midPoint_Pr_t
#> 1                  NA                 NA               NA            NA
#>   residual_Sum_of_Squares log_likelihood AIC_value BIC_value isThisaFit
#> 1                     Inf             NA        NA        NA      FALSE
#>   startVector.maximum startVector.slopeParam startVector.midPoint
#> 1           0.3290071               153.6792           -0.3419652
#>   dataScalingParameters.timeRange dataScalingParameters.intensityMin
#> 1                              24                         0.06746024
#>   dataScalingParameters.intensityMax dataScalingParameters.intensityRange
#> 1                           4.096082                             4.028621
#>       model maximum_Estimate slopeParam_Estimate midPoint_Estimate
#> 1 sigmoidal               NA                  NA                NA