Hosmer Lemeshow Test, variable lengths differ Doing a logistic regression in R version 3.1.2 and I want to conduct a Hosmer Lemeshow test

model &lt;- glm(y ~ a + b + c + d, data = data, family = binomial)

summary(model)

Call:
glm(formula = y ~ a + b + c + d, family = binomial, 
    data = data)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.5607  -0.7642  -0.4456   0.8998   2.3812  

Coefficients:
             Estimate Std. Error z value Pr(&gt;|z|)    
(Intercept) -7.827805   1.169216  -6.695 2.16e-11

a            0.582214   0.134207   4.338 1.44e-05

b           -0.697126   0.462983  -1.506  0.13214   

c            0.027485   0.009669   2.843  0.00448 

d            0.996241   0.163006   6.112 9.86e-10

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 504.53  on 373  degrees of freedom
Residual deviance: 381.91  on 369  degrees of freedom
  (3 observations deleted due to missingness)
AIC: 391.91

Number of Fisher Scoring iterations: 5


Using the function hoslem.test from package "Resource Selection"

hoslem.test(model$y, fitted(model), g = 10)


I get the following error

Error in model.frame.default(formula = cbind(y0 = 1 - y, y1 = y) ~ cutyhat) : 
  variable lengths differ (found for 'cutyhat')


Looking at the code in the hoslem.test function, cutyhat is derived only from fitted(model) values, which I've verified contain no nas and are all integers, so why would they differ?

Pls help.
I think it could be that the model is being used and not the data, try: 

hoslem.test(data$y, fitted(model), g = 10)