fit_dist: Fit distribution to parameter

View source: R/fct_inspection.R

fit_distR Documentation

Fit distribution to parameter

Description

This function fits statistical distributions to a user-defined parameter.

Usage

fit_dist(df, param, dist = c("norm", "beta", "gamma", "lnorm"))

Arguments

df

a dataframe.

param

character. Name of variable of the dataframe on which to fit the distributions.

dist

character or vector of character. Determine which distribution to fit on the density plot.

Details

The available distributions are: "norm" (normal), "beta", "gamma", "lnorm" (lognormal). The arguments of the lists are "AIC" which contains the Akaike Information Criteria for each fitted distribution and "Dist_parameters" which contains the parameters of the fitted distributions. The distributions are fitted using the fitdistrplus::fitdist()

Value

A list with two objects:

  • Statistical_fit: a dataframe containing the statistical fit criteria of the fitted distributions.

  • Dist_parameters: a dataframe containing the parameter value of the fitted distributions.

Examples

# Fitting normal and beta distribution to the "u_pfs" variable of the example dataframe.
data(df_pa)
fit_dist(df = df_pa,
         param = "u_pfs",
         dist = c("norm", "beta"))

Xa4P/pacheck documentation built on April 14, 2025, 1:51 p.m.