Question

In: Statistics and Probability

R-question Set the random number generation seed to the value 1234. Draw a sample of size...

R-question

Set the random number generation seed to the value 1234. Draw a sample of size 11 fromExp(λ = 0.097) and find the mean get-better time in this sample. Repeat this process for a total of 10000 get-better averages and store these values in the variables gbas. Typically, we would make a histogram of the values, but R has a nice function that will draw a smooth representation of the histogram: plot(density(gbas)). Plot this. We now know that the normal model is not the best fit for this sampling distribution. To convince yourself of this, figure out how to draw a normal distribution (in red) atop the existing plot. You should be able to figure out what the mean and spread of the normal distribution would be if H0 is assumed to be true. Include your code and a sketch of the graph.

Solutions

Expert Solution

The mean of Exp(0.097) is

the standard deviation is

The mean of sampling distribution of mean is

the standard error of mean for a sample of size n=11 is

Uisng the central limit theorem we know that the sampling distribution of mean for a sample of size n will tend towards normal distribution as the sample size increases. But for n=11, normal distribution with mean and standard deviation is not yet a good fit.

The R code (all statements starting with # are comments)

#set the sample size
n<-11
#set the total number of samples
r<-10000
#set the value of lambda
lambda<-0.097
#Draw n*r random numberd from Exp(lambda)
x<-rexp(n*r,lambda)
#transform x to a matrix of n rows and r columns
x<-matrix(x,nrow=n,ncol=r)
#get r averages for samples of size n and store in gbas (gbas has r averages)
gbas<-apply(x,2,mean)
#plot the histogram
plot(density(gbas),xlab="Sample Mean",main="Histogram of sample means")
#hypothesized mean (mean of Exp(0.097))
mu<-1/lambda
#standard deviation of Exp(0.097)
sigma<-1/lambda
#hypothesized standard error of mean
se<-sigma/sqrt(n)
#fit a normal pdf on to the plot
xfit<-seq(min(x),max(x),length=1000)
lines(xfit,dnorm(xfit,mean=mu,sd=se),col="red",lty=2)
legend("topright",c("sample means","normal pdf"),col=c("black","red"),lty=c(1,2))

# get this output

We can see that the normal model is not the best fit for this sampling distribution.


Related Solutions

<< Using R code >> Set seed number as "12345" every time you generate random numbers....
<< Using R code >> Set seed number as "12345" every time you generate random numbers. For each answer, use # to explain if necessary. 2) Generate a data.frame "D" with 3 variables. The 1st variable "v1" has 50 number of N(5,3^2) (normal with mean 5, standard deviation 3) The 2nd variable "v2" has 50 number of exp(5) (exponential with parameter 5) The 3rd variable "v3" has 50 random characters from lower case alphabets. 2-1) Rename the variable from "v1",...
How to draw a simple random sample of size 9 and a systematic sample of size...
How to draw a simple random sample of size 9 and a systematic sample of size 9 from 45 samples size. can you explain the steps for each selected sample for me . thanks
Using R Studio Now, set the seed to 348 with `set.seed()`. Then take a sample of...
Using R Studio Now, set the seed to 348 with `set.seed()`. Then take a sample of size 10,000 from a normal distribution with a mean of 82 and a standard deviation of 11. (a) Using sum() on a logical vector, how many draws are less than 60? Using mean() on a logical vector, what proportion of the total draws is that? How far is your answer from pnorm() in 1.1 above? ```{R} set.seed(348) x=rnorm(10000,82,11) sum(ifelse(x<60,1,0)) mean(ifelse(x<60,1,0)) pnorm(60,82,11) Using sum() function...
The number of successes and the sample size are given for a simple random sample from...
The number of successes and the sample size are given for a simple random sample from a population. Use the one-proportion z-interval procedure to find the required confidence interval. n = 76, x = 31; 98% level 0.298 to 0.518 0.276 to 0.540 0.297 to 0.519 0.277 to 0.539 Use the one-proportion z-interval procedure to find the required confidence interval. A researcher wishes to estimate the proportion of adults in the city of Darby who are vegetarian. In a random...
<<Using R code>> Set seed nuumber as 12345" every time you generate random numbers. For each...
<<Using R code>> Set seed nuumber as 12345" every time you generate random numbers. For each anser, use # to explain if necessary. 3. Use data "thusen" in ibrary ISwR" 3-1) Remove missing observations in the data, name this set as thu1, and print the first 6 and last 6 observations. 3-2) Rename a variable "short.velocity" -> "x", "blood.glucose" -> "y". 3-3) Draw a scatter plot for "y" by "x", give title "velocity vs.glucose". Put tick marks of x-axis at...
We draw a random sample of size 49 from a normal population with variance 2.1. If...
We draw a random sample of size 49 from a normal population with variance 2.1. If the sample mean is 21.5, what is a 99% confidence interval for the population mean?
We draw a random sample of size 36 from a population with standard deviation 3.2. If...
We draw a random sample of size 36 from a population with standard deviation 3.2. If the sample mean is 27, what is a 95% confidence interval for the population mean? [26.7550, 28.2450] [25.9547, 28.0453] [25.8567, 28.1433] [26.8401, 27.1599]
We draw a random sample of size 36 from a population with standard deviation 3.2. If...
We draw a random sample of size 36 from a population with standard deviation 3.2. If the sample mean is 27, what is a 95% confidence interval for the population mean?
in R. Generate a random sample of size 700 from a gamma distribution with shape parameter...
in R. Generate a random sample of size 700 from a gamma distribution with shape parameter 8 and scale parameter 0.1. Create a histogram of the sample data. Draw the true parametric density (for the specified gamma distribution) on the histogram. The curve for the density should be red. (Note: The “true parametric density” is the distribution from which the sample values were generated. It is NOT the kernel density that is estimated from the data.)
A random sample of size n = 2 is chosen without replacement from the set{ 1...
A random sample of size n = 2 is chosen without replacement from the set{ 1 , 2 , 3 } . X = 0 if the first number is even, and X = 1 if the first number is odd. Y = 0 if the second number is even, and Y = 1 if the second number is odd. a) List all of the samples. (b) Find the joint distribution of X and Y. (c) Are X and Y...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT