Logistic Regression R I am learning R.  This is from the book "R for Everyone" by Jared Lander.  I was learning logistic regression on some housing data.
The code below came from the book:
acs <- read.table("http://www.jaredlander.com/data/acs_ny.csv",
              sep = ",", header = TRUE, stringsAsFactors = FALSE)
acs$Income <- with(acs, FamilyIncome >= 100000)
income1 <- glm(formula = Income ~ HouseCosts +   # logical regression
             NumWorkers + OwnRent + NumBedrooms + FamilyType,
           data = acs, family = binomial(link = "logit"))

I then tried to apply the model result back into the data "acs".
library(modelr)       # apply the model to data
X <- model_matrix(data = acs, formula = Income ~ HouseCosts +   
           NumWorkers + OwnRent + NumBedrooms + FamilyType)
Xmatrix <- as.matrix(X)
beta <- as.matrix(coef(income1), nrow = ncol(Xmatrix), ncol = 1)

library(arm)
probY <- invlogit(Xmatrix %*% beta)

In sampling "Income", it shows the two rows with income of $99,900 and $ 100,000.
acs[2858:2859, "Income"]
But the result of applying model shows probability of 0.4960143 0.2282368.
probY[2858:2859]
Why the lower income row has higher probability of >= $100,000?
 A: First of all you could take predictions from the glm model directly with income1$fitted.values.
Then use a confusionMatrix function from caret package to investigate performance of your model. There is almost always some imperfection between reality and a statistical model. Here you see that statistics for the model is for sure not a perfect one. That is why we should expecting some mismatches.
# income1$fitted.values is equal to probY
all.equal(as.numeric(probY), as.numeric(income1$fitted.values))

caret::confusionMatrix(factor(as.logical(round(income1$fitted.values))),factor(acs$Income))


The confusion matrix:
Confusion Matrix and Statistics

          Reference
Prediction FALSE  TRUE
     FALSE 10598  3640
     TRUE   2591  5916
                                          
               Accuracy : 0.726           
                 95% CI : (0.7202, 0.7318)
    No Information Rate : 0.5799          
    P-Value [Acc > NIR] : < 2.2e-16       
                                          
                  Kappa : 0.4291          
                                          
 Mcnemar's Test P-Value : < 2.2e-16       
                                          
            Sensitivity : 0.8035          
            Specificity : 0.6191          
         Pos Pred Value : 0.7443          
         Neg Pred Value : 0.6954          
             Prevalence : 0.5799          
         Detection Rate : 0.4659          
   Detection Prevalence : 0.6260          
      Balanced Accuracy : 0.7113          
                                          
       'Positive' Class : FALSE           
```

