# # Epage 143 # # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # version$language == "R" for R version$language == NULL for SPlus if(is.null(version$language) == FALSE) require(alr3) else library(alr3) if(is.null(version$language) == FALSE) data(turk0) attach(turk0) # do a quadratic OLS regression on yBar: # m2 <- lm( Gain ~ A + I(A^2) ) # we can use the ALR3 package "delta.method" (but we need to specify the parameter names correctly): delta.method(m2,"-b1/(2*b2)") # lets do the same problem via the bootstrap (first generate coefficients): # bCoefficients <- boot.case( m2, B=2000 ) # next compute the maximum: maxs <- -bCoefficients[,2]/(2*bCoefficients[,3]) print(mean(maxs)) print(sqrt(var(maxs)))