Calculating estimates for stratified random samples


Here is some R code that finds the stratified estimator of the population mean under simple random sampling and an estimate of its standard deviation.

First I call a simple population with two strata. They are stratum a of size 5 and stratum b of size 7. Next I let you see the names of the columns in X and then I print all of X. I then use the split command which makes it easy to deal with the strata. In R terminology foo is a list where each element of the list is a stratum. The sapply command allows one to find the size of the strata and the strata means. Next I get boxplots of the strata. The next few lines lets me find a random sample of size 2 from stratum a and size 3 from stratum b. I then use the sapply command to find the strata means for the sample. Next I get the point estimate of the population mean. Next I find the estimated variance of our estimate and its standard error. Finally I find an approximate 95% confidence interval for the mean. Note this makes no sense here but it is included for completeness.

These commands should help you do HW assignment 4. Note for some of the bigger problems you will not want to look at all of X.

External Data Entry

Enter a Dataset URL :

Remeber the populations from the text are in a password protected directory.