Hey guys. I'm new to R so I need a little help
I'm trying to check if the estimators that I'm using for a binomial distribution parameter actually tends to the actual one through a Monte Carlo simulation with 10k replications.
For that I'm basing my code in one that I found for the exponential one. First, I wanna understand the code. So here it is:
........................................................................................................................
#This file is a Monte Carlo study of the small sample
#behaviour of the sample mean estimators of the Expected value.
#and the power and size of the associated test statistics.
1000 REPLICATIONS, SAMPLE SIZES 1000, 200, 20 10
Rp<-10000 # no.of replications
sz <-1000 # sample size
#resulting matrices
TT<-matrix(0,ncol=4,nrow=Rp) # estimates matrix
TS<-matrix(0,ncol=4,nrow=Rp) # Std Err. matrix
#Simulation
for(i in 1:Rp) {
X<-rexp(sz,rate=2)
#mean estimates
TT[i,1]<-1/mean(X) #1 #equation1
TS[i,1]<-1/mean(X)^2/sz #2 #equation2
#mean estimates
TT[i,2]<-1/mean(X[c(1:200)]) #3
TS[i,2]<-(1/mean(X[c(1:200)])^2)/(200) #4
#mean estimates
TT[i,3]<-1/mean(X[c(1:20)]) #5
TS[i,3]<-(1/mean(X[c(1:20)])^2)/(20) #6
#mean estimates
TT[i,4]<-1/mean(X[c(1:10)]) #7
TS[i,4]<-(1/mean(X[c(1:10)])^2)/(10) #8
}
#bias and efficiency
#sample mean
summary(TT[,1])
summary(TT[,2])
summary(TT[,3])
summary(TT[,4])
...........................................................................................................................
I understand that it's being repeated 10k times, so each time he generates a different X, base on the sample size and the rate, to use #equation1 to estimate my parameter [E(x)] in #1. So in the column 1 of the matrix TT, is being stored those estimations. Similar thing being done for the #equation2, but for the variance estimation.
But on #3 , what does the c(1:200) means? does it means that from the sample size of 1000, hes only using 200 of those? So in that case I dont need to change the sample size, SZ, to know the estimation for different sample sizes (100,20 and 10)?