Using R programming language, supply the code for:
Generate a random sample of size 10, 000 from gamma distribution with scale parameter equal to 1 and shape parameter equal to 2, and form it into a 1000 x 10 matrix. Use the apply() function on this matrix to compute the means of the 1000 rows. Note that the resulting vector comprises the mean of 1000 random samples of size 10 from the above distribution. Examine the distribution of the sample mean random variable graphically using the vector of simulated sample means and the R function hist(), plot(), boxplot(), and qqnorm(). As an argument to the plot() function, use the object created by using density() function on the mean vector.
Note: If you execute the R command par(mfrow = c(2, 2)) before you execute any of the plot commands, the 4 plots will appear in a single page.
Answer:
R Code:
x<-rgamma(10000,shape<-2,scale<-1)
dim(x)<-c(1000,10)
mean_xrow<-apply(x,1,mean)
par(mfrow=c(2,2))
hist(mean_xrow)
plot(mean_xrow)
boxplot(mean_xrow)
qqnorm(mean_xrow)
par(mfrow=c(1,1))
plot(density(mean_xrow))


Kindly Upvote if Helpful :)
HOPE THIS MAY HELP YOU----------------------
------------------------------THANK YOU
Using R programming language, supply the code for: Generate a random sample of size 10, 000...
STATS Use the R function rnorm() to simulate selecting a random sample of size 25 from a population with mean 80 and s.d. 20. The goal here is to show how contamination affects the mean, s.d., and z-scores. (a) Obtain the sample mean and sample sd of the simulated sample and use them to obtain the z-score for 100. (b) Create the vector contam = c(0,seq(1000,10000,length=21)) To show the effects of contamination, separately add each value of contam to the...
Use the rbinom() function to create a vector of 1000 random observations from the binomial distribution with n=100 and probability of success is equal to 0.4. Calculate the mean and standard deviation statistics for this vector of random draws using the mean() and sd() commands. How do these numbers compare the mean and standard deviation of the binomial distribution when and ? If they are different, why? Make a histogram of this vector using the hist() command.
How to do the following in R: Write a function to generate a random sample of size n from the Gamma(α,1) distribution by the acceptance-rejection method. Generate a random sample of size 1000 from the Gamma(3,1) distribution. (Hint: you may use g(x) ∼ Exp(λ = 1/α) as your proposal distribution, where λ is the rate parameter. Figure out the appropriate constant c).
Using R,
Exercise 4 (CLT Simulation) For this exercise we will simulate from the exponential distribution. If a random variable X has an exponential distribution with rate parameter A, the pdf of X can be written for z 2 0 Also recall, (a) This exercise relies heavily on generating random observations. To make this reproducible we will set a seed for the randomization. Alter the following code to make birthday store your birthday in the format yyyymmdd. For example, William...
NEED HELP WITH PART B
following commands in R computes 5000 simulations of and sample means of size 12 from a normal distribution with mean μ-100 standard deviation ơ--14 require(fastR2) nsamplesum <-do (5000) c(sample.mean-mean(rno * c(sample.mean-mean (rnorm (12,100,14))) The following commands compute the approxim ate mean and standard distribution of the sample mean. sample mean and plot the histogram giving the approximate mean (sample.mean, data-nsamplesum) sd( sample.mean, data-nsamplesum) gf .dhistogram( sample.mean, data- nsamplesum, bins (a Compare the approximate values of...
Generate a random sample of 20,000 x values (based on a sample of size 30) from a Normal distribution with a mean of 26 and a standard deviation of 5. Be sure to use 30116 as your seed. Find the approximate mean and standard deviation of the sampling distribution of the sample means (x) based on your simulation. No credit will be awarded for responses that do not include R code and output.
R codeing simulation
For n = 20, simulate a random
sample of size n from N(µ, 2 2 ), where µ = 1. Note that we just
use µ = 1 to generate the random sample. In the problem below, µ is
an unknown parameter. Plot in different figures: (a) the likelihood
function of µ, (b) the log likelihood function of µ. Mark in both
plots the maximum likelihood estimate of µ from the generated
random sample
(2) For n-20,...
Generate a population of size N= 10000 from an exponential distribution with mean θ= 10. a. Generate 1000 samples of sizen= 200 from the population and plot the density of the sample means. b. Generate a single sample of sizen= 200. Resample with sizen= 200 with replacement fromthis single sample 1000 times. Plot the density of the resample means. c. Comment on the two densities you have plotted
# 3. The following code draws a sample of size $n=30$ from a chi-square distribution with 15 degrees of freedom, and then puts $B=200$ bootstrap samples into a matrix M. After that, the 'apply' function is used to calculate the median of each bootstrap sample, giving a bootstrap sample of 200 medians. "{r} set.seed (117888) data=rchisq(30,15) M=matrix(rep(0,30*200), byrow=T, ncol=30) for (i in 1:200 M[i,]=sample(data, 30, replace=T) bootstrapmedians=apply(M,1,median) (3a) Use the 'var' command to calculate the variance of the bootstrapped medians....
What is the code and result in Rstudio or R
1. Suppose we have a random sample 1.12, 0.44, -1.49, 0.02, 0.81, -1.34,1.34, 0.51,-0.12, 0.97. (a). Use two methods to find the sample mean (b). Use two methods to find the sample variance. (c). Find the sample standard deviation. 2. We can use function rt(n 100, df 2) to generate a random sample from a t-distribution with two degrees of freedom. The sample size is n 100. (a). Generate a...