Question

In: Statistics and Probability

Write the R code First, generate 1000 observations from a binomial distribution with n=30 and p=0.2...

Write the R code

First, generate 1000 observations from a binomial distribution with n=30 and p=0.2 Use the 1000 observations you generated:

a) Generate poisson, binomial, negative binomial Diagnostic Distribution Plots using distplot.

b) Generate a histogram and overlay a kernel estimator of the density

(You can use: binom <- rbinom(n=1000,size=30, prob=0.2))

Solutions

Expert Solution

Generate 1000 random observations of binomial distribution with n=30 and p=0.2

>obs<-rbinom(1000,30,0.2)

(a) Using above observations, generate Diagnostic Distribution Plot

install.packages("vcd")
library("vcd")

> distplot(obs, type="poisson")

> distplot(obs, type="binomial")

> distplot(obs, type="nbinomial")

> #(b) Histogram and overlay Kernel estimator of the density
> x <-obs
> h<-hist(x, breaks=10, col="red", xlab=" ", main="Histogram with Normal Curve")
> xfit<-seq(min(x),max(x),length=40)
> yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
> yfit <- yfit*diff(h$mids[1:2])*length(x)
> lines(xfit, yfit, col="blue", lwd=2)


Related Solutions

Use R and perform following: Generate 1000 observations from an exponential distribution with mean 10. Generate...
Use R and perform following: Generate 1000 observations from an exponential distribution with mean 10. Generate 1000 observations from a central t-distribution with 8 degree of freedom. Make a qqplot of observations in problem 1 versus quantiles generated from a t-distribution with 8 degree of freedom. Can the t distribution be used to approximate data in part 1?Submit the plot. Repeat above part but submit a qqplot of the observations in 1 versus quantiles from an exponential with mean 1....
2. Use MINITAB to generate 10,000 observations from a binomial distribution with n = 50 trials...
2. Use MINITAB to generate 10,000 observations from a binomial distribution with n = 50 trials and probability of success p = 0.02 . Create a histogram of the 10,000 observations. Comment on the shape of the distribution. Why does it makes sense for the histogram to have this shape? 3. Use MINITAB to generate 10,000 observations from a binomial distribution with n = 1000 trials and probability of success p = 0.02. Create a histogram of the 10,000 observations....
Suppose that X ~ NB(r, p) [negative binomial distribution] and that Y ~ B(n, p) [binomial]....
Suppose that X ~ NB(r, p) [negative binomial distribution] and that Y ~ B(n, p) [binomial]. a. Give a probabilistic argument to show that P(X > n) = P(Y < r). b. Use the FPF to express the equality in part (a) in terms of PMFs. c. Using the complementation rule, how many terms of the PMF of X must be evaluated to determine P(X > n)? d. How many terms of the PMF of Y must be evaluated to...
In the exercise, X is a binomial variable with n = 7 and p = 0.2....
In the exercise, X is a binomial variable with n = 7 and p = 0.2. Compute the given probability. Check your answer using technology. HINT [See Example 2.] (Round your answer to five decimal places.) P(1 ≤ X ≤ 3)
Write R code: Here are the first six observations from the prostate data set found in...
Write R code: Here are the first six observations from the prostate data set found in the faraway library. Use help(prostate) to describe the dataset and the variables in the data sets. obs lcavol lweight age lbph svi lcp gleason pgg45 lpsa 1 -0.579819 2.7695 50 -1.38629 0 -1.38629 6 0 -0.43078 2 -0.994252 3.3196 58 -1.38629 0 -1.38629 6 0 -0.16252 3 -0.510826 2.6912 74 -1.38629 0 -1.38629 7 20 -0.16252 4 -1.203973 3.2828 58 -1.38629 0 -1.38629 6...
Binomial Distribution. Suppose that X has a binomial distribution with n = 50 and p =...
Binomial Distribution. Suppose that X has a binomial distribution with n = 50 and p = 0.6. Use Minitab to simulate 40 values of X. MTB > random 40 c1; SUBC > binomial 50 0.6. Note: To find P(X < k) for any k > 0, use ‘cdf’ command; this works by typing: MTB > cdf; SUBC > binomial 50 0.6. (a) What proportion of your values are less than 30? (b) What is the exact probability that X will...
For each problem, write an R code to compute each probability. (a)   Binomial Distribution: X ~...
For each problem, write an R code to compute each probability. (a)   Binomial Distribution: X ~ Bin(10, 0.7)     (i)            P(X = 2)     (ii)           P(X < 2)     (iii)          P(X > 2)     (iv)          P(1 < X < 7) (b) Normal Distribution: X ~ N(0, 4). Note that variance is 4 and, hence, the standard deviation is 2.     (i)             P(X < 3)     (ii)           P(X > 3)     (iii)          P(1 < X < 3) (c) Choose either (a) or (b) and interpret the results in...
Suppose that X is a single observation from a Binomial(n, p) distribution where n is known...
Suppose that X is a single observation from a Binomial(n, p) distribution where n is known and 0 < p < 1 is unknown. Consider three estimators of p: pˆ = X /n “sample proportion” pˆA = (X + 2)/ (n + 4) “plus four estimator” pˆB = (X + (√n/4))/( n + √ n ). “constant MSE estimator” (a) Find the bias functions for all three estimators. (b) Find the variance functions of all three estimators. (c) Find the...
Suppose that X is a single observation from a Binomial(n, p) distribution where n is known...
Suppose that X is a single observation from a Binomial(n, p) distribution where n is known and 0 < p < 1 is unknown. Consider three estimators of p: pˆ = X /n “sample proportion” pˆA = (X + 2)/ (n + 4) “plus four estimator” pˆB = (X + (√n/4))/( n + √ n ). “constant MSE estimator” (a) Find the bias functions for all three estimators. (b) Find the variance functions of all three estimators. (c) Find the...
For the binomial distribution with n = 10 and p = 0.4, where p is probability...
For the binomial distribution with n = 10 and p = 0.4, where p is probability of success. Let X be the number of successes. (a) Find the probability of three or more successes. (b) Find the µ, E(X), and σ 2 , V ar(X)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT