This function performs the nonlinear fit of Weibull CDF of a variable x

weibull3P(
X,
sample.size = 20,
model = c("all", "2P", "3P", "Weibull2P", "Weibull3P"),
npoints = NULL,
maxiter = 1024,
tol = 1e-12,
ftol = 1e-12,
ptol = 1e-12,
minFactor = 10^-6,
nlms = FALSE,
verbose = TRUE,
...
)

Arguments

X

numerical vector

sample.size

size of the sample

model

Distribution model to fit, two-parameters and three-parameters Weibull model ('Weibull2P' or simply '2P' and 'Weibull3P' or '3P). Default is 'all' and the model with the best AIC criterion is reported.

npoints

number of points used in the fit

maxiter

positive integer. Termination occurs when the number of iterations reaches maxiter. Default value: 1024

tol

A positive numeric value specifying the tolerance level for the relative offset convergence criterion. Default value: 1e-12,

ftol

non-negative numeric. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. Therefore, ftol measures the relative error desired in the sum of squares. Default value: 1e-12,

ptol

non-negative numeric. Termination occurs when the relative error between two consecutive iterates is at most ptol. Therefore, ptol measures the relative error desired in the approximate solution. Default value: 1e-12,

minFactor

A positive numeric value specifying the minimum step-size factor allowed on any step in the iteration. The increment is calculated with a Gauss-Newton algorithm and successively halved until the residual sum of squares has been decreased or until the step-size factor has been reduced below this limit. Default value: 10^-6

nlms

Logical. Whether to return the nonlinear model object nls.lm. Default is FALSE.

verbose

if TRUE, prints the function log to stdout

...

other parameters

Value

Model table with coefficients and goodness-of-fit results: Adj.R.Square, deviance, AIC, R.Cross.val, and rho, as well as, the coefficient covariance matrix.

Details

The script algorithm first try to fit the two-parameter Weibull CDF (Weibull2P). If Weibull2P did not fit, then the algorithm will try to fit Weibull3P. The Levenberg-Marquardt algorithm implemented in 'minpack.lm' R package is used to perform the nonlinear fit. Cross-validations for the nonlinear regressions (R.Cross.val) were performed in each methylome as described in reference (1). In addition, Stein's formula for adjusted R squared (rho) was used as an estimator of the average cross-validation predictive power (1).

References

1. Stevens JP. Applied Multivariate Statistics for the Social Sciences. Fifth Edit. Routledge Academic; 2009.

Author

Robersy Sanchez - 06/03/2016 https://github.com/genomaths

Examples

x <- rweibull(1000, shape=0.75, scale=1)
weibull3P(x, sample.size = 100)
#>
#> *** Non-linear regression
#> *** Trying nonlinear fit a Weibull 2P model...
#> *** Trying nonlinear fit a Weibull 3P model ...
#> *** Weibull-2P is the best fitted model
#> *** Performing nonlinear regression model crossvalidation...
#>       Estimate   Std. Error  t value Pr(>|t|))     Adj.R.Square
#> shape 0.785109 0.0007679116 1022.395         0 0.99966640648701
#> scale 0.998828 0.0008097601 1233.486         0
#>                     rho       R.Cross.val                DEV              AIC
#> shape 0.999664731148226 0.999833935051061 0.0277716043574934 -7647.6194188588
#> scale
#>                     BIC     COV.shape     COV.scale COV.mu    n     model
#> shape -7632.89615302185  5.896883e-07 -1.680416e-07     NA 1000 Weibull2P
#> scale                   -1.680416e-07  6.557115e-07     NA 1000