title: Comparing percent change of model coefficients
body: <p>I am working through step 3 of purposeful model-building from Hosmer-Lemeshow and it suggests to compare the percent change in coefficients between a full model [Iris.mod1] and a reduced model [Iris.mod2]. I would like to automate this step if possible.</p>
  
  <p>Right now I have the following code:</p>
  
  <pre><code>#Make species a binomial DV
  iris = subset(iris, iris$Species != 'virginica')
  iris$Species = as.numeric(ifelse(iris$Species == 'setosa', 1, 0))
  
  #Build models
  Iris.mod1 = glm(Species~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width, 
  data = iris, family = binomial())
  
  Iris.mod2 = glm(Species~Sepal.Length+Petal.Length, data = iris, family = 
  binomial())
  </code></pre>
  
  <p>The dataset I am actually using has about 93 variables and 1.7 million rows. But I am using the iris data just for this example.</p>
  
  <pre><code>#Try to see if any coefficients changed by &gt; 20%
  paste(names(which((summary(Iris.mod1)$coefficients[2: 
  (nrow(summary(Iris.mod1)$coefficients)),1] - 
  (summary(Iris.mod2)$coefficients[2: 
  (nrow(summary(Iris.mod2)$coefficients)),1]/
  (summary(Iris.mod1)$coefficients[2:nrow(summary(Iris.mod1)$coefficients)),1] 
  &gt; 0.2 == TRUE)))))
  </code></pre>
  
  <p>However, this code is full of errors and I am lost in a sea of parenthesis.</p>
  
  <p>Is there an efficient way to determine which variables coefficient changed by more than 20%? </p>
  
  <p>Thank you in advance.</p>