How to test  a logistic regression model developed on a training sample on the data left out using R? I have the summary of a logistic regression output in R.  I used training data to make the model. 


*

*How do I test the logistic regression model developed on the training data on the data left out?


My naive guess is to create a function then run each test same through that (not even sure how do pull that) but I have to imagine there's a better way.  
 A: You may want to take a close look at the caret package which has a lot of support for this type of analysis.  Its four vignettes give a good overview of how it can help you with this.
A: You can use predict() for that. You need the model fitted to the training data, and the data from your test group. With type="response", you'll get the predicted probabilities, the default is the predicted logits.
# generate some data for a logistic regression, all observations
x    <- rnorm(100, 175, 7)                     # predictor variable
y    <- 0.4*x + 10 + rnorm(100, 0, 3)          # continuous predicted variable
yFac <- cut(y, breaks=c(-Inf, median(y), Inf), labels=c("lo", "hi"))    # median split
d    <- data.frame(yFac, x)                    # data frame

# now set aside training sample and corresponding test sample
idxTrn <- 1:70                                 # training sample
idxTst <- !(1:nrow(d) %in% idxTrn)             # test sample -> all remaining obs
# if idxTrn were a logical index vector, this would just be idxTst <- !idxTrn

# fit logistic regression only to training sample
fitTrn <- glm(yFac ~ x, family=binomial(link="logit"), data=d, subset=idxTrn)

# apply fitted model to test sample (predicted probabilities)
predTst <- predict(fitTrn, d[idxTst, ], type="response")

Now you may compare the predicted probabilities against actuall class values however you like. You may set a threshold for categorizing the predicted probabilities, and compare actual against predicted category memberships.
> thresh  <- 0.5            # threshold for categorizing predicted probabilities
> predFac <- cut(predTst, breaks=c(-Inf, thresh, Inf), labels=c("lo", "hi"))
> cTab    <- table(yFac[idxTst], predFac, dnn=c("actual", "predicted"))
> addmargins(cTab)
      predicted
actual lo hi Sum
   lo  12  4  16
   hi   5  9  14
   Sum 17 13  30

Note that the dataframe supplied to predict() needs to have the same variable names as the df used in the call to glm(), and the factors need to have the same levels in the same order. If you're interested in k-fold cross validation, have a look at the cv.glm() function from package boot.
