Comparing output from Rcapture() with glm() I'm looking again at R's Rcapture package using the example given in https://hrdag.org/tech-notes/basic-mse.html and mirroring the results in a standard GLM. There are four columns samples in my data A, B, C and D and the best RCapture fit is [34,1,2]. Fitting this by
glm(Freq ~ C*D + A+B, family = poisson(link="log"),data=.)

almost works, the AIC is close, but is out by one degree of freedom. I'm sure Rcapture is right, but it gives a different answer to the GLM. From Rcapture I get for the first model or row in the output table
Number of captured units: 1530 

Abundance estimations and model fits for the models with the smallest BIC:
             abundance stderr deviance df     AIC     BIC infoFit
[34,1,2]        2330.8  137.2   19.738  8 106.025 143.356      OK

but one more residual d.f. from the GLM
Call:  glm(formula = Freq ~ C * D + A + B, family = poisson(link = "log"), 
    data = deaths)

Coefficients:
(Intercept)            C            D            A            B          C:D  
     6.5111      -1.8288       0.4090      -2.3261      -2.7690      -0.5358  

Degrees of Freedom: 14 Total (i.e. Null);  9 Residual
  (1 observation deleted due to missingness)

Given that the R in both cases is most likely correct, what is my statistical error in my application of log-linear modelling to this problem?
 A: I found the example compelling, so after reading it I took a look at the J. Stat. Softw. paper that describes models implemented in the Rcapture package.
All Rcapture models have a component to account for heterogeneity in capture probabilities.
You are trying to reproduce the Poisson $M_t$ model since you are using the closedpMS.t function with h = "Poisson" option. The t subscript denotes temporal effect: the capture probabilities to vary among captures (these are the A, B, C and D variables).
For this model, the heterogeneity column in the design matrix is $2^{\sum\omega_j} - 1$. If you add this column to the data and the formula, you will reproduce the deviance, the residual degrees of freedom and the AIC. (The BIC is different though. Why?)

Update about the BIC. I figured out how Rcapture computes it though I don't understand yet why it is computed this way. Maybe it could be a follow-up question.
We know that the formula for the BIC is -2 x log_likelihood + log(sample_size) x num_parameters. The difference between the BIC reported by glm and the BIC reported by Rcapture boils down to what's the sample size.
# Data from the HRDAG org
library("Rcapture")

A <- c(rep(0, 8), rep(1, 8))
B <- rep(c(rep(0, 4), rep(1, 4)), 2)
C <- c(rep(c(0, 0, 1, 1), 4))
D <- c(rep(c(0, 1), 8))

# killings in Guatemala's Ixil counties, April 1982 - July 1983
# NB: these are *all killings*, NOT filtered by perpetrator
Freq <- c(NA, 1021, 104, 94, 55, 54, 2, 4, 53, 98, 19, 11, 4, 8, 1, 2)
deaths <- as.data.frame(cbind(A, B, C, D, Freq))

fit1 <- closedpMS.t(deaths, dfreq = TRUE, h = "Poisson")
fit1
#> 
#> Number of captured units: 1530 
#> 
#> Abundance estimations and model fits for the models with the smallest BIC:
#>              abundance stderr deviance df     AIC     BIC infoFit
#> [34,1,2]        2330.8  137.2   19.738  8 106.025 143.356      OK

num_captures <- A + B + C + D
deaths$heterogeneity <- 2^(num_captures) - 1

fit2 <- glm(
  Freq ~ C * D + A + B + heterogeneity,
  family = poisson,
  data = deaths
)
broom::glance(fit2)
#> # A tibble: 1 × 8
#>   null.deviance df.null logLik   AIC   BIC deviance df.residual  nobs
#>           <dbl>   <int>  <dbl> <dbl> <dbl>    <dbl>       <int> <int>
#> 1         4233.      14  -46.0  106.  111.     19.7           8    15

Now let's compute the BIC, two ways.
# The first frequency is NA. It corresponds to the un-captured individuals.
y <- Freq[-1]
mu <- fit2$fitted.values

# The log-likelihood is Poisson.
log_likelihood <- sum(dpois(y, mu, log = TRUE))

N <- sum(y) # number of captured individuals
n <- length(y) # number of capture "histories"
k <- length(fit2$coefficients) # number of model parameters

-2 * log_likelihood + log(n) * k # GLM BIC
#> [1] 110.9813
-2 * log_likelihood + log(N) * k # Rcapture BIC
#> [1] 143.3561

