fitGGammaDist {MethylIT}  R Documentation 
This function performs the nonlinear fit of GGamma CDF of a variable x
fitGGammaDist(x, parameter.values, location.par = FALSE, sample.size = 20, npoints = NULL, maxiter = 1024, ftol = 1e12, ptol = 1e12, maxfev = 1e+05, nlms = FALSE, verbose = TRUE, ...)
x 
numerical vector 
parameter.values 
initial parameter values for the nonlinear fit. If the locator paramter is included (mu != 0), this must be given as parameter.values = list(alpha = 'value', scale = 'value', mu = 'value', psi = 'value') or if mu = 0, as: parameter.values =list(alpha = 'value', scale = 'value', psi = 'value'). If not provided, then an initial guess is provided. 
location.par 
whether to consider the fitting to generalized gamma distribution (GGamma) including the location parameter, i.e., a GGamma with four parameters (GGamam4P). 
sample.size 
size of the sample. 
npoints 
number of points used in the fit. If the number of points if greater than 10^6, then the fit is automatically set to npoints = 999999. However, the reported values for R.Cross.val, AIC, and BIC are computed taking into account the whole set of points. 
maxiter 
positive integer. Termination occurs when the number of iterations reaches maxiter. Default value: 1024. 
ftol 
nonnegative 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: 1e12 
ptol 
nonnegative 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: 1e12. 
maxfev 
integer; termination occurs when the number of calls to fn has reached maxfev. Note that nls.lm sets the value of maxfev to 100*(length(par) + 1) if maxfev = integer(), where par is the list or vector of parameters to be optimized. 
nlms 
Logical. Whether to return the nonlinear model object

verbose 
if TRUE, prints the function log to stdout 
... 
arguments passed to or from other methods. 
The script algorithm tries to fit the threeparameter GGamma CDF ("GGamma3P") or the fourparameter GGamma ("GGamma4P") using a modification of LevenbergMarquardt algorithm implemented in function 'nls.lm' from 'minpack.lm' package that is used to perform the nonlinear fit. Crossvalidations 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 crossvalidation predictive power [1].
If the number of values to fit is >10^6, the fitting to a GGamma CDF would be a time consuming task. To reduce the computational time, the option summarized.data' can be set 'TRUE'. If npoint != NULL, the original variable values are summarized into 'npoint' bins and their midpoints are used as the new predictors. In this case, only the goodnessoffit indicators AIC and R.Cross.val are estimated based on all the original variable x values.
Model table with coefficients and goodnessoffit results:
Adj.R.Square, deviance, AIC, R.Cross.val, and rho, as well as, the
coefficient covariance matrix. If nlms = TRUE, then a list with
nonlinear model object nls.lm
is returned.
Robersy Sanchez  06/03/2016
1. Stevens JP. Applied Multivariate Statistics for the Social Sciences. Fifth Edit. Routledge Academic; 2009.
set.seed(123) x < rggamma(2000, alpha = 1.03, psi = 0.75, scale = 1.1) fitGGammaDist(x)