R plots and R mathematical problems
$14-30 NZD
Paid on delivery
Q 1
a) Use base R graphics to draw the following probability density function (pdf) of a random
variable X and its cumulative distribution function (cdf). Annotate the plots appropriately.
Probability density function
_ Cumulative distribution function
b) Color the area under the curve (of pdf graph) corresponding to the following probability:
You are required to find the value of c by using the cdf function given above to annotate the
colored area of the plot.
Hint: You may find bquote function to be useful.
c) Save these three graphs as pdf files called [login to view URL], [login to view URL] and [login to view URL], respectively.
Q 2
The file [login to view URL] contains 40 samples of size 200 from a Weibull distribution with
various values of the shape and scale parameters. You are required to use the data in the column
with the heading given by “hkas238”.
a) Fit a Weibull distribution to your data using the function fitdistr from the package MASS.
b) Determine the scale and shape parameters of the fitted Weibull distribution.
c) Fit a Weibull distribution from first principles by calculating the likelihood function and
finding the maximum likelihood estimates of the parameters using the function optim.
Hint: The probability density function of the Weibull distribution is given by
The R function optim performs generic minimization of functions. Its main arguments are
par, a vector of starting parameters (so in our case, some realistic starting values for k and
) and fn, a function with first argument to be minimized over.
Also, the minimization problem we are dealing with involves some constraints about the
parameters of interest. Therefore, you may consider changing method, lower and upper
arguments in the optim function.
d) Draw a histogram of the data and overlay the _tted density function on the plot.
Hint: curve function in R may be useful.
e) Draw a Quantile-Quantile plot for your data. Add a line with slope given by the slope of a
line joining the points given by the upper and lower theoretical and sample quartiles, and
intercept zero. Annotate the plot appropriately.
Hint: ppoints function in R may be useful.
Make sure your code is runnable with the assumption that there is a copy of [login to view URL]
in the same folder as your R Markdown file.
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Project ID: #25508421
About the project
Awarded to:
Hey i can do first two questions for 50. Please ping me so that we can chat. Thanks............................