# # 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. # #----- library(ElemStatLearn) # loads the data frame SAheart # The largest and smallest model we would consider (all possible variables): # m_Largest = glm( chd ~ sbp + tobacco + ldl + famhist + obesity + alcohol + age, family=binomial(), data=SAheart ) m_Smallest = glm( chd ~ 1.0, family=binomial(), data=SAheart ) stepped_model = step( m_Largest, scope=list(lower=~+1, upper=~sbp + tobacco + ldl + famhist + obesity + alcohol + age), direction="backward", data=SAheart ) print( stepped_model )