Statistical Distribution and Its Density Plot | shiny Application -Part1

statistical distribution density function
General R langauage StatisticsLeave a Comment on Statistical Distribution and Its Density Plot | shiny Application -Part1

Statistical Distribution and Its Density Plot | shiny Application -Part1

In the previous post entitled Random Numbers, we mentioned how to generate random numbers from the normal distribution in the R programming language showing statistical distribution and its density plot. In this post, with the help of the Shiny library in R programming language, we will get the desired distribution type and parameter from the user and plot its density function graph.


First, I will write each part of the code, then we will give explanations about it. Using these steps, we will plot Statistical Distribution and Its Density Plot for some distributions.

Step 1.

In this section, the necessary libraries for plotting the density function are clearly loaded and the ggplot engine will be used.

Step 2.

In the second part, the instructions related to the preparation of the user layer (UI) are written. The screen is divided into two parts and the desired distribution parameters are to be determined in the left part. Statistical distributions can be drawn in this program as follows:

1- Normal distribution

2- T (student) Distribution

3- Chi-square distribution

4- F Distribution

The parameter of each distribution will also be placed as an input in different variables. There is also a button for choosing a color and drawing a graph on the screen.

Step 3

The Shiny Codes server section is located in this part. Calculations as well as the generation of random numbers from the desired distribution make up the rest of the code. As you can see, the data variable provides all the values related to random numbers in the form of a data frame. Then, with the help of the ggplot library, the final plot of the density function is done.

step 4

Setting the parameters of the distributions and requesting their input from the user lies in the codes of this part.

step 5

The addition of the shiny application execution section can be seen in the last step. After entering all these codes in a shiny file, you can run it to view the web page that will receive the inputs and draw the density function graph.

Note: Note that the inputs of each distribution may not be fit to its values (for example, enter the variance value for a negative normal distribution). For this reason, it is possible to see errors when drawing the statistical distribution and Its density plot.

In other posts, we will have modifications in the program that will prevent such errors and generalize it.

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top