# Example 1: ratio estimation of number and proportion of females # p. 38 of notes x <- c(10,18,10,12,25,15,10) y <- c(7,12,4,6,19,7,5) n <- 7 N <- 20 plot(x,y,pch=16,xlab="Number of animals",ylab="Number of females") # Estimation of proportion of females r <- mean(y)/mean(x) r sr2 <- (1/(n-1))*sum((y-r*x)^2) sr2 SE.r <- sqrt((1-n/N)*sr2/(mean(x)^2*n)) # assumes mu_x not known SE.r c(r - qt(.975,n-1)*SE.r,r + qt(.975,n-1)*SE.r) # Estimation of total number of females tau.x <- 350 # total number of animals on all 20 plots (given) tau.hat <- r*tau.x SE.tau <- sqrt(N*(N-n)*sr2/n) c(tau.hat,SE.tau) c(tau.hat - qt(.975,n-1)*SE.tau,tau.hat + qt(.975,n-1)*SE.tau)