title: Exclude one fixed variable in "for" loop
body: <p>I have for example 1 response variable, <code>Y</code> and 5 predictors, <code>X1-X5</code>.
  I am trying to fit a glm model and calculating the deviance difference with <code>X5</code> fixed in the model as follows  </p>
  
  <pre><code>ind_var &lt;- names(dat)[substr(names(dat),1,1)=="X"]
  results &lt;- data.frame()
  for (i in ind_var)
  {
  glm1 &lt;- glm(as.formula(paste("Y~X5+",i)), family=binomial, data=dat)
  dDeviance &lt;- with(glm1,(null.deviance-deviance))
  df &lt;- data.frame(ind_var=i, diff=dDeviance)
  results &lt;- rbind(results, df)
  }
  </code></pre>
  
  <p>Question : </p>
  
  <p>1) How to exclude <code>X5</code> when the loop is selecting <code>i</code></p>
  
  <p>2) How to insert fixed variable in the model (here is <code>X5</code>). I noticed that when I paste <code>X5</code> in the model like above, the result is incorrect. Here, I do it manually to check the model with paste function, you can see that there is only 1 coefficient with 99 <code>df</code>. I believe in normal model with <code>Y~X5+X1</code> I should have 3 coefficients (including intercept) with 97 <code>df</code>. </p>
  
  <pre><code>mod1 &lt;- glm(as.formula(paste("Y~X5+",X1)), family=binomial, data=dat)
  mod1 
  
  Call:  glm(formula = as.formula(paste("Y~X5+", X1)), family = binomial, 
  data = dat)
  
  Coefficients:
   X5  
  0.02581  
  
  Degrees of Freedom: 100 Total (i.e. Null);  99 Residual
  Null Deviance:      138.6 
  Residual Deviance: 138.6        AIC: 140.6
  </code></pre>
  
  <p>Any suggestions is highly appreciated.    </p>