{'fraction_non_alphanumeric': 0.03241987923827218, 'fraction_numerical': 0.018671620993961913, 'mean_word_length': 4.65221043788722, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Estimation of the number of irregular foreigners in Poland using non-linear count regression models

Population size estimation requires access to unit-level data in order to correctly apply capture-recapture methods. Unfortunately, for reasons of confidentiality access to such data may be limited. To overcome this issue we apply and extend the hierarchical Poisson-Gamma model proposed by Zhang (2008), which initially was used to estimate the number of irregular foreigners in Norway. The model is an alternative to the current capture-recapture approach as it does not require linking multiple sources and is solely based on aggregated administrative data that include (1) the number of apprehended irregular foreigners, (2) the number of foreigners who faced criminal charges and (3) the number of foreigners registered in the central population register. The model explicitly assumes a relationship between the unauthorized and registered population, which is motivated by the interconnection between these two groups. This makes the estimation conditionally dependent on the size of regular population, provides interpretation with analogy to registered population and makes the estimated parameter more stable over time. In this paper, we modify the original idea to allow for covariates and flexible count distributions in order to estimate the number of irregular foreigners in Poland in 2019. We also propose a parametric bootstrap for estimating standard errors of estimates. Based on the extended model we conclude that in as of 31.03.2019 and 30.09.2019 around 15,000 and 20,000 foreigners and were residing in Poland without valid permits. This means that those apprehended by the Polish Border Guard account for around 15-20% of the total.

1. Introduction. The demand for reliable estimates of the number of foreigners residing in a given country on a permanent and temporary basis as well as those that are part of the working population is expressed at various levels, including the central government, as well regional and local authorities. Information about the demographic, social and economic characteristics of foreigners is particularly important for the implementation of population, migration and economic policies. Another important issue is the Keywords and phrases: capture-recapture, population size estimation, irregular migration, truncated Poisson and negative binomial scale of unregistered / irregular immigration 1 , i.e. remaining outside the administrative systems. There is currently no reliable and direct data source that would provide reliable information in this respect.
Determining the number of foreigners, including unregistered immigrants, is an important methodological challenge for official statistics. First, administrative registers provide information about the de iure (registered) population, while statistics are interested in the de facto (registered and unregistered) population. Secondly, foreigners constitute a hard-to-reach population, i.e. one that cannot be easily estimated using traditional statistical methods. This is because there is no available (exhaustive) sampling frame/list and it is difficult to obtain information from individual units . While some characteristics of hard-to-reach populations can be determined by collecting survey data (for example, the selection of units for a sample can be done using the snowball method and its extension -Respondent Driven Sampling), the task of estimating the size of such a population poses a methodological challenge.
A number of appropriate statistical methods for estimating population sizes based on capture-recapture techniques have been proposed in the literature (for a recent review see Böhning, Bunge and van der Heijden, 2017). We can categorise these approaches into two groups: the first one includes those based on a single data source (cf. Van Der Heijden et al., 2003;Böhning and van der Heijden, 2009) and the second -on at least two data sources (cf. Van der Heijden et al., 2012;Coumans et al., 2017). The effective use of these techniques in practice largely depends on the availability of statistical data and is restricted by the need to meet certain assumptions underlying the individual methods. Dual or triple system capture-recapture methods require access to unit-level data (e.g. in order to calculate recapture counts) and are based on certain assumptions, which it may be difficult to meet in practice.
However, in practice it is often only possible to obtain aggregated data owing to privacy and sensitivity restrictions. For instance, Statistics Poland does not have access to individual data from police or Border Guard records. In such situations one can apply the residual method (Passel, 2007;Hanson, 2006), single-source capture-recapture based on distributional assumptions about count data (cf. Böhning et al., 2019) or models developed for correcting under-reporting as proposed by Bailey et al. (2005); de Oliveira, Loschi and Assunção (2017); Stoner, Economou and Drummond Marques da Silva (2019). The first and most common method applied in economics, for instance by the Pew Research Center (Pew Research Center, 2019a), is the residual method, where the size of the unauthorized population is calculated as the difference between the total number of foreigners, non-citizens (e.g. from census data) and that of authorized non-citizens (e.g. from register data). Single source capture-recapture based are more restrictive and is biased in presence heterogeneity and contamination (dependence between captures). To overcome these issue zero-truncated one-inflated distribution was proposed by Godwin and Böhning (2017) and proved to be equivalent with zero-one truncated distributions (Böhning et al., 2019). The latter method involves joint modelling of the binary indicator or proportion of under-reporting and observed counts. It also requires a set of strong covariates for each equation and instrumental variables that are connected only with one of these processes.
In this paper we take a different approach, which was initially proposed by Zhang (2008) in an unpublished working paper. The model is based solely on aggregated data, with the assumption of a non-linear relationship between the registered and unregistered population under a Gamma-Poisson mixed model. The method requires three data sources: 1) observed irregular population (e.g. apprehensions), 2) foreigners listed in police registers (e.g. criminal charges), and 3) known legal population (e.g. from the population register). In the original paper, Zhang (2008) used the following datasets for Norway: (1) foreigners who did not have a valid permit for staying in the country, determined on the basis of expulsion requests at the Norwegian Directorate of Immigration (further divided into those who had applied for asylum and those who had not), (2) foreign citizens who faced criminal charges, and (3) foreign-born persons aged 18 and over, registered in the Central Population Register. The main limitation of this method is the fact that some countries (e.g. UK, USA) do not have a central population register.
In this study, we critically assess, reuse and extend this model by including demographic covariates and different distributions of counts to estimate the number of of irregular foreigners in Poland. The structure of the paper is as follows. Section 2 provides a description of the situation in Poland, basic definitions of concepts referred to in the paper and data sources used for the estimation. Section 3 describes assumptions of the approach proposed by Zhang (2008), the model, its critique and extension, including bootstrap MSE estimation. Section 6 offers a verification of the assumptions given the available data and estimation results. The paper ends with conclusions and discussion. All codes and data used in the paper are available in the supplementary materials Supplement A.

The population of irregular foreigners in Poland.
2.1. Basic definitions. The population of unauthorized immigrants is not only hard to reach but also hard to define. To start with, a foreign-born person can be classified using three characteristics Zhang (2008): • entry status: legal or illegal, • residence status: legal, quasi-legal, temporary or illegal, • working status: legal, illegal or no-work.
The exact definition of these categories will vary across countries and over time, as a result of the dynamism and intricacies of immigration laws. In the paper we focus on the residence status.
In the EU context, the term irregular migrant refers to a third-country national present on the territory of a Schengen State who does not fulfil, or no longer fulfils, the conditions of entry as set out in the Regulation (EU) 2016/399 (Schengen Borders Code) or other conditions for entry, stay or residence in that EU Member State.
Pew Research Center (2019b), which provides estimates of the irregular population calculated by applying the residual method, uses the following definition in the EU context: "Unauthorized immigrants in this report are people living without a residency permit in their country of residence who are not citizens of any European Union or European Free Trade Association (EFTA) country. The unauthorized population also includes those born in EU-EFTA countries to unauthorized immigrant parents, since most European countries do not have birthright citizenship. Finally, the European unauthorized immigrant population estimate includes asylum seekers with a pending decision." According to Eurostat (2019) in 2019, "627,900 non-EU citizens were found to be illegally present in the EU-27. This was up 9.7% compared with one year before (572,200), but down 69.9 % when compared with the record level of 2015, when that number present stood at 2,085,500". EU Member States with the largest numbers of non-EU citizens found to be illegally present in 2019 included Germany (133,500), Greece (123,000), France (120,500) and Spain (62,900), which together accounted for 70.1% of all non-EU citizens found to be illegally present in the EU-27. The corresponding figure for Poland in 2019 was 26,625, compared to 26,547 in 2018. Note that these statistics are based on border guard reports that will be discussed in the next section.
For administrative purposes, Polish authorities (Polish Border Guard, 2020) use the term illegal stay, which is defined as a stay which does not comply with the legal provisions describing the conditions that foreigners must meet in order to enter and stay in the Republic of Poland . More specifically, a person's stay in the Republic of Poland is regarded as illegal when a foreigner: 1. does not hold a valid visa or another valid document entitling them to enter and stay in Poland, 2. has not left the territory of Poland after their period of stay in the country has expired, 3. has crossed or attempted to cross the border illegally, 4. performs or has performed work illegally, 5. has undertaken business activity in breach of the regulations, 6. does not hold sufficient means of subsistence for the duration of their intended stay in Poland,7. is a person identified in an alert issued in the SIS (Schengen Information System) or in the national database for the purposes of refusing entry If a foreigner is found to be staying in Poland illegally, an administrative procedure is initiated whereby the person is obliged to leave the country.
The legality of a foreigner's stay in Poland can be carried out by representatives of the following agencies: • officers of the Customs Service, • officers of the Border Guard, • police officers, • authorised employees of the Office for Foreigners, • authorised employees of the Provincial Office.
Currently, there are two institutions that provide information about irregular foreigners -the Border Guard on a quarterly basis and the Office for Foreigners within the Ministry of the Interior and Administration on an annual basis. The latter provides information about the number of third country nationals ordered to leave. In this paper we focus on data obtained from the Polish Border Guard, described in the section below.
2.2.1. Polish Border Guard data. The Polish Border Guard (PBG) reports the number of irregular foreigners according to the actual place of apprehension, which includes: within the country, at airports, at the border with Ukraine, Belarus and Russia separately. In the case of airports or borders, the legal status of foreigners exiting Poland was verified, i.e. some of them were found to be irregular (e.g. exceeded their period of stay) and were ordered to leave (i.e. this number is reported by the Office for Foreigners).
Since these people were already leaving Poland, no apprehension procedure was involved. Consequently, these cases should not be taken into account while estimating the size of the unauthorized population.
Reports prepared by PBG are compiled on a quarterly basis and are broken down by sex and age. The current reporting suffers from multiple counts of the same individuals, because PBG does not normally remove duplicates from their quarterly statistics. Fortunately, at our request, the data we received from PBG had been deduplicated by accounting for information about re-apprehensions. Currently, PBG can only specify two levels -first and second or more apprehensions within a given year. In our study we focus on persons apprehended only once within the country. Table 1 presents statistics for the first and second half of 2019. In the first part of 2019 over 11,000 foreigners were found to stay in Poland illegally, with about 3,200 apprehended within the country. These figures increased in the second half: to over 14,000 and 3,500, respectively. The increase can most likely be attributed to those foreigners whose stay permit issued in the first half of the year expired. Note that most illegal foreigners were stopped while leaving Poland at the border with Ukraine, which is the main source country of non-citizens in Poland. We also note that the number of re-apprehensions is very low and follows a zerotruncated one-inflated distribution, thus limiting the possibility of applying single-source capture-recapture. KSIP) which is the main police database containing information about individuals suspected of indictable offenses, persons wanted by the police or attempting to hide their identity, and about lost or stolen property. We were given access to police records about registered individuals containing the following classifications: 1) procedural registrations, 2) criminal registrations, 3) searches for missing and wanted individuals and 4) traffic violations.
We obtained anonymised, unit-level data, containing the following variables: a pseudo-identifier (each person in the KSIP register has a unique identifier), the quarter in which the registration was made, sex, age calculated at 28 Jan 2020 (date of data compilation), whether or not the person has a personal id, citizenship, and residence status (unknown, permanent, temporary stay or unregistered). These data are presented in Table 2.
According to the police records, 24,571 foreigners were registered in the first half of 2019 and 28,453 in the second half. The increase is mainly due to the higher number of individuals who committed traffic offences, which in turn may result from more intensive police activity during summer holidays and the Christmas period. In both periods,the dataset contains a similar share of foreigners registered for permanent residence or temporary stay and those unregistered but there are differences in the categories of police registrations. For instance, most procedural and search registrations involved unregistered foreigners, while most traffic violations concerned registered foreigners. In general, the number of foreigners in the police register is higher than that reported by the Border Guard. 2.2.3. The registered (legal) population. A foreigner, a citizen of another EU Member State, who stays in Poland for more than 3 months, is obliged to register. Other foreigners are required to register if their stay is longer than 30 days. Since 2018, each foreigner who stays longer than 30 days and has registered, has been automatically assigned a personal identification number (PESEL), but if registration is not possible (e.g. no permanent place of residence), such a person can still apply for a PESEL number.
The PESEL register is maintained by the Ministry of Digital Affairs 2 . Table 3 presents information about foreigners in the PESEL register (holding a PESEL id) broken down by registration type: no address in Poland, temporary stay, permanent residence, deregistered 'to nowhere', temporary stay expired 3 , and residence outside Poland. According to the PESEL register, the majority of registered foreigners did not reside in Poland or their period of temporary stay expired. Moreover, in most cases, their stay was temporary. This is mainly due to the requirements that have to be met in order to qualify for permanent residence. In our study we focus on foreigners that have come for a temporary stay or permanent residence. In section 6.1 we provide exact information regarding the sub-population of foreigners analysed in our study. (2008) model. (2008) proposed a model to estimate the number of foreigners at a given time (i.e. census night, register reference point), which relies on administrative data (cf. Gerritse, 2016) but contrasts with most single-source capture-recapture studies, which use data from the whole year or a specific period to obtain counts for the models. Zhang (2008) model is based on the assumption that there is a relationship between the unauthorized and registered population, which is justified below.

Model assumptions. Zhang
Let M t be the size of the population of unauthorized residents at the time point of interest t. Let N t be the size of the known reference (proxy) population at the same time t (e.g. census night; end of the year). We use N t to denote the number of foreign-born persons over 18 who are registered, i.e. have a temporary or permanent residence permit.
M t should be regarded as a random variable and N t as a known covariate. Let f (M t |N t ) denote the conditional probabilistic distribution of M t given N t . The target parameter is the theoretical size of irregular residents, which is defined as the conditional expectation of M t given N t with respect to tering or remain in the country without a valid residence permit, which means they should be included in the irregular population. Without linking the PESEL register with other sources it is not possible to assess the quality of this variable. Note that these figures are over 10 times as high as the number of illegal stays reported by the Border Guard and thus may contain a significant number of misclassified cases.
As Zhang (2008) notes, the theoretical size is defined as the conditional expectation of a random variable, which makes it possible to get rid of the spurious variation as long as the reference population size is held fixed. The purpose of introducing N t is two-fold: (a) it serves as an explanatory variable of the irregular size M t , and (b) it provides an interpretation of the irregular size M t in analogy to N t . In this way, the theoretical size is a stable measure of the target variable as variation in M t is linked to that of N t .
Moreover, since the chosen N t is not subject to seasonal variation, neither is the theoretical ξ t . In contrast, M t defined in a more naturalistic manner can be expected to vary greatly in the course of one year, being perhaps the highest in the summer months, which is another kind of spurious variation.
There is also a sociological and economic justification for why M t depends on the regular population N t . Because irregular foreigners do not have regular job opportunities and cannot claim social and health benefits, they need a network of contacts with registered residents, who are much better off socially and economically. It is hard to imagine a completely closed community of Ukrainian or Vietnamese irregular residents in Poland. The first one is the largest immigrant group in Poland as a result of recent migration flows and the second is one of the most stable in terms of size and is confined to a relatively small area (living mainly in Warsaw and in neighbouring communes). This explains the choice of the reference population -the registered population aged 18 and over.
3.2. Zhang (2008) model. For both the target and the reference populations, let i = 1, ..., C be the index of the sub-population classified by the country of citizenship and origin, respectively. For simplicity, we drop the t index denoting the reference time. Zhang (2008) assumed that the observed number of irregular residents follows a Poisson distribution, with parameter λ i , denoted by The parameter λ i should depend on two other quantities: (a) the total number of irregular residents from country i, denoted by M i , and (b) the probability of being observed, i.e. the probability for an irregular resident to be included in Border Guard data, denoted by denotes the conditional expectation of M i p i given n i and N i . The u i is a random effect that accounts for heterogeneous variation from one country to another. Together, we obtain The final model is specified by the following set of equations where Gamma(1, φ) denotes the gamma distribution with the expectation E(u i ) = 1 and variance V (u i ) = 1/φ. Zhang uses term hierarchical Gamma-Poisson random effect model to describe 6 and derives log-likelihood function that may be found in Appendix B but we show in Appendix B.1 that it is actually Negative Binomial distribution as a special case of Poisson-Gamma mixture. Furthermore, we show in Appendix B.4 that the simplified approximation of term log Γ(x) used by Zhang (2008) leads to biased estimates of α, β and ξ.
The model has the following assumptions. First, country random variation refers only to observed apprehensions i.e. m i as µ i is scaled by u i . Second, the non-linear relationship between the regular population size N i and M i is imposed by the power function with α being the same for all the countries. Finally, there is a similar relationship, defined by the β parameter, which exists between police "catch rate" and the probability of being observed in Border Guard data.
From equations (2)-(6) we derive the following relationship that can be used to verify the model assumptions. After dividing both sides by N i and applying the log transformation we get Then, we can plug in m i and model log (m i /N i ) into the linearized model from which we should expect a negative relationship with log N i and a positive one with log(n i /N i ).
3.2.1. The target parameters. We are interested in the target parameter describing the population size of irregular residents. Given the above model, the target parameter is defined as and its estimator is given by whereα is the estimator of α.

Extensions.
A natural way of extending the above model is to include additional covariates, such as country, sex, age or place of residence to account for variability in α or/and β and including different distributions for the observed counts m tij .
Let m tij be observed counts for period i = 1, .., T , country i = 1, ..., C and domain j = 1, ..., J defined as an interaction between, e.g. sex and age. We assume that the observed counts are generated from the count distribution given (12) where Count denotes a suitable count distribution, such as Poisson, Geometric or Negative Binomial (NB2), and η is a vector of parameters for a given distribution -for Poisson: η = (µ tij ) or for NB2: η = (µ tij , φ), where µ tij is defined as in (7). Note that, by definition, µ tij > 0 is positive as we only observe apprehended foreigners from a given country and belonging to a given domain. This resembles the situation in single-source capture-recapture studies based on re-apprehensions. Thus assuming (2) will lead to underestimation estimates of the population total as shown in a limited simulation study in Appendix B.4. This results suggest that the original model proposed by Zhang (2008) may lead to biased estimates of ξ. Furthermore, zero-inflation may be presence. For instance, the study by Böhning et al. (2019) shows equivalence between zero-truncated one-inflated and zero-one truncated count distributions. Having that in mind, our extension we also consider distributions that may be zero-truncated as the one below or zero-one truncated as given by represent 0 and 1 densities and η is a vector of parameters for a given count distribution.
In our study we consider the following distributions for m tij : Poisson (PO), zero-truncated Poisson (ztPO), Negative-Binomial (NB2) and zero-truncated Negative Binomial (ztNB2), where µ is the mean and φ is the dispersion parameter. Log-likelihood functions for the models considered in the paper are given in Appendix B.
Furthermore, we extend equation (7) by including covariates where X and Z may be the same and η is estimated using the maximum likelihood method. Note that X and Z can refer to the domains defined by j, as the model uses only two covariates -population size N tij and police records to population size n tij /N tij . This is an interesting alternative to, for instance, the model proposed by Stoner, Economou and Drummond Marques da Silva (2019), which requires strong covariates for under-reporting and observed counts. Under the model (15) estimator for the target parameter given by (11) changes to

Estimating uncertainty.
5.1. Zhang (2008) proposal. In the original paper, Zhang did not calculate variance for the target parameter ξ but proposed a confidence interval for ξ by plugging in the confidence interval for α. Thus, the CI for ξ is given by where α l , α u are the lower bound and upper bound of the CI interval for α.
If we use additional covariates to explain variability in ξ we can plug in lower and upper bounds for all parameters as shown below where α l and α u are vectors with lower and upper bounds.

Parametric bootstrap.
We use an alternative approach, based on parametric bootstrapping, to estimate the mean square error, which exploits an idea similar to that proposed by González-Manteiga et al. (2008) for small area estimation. It consisting of the following steps: 1. given n i , m i and N i , calculateη using the maximum likelihood function, 2. givenη, generateη * from a multivariate normal distribution MVN(η, Cov(η)), where Cov denotes the covariance ofη. For instance, for the NB2 model we use . generate m * i from the assumed distribution using µ * = N X T α * n N Z T β * , 5. fit the model to (m * i , n tij , N tij ) and estimate η * , 6. estimateξ * = C i=1 Nα * i , 7. repeat steps 2-6 B times and calculate the bootstrap MSE estimator and Relative MSE estimator Based on bootstrapped ξ * from point 4 we calculate the confidence interval for ξ using the 95% percentile method and a method recently introduced by Liu, Gelman and Zheng (2015) called the shortest probability interval (SPIN). The latter method is recommended for asymmetric distributions, bounded variables (e.g. positive); intervals constructed using SPIN have better coverage.
6. Results. In addition, we derived data broken down by sex and economic age group (18-59 and 60+ for women; 18-64 and 65+ for men). Table 4 presents information about the number of foreigners and countries of origin present in the PESEL, police and Border Guard registers. The PESEL register contained 151 and 147 countries in the first and second half of the year, respectively, police data -around 100, and Border Guard records -around 70. The two latter sources contain a considerably greater percentage of men, in contrast to the PESEL register, where women account for around 60% of all foreigners.
The model requires that the following conditions hold: m tij > 0, n tij > 0 and n tij /N tij < 1, so we created a new dataset that meets these requirements. Countries that do not satisfy these conditions were grouped to create a pseudo-country denoted as other 4 . After applying this condition, we received a total of 73 countries (including category other ), of which 50 were Table 4 The number of foreigners and countries by data source, sex and period before applying the condition for the model observed in both periods and 23 only in one (65 in the first and 58 in the second half of 2019). The full list of countries is given in Appendix A.
6.2. Verification of the assumptions. To verify the model assumptions we investigate the relationships resulting from equation (9) and compare the log of the PESEL population with the log of Border Guard (BG) counts to the PESEL population (top) and the log of police counts to the PESEL population by country of origin (bottom) and sex in both halves of 2019. Figure 1 presents these relationships with a linear model defined in (9), which was calculated for the whole dataset, while figure 2 includes separate fits for each sex. The shapes are defined by the interaction of sex and age (working age and post-working age).
Both plots show the expected relationship, i.e. a negative correlation with the population size (less than -0.6) and a positive correlation with the proportion of police-to-PESEL counts for both quarters (over 0.7). This means that the relationship between the size of the unauthorized and registered population decreases as the registered population grows. However, there is an outlier in our population -Ukraine. Citizens of this country are the biggest immigrant group in Poland in all datasets (over 70% in the PESEL population, around 60% of BG apprehensions and close to 70% of all police registrations). Ukraine is an outlier for both sexes but not for the relationship seen within the police data. If Ukraine is excluded, the correlation with the PESEL population changes to around -0.7 while the correlation with the log of police-to-PESEL counts stays the same. In addition, the pseudo-country, denoted by UNK, is an outlier but only for males. Figure 2 presents the same relationship but separately for each sex. As can be seen, there are differences in this respect, particularly in the com- parison with the log of the PESEL population, as evidenced by the shift in the regression lines. This means that the unauthorized population mainly consists of males, in contrast to the registered (PESEL) population, which is dominated by females. A similar pattern can be observed regarding the relationship with the police data, where Pearson's correlation coefficient for both sexes is around 0.5-0.6, while without accounting for sex -around 0.7.
The above claims are also confirmed by results from fitting the linearized model given by (9). For both periods α − 1 parameter associated with log(N tij ) was equal to -0.4109 and -0.4190 indicating that the relationship with regular population is stable overtime and β for log(n tij /N tij ) was equal to 0.5694 and 0.5841.
6.3. Estimation results. Table 5 contains the main model performance measures, while additional details, including diagnostics, are presented in Appendix C. Results are broken down by quarter end, distribution and covariates used in the modelling phase. We also report AIC and BIC. As expected, truncated distributions yield better lower values of information criteria and higher values ofξ. For both periods, the Poisson and truncated Poisson distributions perform poorly and the estimated irregular population is very large. Results from Table 5 indicate that at the end of the first quarter the truncated NB2 with no covariates or with one covariate for α, i.e. Ukraine, is the best model in terms of information criteria (BIC). For the end of the third quarter, the best models also assume the NB2 distribution but the ranking of covariates is different i.e. the model that accounts for sex is the best (BIC=529.3), while the model with Ukraine as a covariate is slightly worse (BIC=531.3). The main difference between these models is the degree of uncertainty, since in the first model the confidence interval is narrower than in the second. There is no justification for such an increase between two periods, given that the regular population grew from 232,500 to 234,200 and a big change in the irregular population is unlikely. This result is mainly due to high values of α 0 , which for the truncated NB2 with sex as a covariate equals 0.875, with sex and Ukraine -0.838 and the model with Ukraine -0.673. Based on that we decided to focus on truncated NB2 models without covariates and that with Ukraine as the only covariate inα.
Estimatedα 0 ,α 1 ,β andφ are reported in Table 6. In addition we provide the Sum of Squares (in thousands) denoted by SSQ. Diagnostics for the final model are presented in Appendix C. For both quarters models with no covariates are characterised by higherα 0 andβ and the SSQ over 5 times as high as that for the models with one covariate (Ukraine,α 1 ). As expected, the parameter for Ukraine is positive but is characterised by a high standard error as we have only 4 observations for this country. Table 6 Estimated parameters for models with no covariates (no cov.) and with Ukraine as a covariate under the truncated NB2 distribution. Standard errors are reported in parenthesis. The research on irregular migration in Poland is limited. As far as we know, the only results about the unauthorized population in Poland can be found in Pew Research Center (2019b). The analysis was carried out for the period 2014-2017, and the population was estimated to be lower than 100,000, regardless of whether or not waiting asylum seekers were included Pew Research Center (2019b). In their report, Pew Research Center does not provide any point estimates or quantify the uncertainty behind this number. Thus, currently there is no other estimate that our results can be compared with 5 .

As at
To provide some context, we compare our estimates with relevant statis-tics on migration to Poland reported by the Office for Foreigners for 2019. Table 7 contains three indicators that can be connected with illegal staysnegative decisions issued to applications for temporary and permanent stay and decisions about the compulsory return of an individual to their country of origin. A foreigner who has received a negative decision is obliged to leave Poland within 30 days from the date when the decision was issued. If a foreigner does not leave Poland within this period and is apprehended, they are ordered to return. There are multiple reasons why such an order can be issued, such as illegal stay or work or being considered persona non grata 6 . The order to return is issued by the commanding officer of the Border Guard unit or the commanding officer of the locally competent Border Guard unit and most of such orders are given to foreigners who exit Poland and were identified as staying illegally (29,072 obligations in Table 7 and 25,810 in Table 1). The number of refusals concerning applications for a temporary and permanent stay is close to 36000 and is significantly higher than our estimates. This is mainly because of a variety of reasons for issuing a negative decision (e.g. not meeting requirements for a temporary stay or detention. The full list is given in Appendix D.1). Our point estimate is lower than the total number of refusals and orders to return, which suggests that the size of the unauthorized population is plausible.  Table 7 contains information about the number of irregular residents from Ukraine and by age and sex. The total in comparison to the regular population in Poland in 2019 (37.97 million) is close to 0.04% on 31 December 2019, and 0.05% on 30 September 2019 is small and plausible. Pew Research Center (2019b) reports that the irregular population for most countries is lower than 1%.
The demographic structure is also probable except for sex. Ukrainians account for over 65% the irregular population, which is similar to the percentage of refusals or return decisions for Ukrainians. Most of them are people of working age, since their motivation for migrating to Poland is mainly economic. The main problem is the sex structure. Our estimates show that the majority are females, while all other data (apprehensions, refusals, return decisions, etc.) indicate the opposite. The main reason for this result is the structure of the PESEL register, in which the majority (about 60%) are women. However, if we compare our estimate to the regular foreign population of males and females, we get 6.8% and 5.8% respectively, which indicates that males are more likely to be irregular migrants.
Finally, Table 8 contains interval estimates for the size of the irregular population using three different measures: Zhang (2008) plugin interval, the bootstrap calculated using SPIN and the percentile method. The method used by Zhang (2008) yields a very wide interval ranging from 4,000 to 67,000 at 31 March and from 4,000 to 134,000 at 30 September. The SPIN and quantile method provides similar intervals for the first period suggesting that in the first period the irregular population ranged from 7,000 to 30,000. For the second period SPIN yields a shorter interval between 6,000 and 57,000. The estimated √ mse equals 8,259 and 15,904 respectively. The SPIN method is preferred as the bootstrappedξ * are right-skewed, as shown in Figure C.2. 7. Discussion. In the paper we propose a different approach to estimate the hard-to-reach population of irregular foreigners based on a flexible non-linear count regression model. The approach is an alternative to classic capture-recapture methods based on one or multiple sources and the interpre-tation of results is more intuitive as the irregular population is conditionally dependent on the regular population. Extending the model for additional covariates and zero-truncated distributions makes it more general. That said, the proposed model has certain limitations.
The approach is based solely on the administrative data and, as a result, the quality of our estimates depends on the availability of high-quality register-based statistics. Beresewicz, Gudaszewski and Szymkowiak (2019) provided estimates of the size of the de facto population of foreigners for 2015 and 2016. The paper includes information about the co-occurrence of regular foreigners in the PESEL and two external registers maintained by the National Insurance Institution (ZUS) and the Office for Foreigners. For instance, the PESEL register data for 2016 were linked with two other sources and around 7,000 (out of 47,000) foreigners were observed exclusively in the PESEL register. This figure, however, cannot be used as a measure of overcoverage because only three sources were used. In a more recent study, Statistics Poland (2020) published a detailed analysis of foreigners based on 9 registers linked by the PESEL id. Only about 1,500 out of 2.1 million foreigners were found to be listed exclusively in the PESEL register while over 980,000 were listed only in one of the other registers. This indicates that the PESEL register is not considerably affected by overcoverage.
Because not all countries have a population register (e.g. United States or Ireland), it is possible to use population surveys, such as the Current Population Survey conducted by the US Census Bureau, or a system of integrated registers with signs-of-life methodology as in Zhang and Dunne (2018).
Selection of data for the model should be strictly connected with the definition of the irregular population used in the study. Currently, there is no information about how long apprehended foreigners have been staying in Poland, which means that this group can include a mix of persons who have been residing for a period longer than 3 months, have exceeded their temporary residence permit or have been staying without any permit. Therefore, there is a need for a close collaboration with the Border Guard. However, the model assumes a relationship between the regular and irregular population and therefore the approach can be applied to different populations, such as illegal workers or the homeless population, given the existence of register-based proxy populations and auxiliary variables. Note: In the second half of 2019, no women of post-working age (60+) were apprehended by the Border Guard, while the PESEL register contained 1,286 foreigners and police records -52. As we did not have any other group to merge with we decided to artificially add one person to the Border Guard dataset to represent this subgroup in that period. The same number of foreigners in this subgroup were apprehended in the first half year.
To simplify the notation, we will use µ i for (α, β) parameters as they are derived from Under the Poisson gamma model (6), we have As noted by Cameron and Trivedi (2013), the representation of the negative binomial distribution as a Poisson-Gamma mixture is an old result following back to Greenwood and Yule (1920) and the parametrization of the gamma function leads to different variance functions (Cameron and Trivedi, 1986). Now, based on Cameron and Trivedi (2013, pp. 117-118), we show that (23) is actually a negative binomial distribution represented as Gamma-Poisson mixture. Let κ = 1/φ and from the gamma function property Γ(m + 1) = m! we get which is an alternative parameterisation of Negative Binomial with mean µ and dispersion parameter φ. Another way to specify the Gamma-Poisson mixture as a Negative Binomial is given in Cameron and Trivedi (2013, p. 117-118) .
The likelihood using (23) is given by Thus, disregarding constant terms, the log-likelihood is given by where Zhang (2008) proposed to used the following log-likelihood function where µ i is defined as in (7) and Zhang (2008) used the Stirling's approximation given by log Γ(z) . = (z − 0.5) log(z) + 0.5 log(2π) − z. However, the exact Stirling's approximation is log Γ(z) = (z −0.5) log(z)+ 0.5 log(2π) − z + ∞ 0 2 arctan( t z ) e 2πt −1 dt and thus the log-likelihood function given in (27) is not complete and may result in biased or inefficient estimates of η. To verify this we conducted a limited simulation study involving a simplified version proposed by Zhang (2008) and compared with the exact version mentioned above. The results presented in Appendix B.4 show that Zhang (2008) proposal leads to slight bias in α, β and ξ estimates.
The MLE of η, denoted byη, is given by the solution to the likelihood equations, i.e.
The MLE can be obtained using the Newton-Raphson method with starting values obtained from the model given in (9). In this case, α and β are used as the starting values for the same parameters of the Poisson-gamma model, and the inverse of the estimated V ( i ) is used as the starting value for φ. We estimated the model using maxLik package (Henningsen and Toomet, 2011) in the R language (R Core Team, 2019). Zhang (2008) model. The mean parameter µ i is linear on the log scale, denoted by logµ i = x T i γ with generic vector of covariates x i and parameters γ. Now that l i (η) depends on γ only through µ i , we have

B.2. Partial derivatives for
Moreover, B.3. Likelihood functions for models used in the study.
B.3.3. Negative Binomial type 2 (NB2). (36) B.3.4. zero-truncated Negative Binomial type 2 (ztNB2). (37) B.4. Limited simulation study -Stirling's approximation, zerotruncation and its impact on estimates. Zhang (2008) used Stirling's approximation of log Γ(x) that drops the integral part and the log-likelihood function in (27) is reduced. To verify whether this approach has an impact on the estimated parameters we conducted a limited simulation study using Polish data in which we compared log-likelihood using (27) (denoted as zhang), log-likelihood using (27) but log Γ(x) was calculated using the lgamma function in R (denoted as lgamma), log-likelihood using the dnbinom function in R (denoted as dnbinom) and log-likelihood for zero-truncated NB2 using dztnbinom from the actuar package in R (denoted as dztnbinom).
We set α = 0.7, β = 0.8 and considered two cases: when the dispersion parameter is low (φ = 1.5) and when it is high (φ = 2.5). We generated m i data using rnbinom with mean parametrisation, where µ i were defined as in (7). We used N i and n i for the first quarter of 2019. In each iteration (B=500) we removed cases when m = 0 to mimic Border Guard data. To assess the performance we report the following measures: • Relative bias • Relative root m square error where MSE SIM is calculated as where θ is replaced with α, β, φ and ξ. Results are presented in Table 9. The approximation used by Zhang leads to biased estimates of α, β and ξ, but for φ in both cases (low and high) the relative bias is lower than that obtained using the lgamma or dnbinom function. This means that (27) should not be used for estimating the (6) model. Furthermore, mis-specification of the distribution (NB2 instead of zero-truncated NB2) leads to underestimation of the size of the irregular population.  Cameron and Trivedi (2013, ch. 5.2.1) discuss Pearson, Deviance and Anscombe residuals to assess the quality of the model. In the paper we focus on the latter, which for the Negative Binomial is given by , where κ = 1/φ. Figure 3 and 4 present diagnostic plots for the first and the second model. Both plots contain four subplots showing comparisons of observed, fitted and Anscombe residuals calculated using (41) formulae. Residuals are skewed because of poorly fitted values for males of working age from the pseudocountry rest (414 vs 87.38), India (85 vs 28.12) and the Philippines (9 vs 1.45), and females of working age from Georgia (23 vs 5.86) in the first quarter. In the case of the second model, there were problems with males of working age from the pseudo-country rest (485 vs 121.69), Armenia (7 vs 53.05) and Tajikistan (34 vs 11.08) and females of working age from Georgia (47 vs 5.74).

APPENDIX D: DEFINITIONS OF MEASURES USED FOR THE COMPARISON
Description below is taken from the official web page of the Office for Foreigners (links: Temporary residence permit, Permanent residence permit).
D.1. The decision about the compulsory return of an individual to their country of origin. A return decision is issued when a foreigner: • resides or resided within the territory of the Republic of Poland without a valid visa or another valid document authorising him/her to enter this territory and stay within it, if a visa or the other document is or were required or • has not left the territory of the Republic of Poland after the lapse of the maximum duration of his/her stay within the territory of some or all Schengen countries to which he/she was entitled without the need for a visa for 180 days in each period, unless international agreements provide otherwise, or • has not left the territory of the Republic of Poland after the lapse using the maximum duration of his/her stay indicated in the Schengen visa within each 180-day period or after the lapse of the permissible period of stay on the basis of a national visa, or • performs or performed work without a required work permit or an employer's declaration of intention (registered in a district labour office) to employ him/her to perform work, or has been fined for illegal performance of work, or • operated an economic activity in breach of the regulations applicable in this regard within the territory of the Republic of Poland, or • does not have the financial resources necessary to cover the costs of his/her stay within the territory of the Republic of Poland, to travel back to the country of origin or residence or transit through the territory of the Republic of Poland to a third country that will grant a permission to enter and has not indicated reliable sources to obtain such funds, or • the foreigner is entered in the register of foreigners whose stay within the territory of the Republic of Poland is undesirable, or • the foreigner's data can be found in the Schengen Information System for the purposes of refusing entry if the foreigner stays within the territory of the Republic of Poland under the visa-free travel regime or under a Schengen visa, with the exception of a visa authorising only the entry and stay within the territory of the Republic of Poland, or • it is justified by national security or defence, the protection of public order and safety or the interests of the Republic of Poland, or • has crossed or attempted to cross the border in breach of legal regulations, or • has been convicted in the Republic of Poland by a final decision for a custodial sentence subject to execution, and there are grounds to conduct proceedings on his/her transfer abroad for the purpose of enforcing the penalty against him, or • resides outside the border zone in which according to the permit for crossing the border under the local border traffic, he/she may reside, unless international agreements stipulate otherwise, or • stays within the territory of the Republic of Poland after lapse of the period of stay to which he/she was entitled under a permit to cross the border under the local border traffic, unless international agreements stipulate otherwise, or • further stay of the foreigner within the territory of the Republic of Poland would be a threat to public health, which was confirmed by clinical examination, or to the international relations of another European Union Member State, or • the purpose and conditions of stay of a foreigner within the territory of the Republic of Poland are inconsistent with the declared ones, unless the legal regulations allow him/her to be changed, or • a decision on refusal to grant refugee status or subsidiary protection award or a decision to discontinue the proceedings on granting him/her refugee status was issued and he/she has not left the territory of the Republic of Poland within the deadline and in the case referred to in Article 299 (6)(2) of Act of 12 December 2013 on Foreigners.
D.2. Negative decisions for temporary or permanent stay. Foreigner shall be refused to grant temporary residence permit, if: • that person does not meet the requirements of granting temporary residence permit due to the declared purpose of the stay or the circumstances, which constitute the basis for application for the permit, do not justify his/her stay within the territory of the Republic of Poland for a period longer than 3 months, or • there is a valid entry of the foreigner to the register for foreigners, whose stay within the territory of the Republic of Poland is undesirable, or • that persons data are present in the Schengen Information System for the purposes of entry refusal, or • it is required by the State defence and security or maintenance of public order and security or obligations resulting from ratification provisions of the international agreements applying to the Republic of Poland, or • in the proceedings for granting temporary residence permit: a) that persons has made an application containing untrue personal data or false information or attached it with documents containing such data or information, or b) that person has testified untruthfully or has concealed the truth or counterfeited or forged a document in order to use it as the original or has used such a document as a original, or • that persons is in arrears of taxes, with exception of the cases when he/she has obtained a legal exemption, deferral, division of overdue amounts into instalments or the enforcement of the whole decision of a competent body has been suspended, or • that person has not returned the costs related with issuance and execution of the decision on obligation of the foreigner to return, which were covered from the State budget, or • being subject to the obligation of treatment pursuant to Article 40 (1) of the Act of 5 December 2008, on preventing and combating infections and infectious diseases among people he/she refuses to consent to treatment, or • that persons has made an application during an illegal stay within the territory of the Republic of Poland or is illegally staying within the territory.
Initiation of proceedings on granting a permanent residence permit to the foreigner is refused when on the day of submitting the application for such permit the foreigner: • Residing in the territory of the Republic of Poland: -Illegally or -On the basis of a Schengen visa authorizing only to enter the territory of the Republic of Poland, and stay in this territory that was issued for the purpose of entry for humanitarian reasons, due to the state's interest or international obligations or -On the basis of a temporary residence permit due to circumstances requiring a short stay or -On the basis of a EU long -term resident residence permit or • Is detained, placed in a guarded centre, or in detention for foreigners, or a preventive measure is applied to him/her in the form of prohibition to leave the country or • Is serving prison term or is temporarily detained or • Stays in the territory of the Republic of Poland after he/she has been obliged to return, and the period for voluntary return specified in the decision obliging the foreigner to return has not yet expired, also in the case of extension of this deadline or • Is obliged to leave the territory of the Republic of Poland in the event of refusal to grant or withdrawal of residence permit or in the event of refusal to grant or withdrawal of international protection or • Stays outside the borders of the Republic of Poland.

SUPPLEMENTARY MATERIAL
" Supplement A: R codes (doi: 10.1214/00-AOASXXXXSUPP; .pdf). R codes to reproduce all results in the paper