Description Usage Arguments Details Value See Also Examples
View source: R/fit.distribution.R
This function calculates the distribution parameters and a number of statistics for a numeric vector and returns them as a named vector. This function is used internally by the standardized.index function or can be used to provide input to it.
1 | fit.distribution(data, distr, method = c("mle", "lmom"), na.thres = 10)
|
data |
vector of data |
distr |
character string specifying the distribution, see details |
method |
distribution fitting method, see details |
na.thres |
maximum percentage of NA values allowed in data, default = 10% |
Supported distributions are: gamma ('gamma'), 3-parameter gamma ('gamma3'), Weibull ('weibull'), 3-parameter Weibull ('weibull3'), Generalized Extreme Value ('gev'), and Generalized Logistic ('glogis'). Supported distribution fitting methods are: Maximum Likelihood Estimation ('mle', default for 'gamma','weibull','gev' and 'glogis') and L-Moments ('lmom', default for 'gamma3' and 'weibull3'). 'mle' is not supported for distributions 'gamma3' and 'weibull3'. For distr = 'glogis' and method = 'lmom', the 'glo' distribution from package 'lmomco' is used, and its parameters are returned.
a named vector containing:
fitted distribution parameters, parameters are distribution-specific
prob.zeroempirical probability of zeros in the data, used in SI calculation with with distributions not including zero such as gamma and Weibull
n.obsthe total number of observations in the data (including NA values)
n.nathe number of NA values in the data
pct.nathe percentage of NA values in the data
ks.pvalp-value for a two-sided Kolmogorov-Smirnov test that data comes form the fitted distribution
ad.pvalp-value for a two-sided Anderson-Darling test that data comes form the fitted distribution The data (without NA values) and distr, method and na.thres settings are added to the result as addditional attributes.
1 2 3 4 5 6 7 8 9 10 11 12 13 | data(Ukkel_RR)
# calculate the total rainfall for all months June
monthly.precipitation <- apply.monthly(x=Ukkel_RR,FUN=sum)
data <- c(coredata(monthly.precipitation[format(index(monthly.precipitation),'%m')=='06']))
# fit gamma distribution to the data
fit <- fit.distribution(data=data,distr='gamma',method='mle')
fitplot(x=fit,main='June precipitation',xlab='precipitation (mm)')
# fit gev distribution to the data
fit <- fit.distribution(data=data,distr='gev',method='mle')
fitplot(x=fit,main='June precipitation',xlab='precipitation (mm)')
# fit glogis distribution to the data
fit <- fit.distribution(data=data,distr='glogis',method='mle')
fitplot(x=fit,main='June precipitation',xlab='precipitation (mm)')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.