Question

In: Math

Problem 6: R simulation. Use different color lines and appropriate legend to (1) plot the density...

Problem 6: R simulation.

Use different color lines and appropriate legend to

(1) plot the density functions of χ 2 k for k = 1, 2, 3, 4, 6, 9 in one figure;

(2) plot the density functions of tk for k = 3, 5, 10, 30 and N(0, 1) distribution in one figure. Describe respectively what you observe when the degree of freedom increases.

Solutions

Expert Solution

1)

R codes are:

curve(dchisq(x,1),0,15,ylim=c(0,.5),lwd=2,col="black",ylab="Density")
curve(dchisq(x,2),add=T,col="red",lwd=2)
curve(dchisq(x,3),add=T,col="blue",lwd=2)
curve(dchisq(x,4),add=T,col="green",lwd=2)
curve(dchisq(x,6),add=T,col="orange",lwd=2)
curve(dchisq(x,9),add=T,col="steelblue",lwd=2)
legend(10,.45,legend=c("df=1","df=2","df=3","df=4","df=6","df=9"),
col=c("black","red","blue","green","orange","steelblue"),
lwd=c(2,2,2,2,2,2),bty="n")

2).

curve(dt(x,3),from=-3,to=3,ylab="Density",lwd=2,col="orange",ylim=c(0,.45))
curve(dt(x,5),add=T,lwd=2,col="red")
curve(dt(x,10),add=T,lwd=2,col="blue")
curve(dt(x,30),add=T,lwd=2,col="green")
curve(dnorm(x,0,1),add=T,col="black",lwd=2)

legend("topright",legend=c("df=3","df=5","df=10","df=30","N(0,1)"),
col=c("orange","red","blue","green","black"),
lwd=c(2,2,2,2,2),bty="n")

We can observed from the above plot that as degree of freedom increases t distribution approaches to normality.


Related Solutions

This is a question answered by R. **In this problem, we'll use simulation to think about...
This is a question answered by R. **In this problem, we'll use simulation to think about survey sampling. Suppose I want to plan a survey to learn what percentage of students prefer coffee to tea.** a. **Let *X* be the number of students in my sample that prefer coffee. If I survey *n* students, and the true proportion of students that prefer coffee is *p*, then we can model *X* as a Binomial(*n*, *p*) random variable. If I survey ten...
1)Using R, construct one plot of the density function for a uniformly distributed continuous random variable...
1)Using R, construct one plot of the density function for a uniformly distributed continuous random variable defined between 0 and 6. Make sure you include a main title, label both axis correctly and include a legend in your figure. The main title needs to include your last name, also include your R code with your answer. 2) Using R, construct one plot of the density function for a Chi-square distributed random variable. The plots should contain six lines corresponding to...
answer use a different color, please) 1. In shorthorn cattle the gene for red coat color...
answer use a different color, please) 1. In shorthorn cattle the gene for red coat color is not dominant over that for white coat color.       The heterozygous condition produces a roan color. A breeder has a white, red, and roan         cows and bulls. What phenotypes can be expected from the following crosses? A. Red x roan                B. Red x red               C.. Roan x white D. Red x white 2. A homozygous black chicken is crossed with a homozygous splashed white...
(Use R Programming to Code) Use the Monte Carol simulation to estimate the probability that all...
(Use R Programming to Code) Use the Monte Carol simulation to estimate the probability that all six faces appear exactly once in six tosses of fair dice.
1. Basic use of R/R Studio. Solve the following problem in R and print out the...
1. Basic use of R/R Studio. Solve the following problem in R and print out the commands and outputs. (a) Create a vector of the positive odd integers less than 100; Remove the values greater than 60 and less than 80; Find the variance of the remaining set of values (b) What’s the difference in output between the commands 2*1:5 and (2*1):5? Why is there a difference? (c) If you wanted to enter the odd numbers from 1 to 19...
1. In the following problem, check that it is appropriate to use the normal approximation to...
1. In the following problem, check that it is appropriate to use the normal approximation to the binomial. Then use the normal distribution to estimate the requested probabilities It is estimated that 3.4% of the general population will live past their 90th birthday. In a graduating class of 750 high school seniors, find the following probabilities. (Round your answers to four decimal places.) (a) 15 or more will live beyond their 90th birthday (b) 30 or more will live beyond...
Use a for loop to plot the function given in Problem 16 over the interval -2 ≤ x ≤ 6. Properly label
Use a for loop to plot the function given in Problem 16 over the interval -2 ≤ x ≤ 6. Properly label the plot. The variable y represents height in kilometers, and the variable x represents time in seconds.
# Problem 5: Use R to compute: # (a)(6 pts) Set three random vectors of 1000...
# Problem 5: Use R to compute: # (a)(6 pts) Set three random vectors of 1000 random numbers as follows: # x1: from Unif(0,5), # x2: from Binom(70,0.2), and # x3: from Exp(1). # Define y = x1 + 4*x2 + 8*x3 + 10 + Err, where Err ~ N(0,sd=10). # (b)(6 pts) Create a dataframe df containing these four variables # and create scatterplots of all pairs of these four variables. # (c) Create a multiple regression model for...
Q3. (This question is based in R) Now use the simulation ("X = rnorm(1000, mean =...
Q3. (This question is based in R) Now use the simulation ("X = rnorm(1000, mean = 10, sd = 2)", "Y = rnorm(1000, mean = 5, sd = 3)") to estimate the distribution of X+Y and create confidence intervals. A) Form a set of Xs and Ys by repeating the individual experiment for B = 2000 times, where each experiment has n = 1000 samples. You may want to write a for loop and create two matrices "sample_X" and "sample_Y"...
Does anyone know the code to use in R programming to create a scatter plot?
Does anyone know the code to use in R programming to create a scatter plot?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT