fit_steplength | R Documentation |
This function finds parameter estimates of the marginal linear distribution, or gives a kernel density estimate using a Gaussian smoothing kernel.
fit_steplength( x, parametric = c("beta", "cauchy", "chi-squared", "chisq", "exponential", "exp", "gamma", "lognormal", "lnorm", "lognorm", "logistic", "normal", "t", "weibull", "normalmix", "weibullmix", "gammamix", "lnormmix", FALSE), start = NULL, bandwidth = NULL, ncomp = 2 )
x |
numeric vector of measurements of a linear random variable in [0,∞). |
parametric |
either a character string describing what distribution
should be fitted ( |
start |
(optional, except when |
bandwidth |
numeric value for the kernel density bandwidth.
Default is |
ncomp |
integer, number of components of the mixed distribution.
Only has an effect if |
If a parametric estimate is made, a list is returned
containing the estimated parameters, their standard errors,
the log-likelihood, the AIC and the name of the distribution.
If a non-parametric estimate is made, the output is a a 'density
' object,
which is obtained with the function
GoFKernel::density.reflected()
of the 'GoFKernel'
package.
GoFKernel::density.reflected()
,
fit_angle()
, opt_lin_bw()
.
require(graphics) set.seed(123) silent_curr <- cylcop_get_option("silent") cylcop_set_option(silent = TRUE) n <- 100 #n (number of samples) is set small for performance. x <- rweibull(n, shape = 10) dens_non_param <- fit_steplength(x = x, parametric = FALSE) weibull <- fit_steplength(x = x, parametric = "weibull") gamma <- fit_steplength(x = x, parametric = "gamma") chisq <- fit_steplength(x = x, parametric = "chi-squared", start = list(df = 1)) true_dens <- dweibull(seq(0, max(x), length.out = 200), shape = 10 ) dens_weibull <- dweibull(seq(0, max(x),length.out = 200), shape = weibull$coef$shape, scale = weibull$coef$scale ) dens_gamma <- dgamma(seq(0, max(x),length.out = 200), shape = gamma$coef$shape, rate = gamma$coef$rate ) dens_chisq <- dchisq(seq(0, max(x),length.out = 200), df = chisq$coef$df ) plot(seq(0,max(x),length.out = 200), true_dens, type = "l") lines(dens_non_param$x, dens_non_param$y, col = "red") lines(seq(0,max(x),length.out = 200), dens_weibull, col = "green") lines(seq(0,max(x),length.out = 200), dens_gamma, col = "blue") lines(seq(0,max(x),length.out = 200), dens_chisq, col = "cyan") cylcop_set_option(silent = silent_curr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.