Question

Below is R code (R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night") to plot a...

Below is R code (R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night") to plot a pareto distribution. For part (c), I'm unable to get the density curve to show up in the histogram. Thanks!

Problem 1. The Pareto distribution has been used in economics as a model for a density function with a slowly decaying tail. The Pareto($a$,$b$) distribution has pdf

$$
f(x) = \frac{ab^{a}}{x^{a+1}}, \quad x \geq b
$$

Set the seed number

set.seed(210)

(a) Use the inverse transform method to generate a random sample of size 1000 from the Pareto(3,2) distribution.

x <- runif(1000)
inv.cdf.pareto <- 2/(1-x)^(1/3)
head(inv.cdf.pareto)
tail(inv.cdf.pareto)

(b) Plot the density histogram of the sample.

hist(inv.cdf.pareto, prob = TRUE, col="gray", xlab="x")

(c) Add the theoretical density curve $f(x)$ to the density histogoram.

fx <- (3*2^3)/(x^4)
hist(inv.cdf.pareto, prob = TRUE, col="gray", xlab="x")
lines(x,fx)

Homework Answers

Answer #1

a) Use the inverse transform method to generate a random sample of size 1000 from the Pareto(3,2) distribution.

> set.seed(210)
> x <- runif(1000)
> inv.cdf.pareto <- 2/(1-x)^(1/3)
> head(inv.cdf.pareto)
[1] 2.540347 3.647373 4.213790 2.435244 2.250679 2.057318
> tail(inv.cdf.pareto)
[1] 2.029346 2.514305 2.151040 2.103859 4.200316 2.215587

b) Plot the density histogram of the sample.

> hist(inv.cdf.pareto, prob = TRUE, col="gray", xlab="x")

c)

> lines(density(inv.cdf.pareto))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT