Question: 1 Creating an ECDF Function Empirical Cumulative Distribution Functions ( ECDFs ) are approximations to true Cumulative Distribution Functions. The function is defined as hat
Creating an ECDF Function
Empirical Cumulative Distribution Functions ECDFs are approximations to true Cumulative Distribution
Functions. The function is defined as
hat values
for the sample size. In other words, count how many of the set of values are less than or equal to a given
value then that is the function evaluation at that
Now, obviously to do this for all is impossible, even on a computer, as there are infinite number of s on
the real line. So instead, we compute ECDFs on a finite, discrete mesh of values, eg all multiples of
between and The range needs to be carefully chosen to cover all of the values in the sample, and the
multiple needs to be chosen small enough to ensure the plot is useful and sensible
Implement your own function in R which creates an ECDF given an input dat, consisting of real numeric
values. That is your function should resemble:
You will need to determine the range for the values, set a step for your mesh, then determine the values
that correspond to the s Store these two vectors which will be quite large! together in a data.frame object
called ecdf, so the final line of the function will return the data.frame of both and
Ensure your function is defined in a chunk which is set to be visible, so the code can be evaluated.
Testing your Implementation
As with TC there is a data set included with R called ToothGrowth, which can be loaded using
library datasets
data ToothGrowth
Use this data to generate an empirical CDF ECDF hat of the tooth growth len of guinea pigs after
receiving one of three dose dose levels of one of two supplements supp Plot an ECDF of the growth, with
appropriate labels. You must use your selfdeveloped code to generate the and pairs for the plot.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
