Question: I'm auditing online class The question was to Use a Monte Carlo simulation to corroborate that the t statistic comparing two means and obtained with

I'm auditing online class

The question was to Use a Monte Carlo simulation to corroborate that the t statistic comparing two means and obtained with normally distributed (with mean 0 and some sd) follows a t distribution

Please explain the code below and tell how it confirms that the t statistic follows t distribution. BTW, what is t distribution?

Ns<-seq(5,30,5)

B <- 1000

mypar(3,2)

LIM <- c(-4.5,4.5)

for(N in Ns){

ts <- replicate(B,{ x <- rnorm(N) y <- rnorm(N) t.test(x,y, var.equal = TRUE)$stat })

ps <- seq(1/(B+1),1-1/(B+1),len=B)

qqplot(qt(ps,df=2*N-2),ts,main=N, xlab="Theoretical",ylab="Observed", xlim=LIM, ylim=LIM)

abline(0,1)

The next question is: Consider the sample median as an example. Use a Monte Carlo to determine which of the following best approximates the median of a sample taken from normally distributed population with mean 0 and standard deviation 1. How is the median distributed. I'd like both theoretical and code if possible but if you do one, I prefer theoretical. How is sample median distributed and how do you show it?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!