I have written code for a complex 2 staged sample in R, I want to compare mean estimates of the results from this code to other methods however, it is not a function or a dataset, simply code that creates the results. I have pasted the 2nd stage part my code which is being produced for multiple sample sizes, I want to complete the simulation w replication. I have attached code. Thanks for your help.
library(devtools)
source_gist(6424112)
en_min<-15
en_max<-100
SSS <- matrix(c(rep(0,2*(en_max-en_min+1))),2,(en_max-en_min+1))
ps_min=2
psmax=13
for (ps in ps_min:psmax) {
nabida<-merge(hoto,catte,by="Invoice..")
ratatabin<-as.data.frame(table(pframe$Invoice..))
shestamar<-as.data.frame(table(nabida$Invoice..))
colnames(shestamar)[1]<-c("Invoice..")
rotodoto<-merge(nabida,shestamar,by="Invoice..")
beg2ndb<-stratified(rotodoto[order(rotodoto$Invoice..),], group = "Invoice..", size=ps)
lutut<-as.data.frame(table(beg2ndb$Invoice..))
colnames(lutut)[1]<-c("Invoice..")
colnames(shestamar)[1]<-c("Invoice..")
wytiq<-merge(beg2ndb,lutut,by="Invoice..")
wytiq$secondselection<-wytiq$Freq.y/wytiq$Freq.x
wytiq
wytiq$finalweight<-(1/wytiq$secondselection)*wytiq$samwt
wytiq
en<-nrow(wytiq)
ssuest<-sum(wytiq$finalweight*wytiq$COMMISSION..Profit.Ratio.)
Tcritssu=qt(0.95, en-1)
twatiri<-nrow(pframe)
lestamasia<-((twatiri-en)/(twatiri-37))**(((twatiri-37)/((twatiri-en)*((en/37)**2))))
ssuest-Tcritssu*sqrt(lestamasia*variance_ssupr)
hetadan<-ssuest-Tcritpsu*sqrt(lestamasia*variance_psupr)
SSS[1,en-(en_min-1)]=en
SSS[2,en-(en_min-1)]=ssuest-Tcritpsu*sqrt(lestamasia*variance_ssupr)
}