Working data will be in C:\Program Files\sp2000\users\default\_Data # This exercise is based on Example 1.4.1 in Lehmann. > binomsamp_function(n,p,a,b) + {x_rbinom(1000,n,p) + (a+x)/(a+b+n) + } > s50_binomsamp(50,.2,1,1) > length(s50) [1] 1000 > s50[1:10] [1] 0.2115384615384615 0.1538461538461538 0.1538461538461538 [4] 0.1730769230769231 0.1730769230769231 0.2692307692307692 [7] 0.2307692307692308 0.1538461538461538 0.2307692307692308 [10] 0.1923076923076923 > s200_binomsamp(200,.2,1,1) > s1000_binomsamp(1000,.2,1,1) > bias_c(mean(s50),mean(s200),mean(s1000))-.2 # The bias variable is an estimate of the true bias, # based on a random sample of size 1000. > bias [1] 0.0105192307692305900 0.0018316831683166940 0.0008922155688623479 > variance_c(var(s50),var(s200),var(s1000)) # The variance variable is an estimate of the true variance, # based on a random sample of size 1000. > variance [1] 0.0028905351357274420 0.0007597809553500175 0.0001660354582892740 > n_c(50,200,1000) > n [1] 50 200 1000 > bias*n [1] 0.5259615384615293 0.3663366336633389 0.8922155688623479 > bias*n^2 [1] 26.29807692307646 73.26732673266778 892.21556886234780 > bias*sqrt(n) [1] 0.07438219409789129 0.02590391178603990 0.02821433361467825 # Bias seems to be of order 1/n or 1/root(n), certainly not of # order 1/n^2. > variance*n [1] 0.1445267567863721 0.1519561910700035 0.1660354582892740 > variance*n^2 [1] 7.226337839318605 30.391238214000700 166.035458289274000 # Variance seems to be of order 1/n, certainly not 1/n^2. >