Skip to content

Random distributions with specific shapes and related statistics

License

Notifications You must be signed in to change notification settings

MSeidelFed/RandodiStats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RandodiStats

R functions to work and test randomly generated response variables with specific distribution shapes and related statistics

The function plotting_distributions allows plotting the distribution of multiple variables of interest by estimating their shape through the kurtosis and square of skewness parameters. These parameters are a dependency of the "fitdistrplus" R package.

The function requires one mandatory parameter and five optional ones that go to default if not specified, e.g.

logis <- plotting_distributions(Distribution_test_mat = Distribution_test_mat, Regression_Family = "logis", n_random_distributions = 1000, colour = "red", random_distributions_plot = T, vector_colors = vector_colors)

Normal <- plotting_distributions(Distribution_test_mat = Distribution_test_mat, Regression_Family = "Normal", n_random_distributions = 1000, colour = "yellow", random_distributions_plot = T, vector_colors = vector_colors)

Beta <- plotting_distributions(Distribution_test_mat = Distribution_test_mat, Regression_Family = "Beta", n_random_distributions = 1000, colour = "grey", random_distributions_plot = T, vector_colors = vector_colors)

gamma <- plotting_distributions(Distribution_test_mat = Distribution_test_mat, Regression_Family = "gamma", n_random_distributions = 1000, colour = "blue", random_distributions_plot = T, vector_colors = vector_colors)

Mandatory function parameter - a data matrix

Distribution_test_mat is a matrix R object featuring response variables in each column and their measured values across treatments in rows.

In order to produce an exemplary matrix to be run into the main function, I have posted the function "distribution_test_mat" that requires two optional arguments to be used. e.g.

Distribution_test_mat <- distribution_test_mat()

Distribution_test_mat[1:5,1:5]

     [,1] [,2] [,3] [,4] [,5]
[1,]  6.5  8.5 22.7  6.9 23.0
[2,] 12.5  7.2  3.9 12.1 14.1
[3,] 16.0  9.7 13.6 10.8 15.6
[4,] 25.4  4.9  4.5 14.0  9.4
[5,] 18.1 24.7  3.5  7.7  4.3

The resulting default matrix will include 1000 "logis", "Normal", "Beta", "gamma" distributed randomly generated response variables. These are the distributions shapes included in the test and they must be stated in the main function "plotting_distributions".

Example of the shape plot obatained with 1000 randomly generated response variables per distrbution (using the function "distribution_test_mat")

Distributions

logis = "red"; normal = "yellow"; beta = "grey"; gamma = "gamma"

Optional function parameters - default to gamma, 100 random distributions, red color & no colors vector

n_random_distributions represents the amount of independent distributions with the specific shape that the function will use to construct the kurtosis and square of skewness graph.

colour defines the color of the distribution line in the graph.

If TRUE random_distributions_plot generates a plot of your random distribution aiming at observing the local concentration in individual points, distributions are not a linear trend as outlined in the resulting graph but rather complex concentrations that can be observed with this plot.

Finally, vector_colors enables you to input a charachter vector specifying the colour in which independent response variables should be plotted (see appended image). This feature is useful if you want to color differently potentially correlated variables which would show similar distribuions.

The function returns a matrix with the kurtosis and square of skewness values for the inputed response variables. Secondly, it returns a plot with the distribution of your variables as compared to the simplified-linear version of the shape distribution chosen by you. Note that the actual distribution of shape distributions (appended image) is much more complex that the simplified-linear version.

About

Random distributions with specific shapes and related statistics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages