Package 'LCCR'

Title: Latent Class Capture-Recapture Models
Description: Estimation of latent class models with individual covariates for capture-recapture data. See Bartolucci, F. and Forcina, A. (2022), Estimating the size of a closed population by modeling latent and observed heterogeneity, Biometrics, 80(2), ujae017.
Authors: Francesco Bartolucci [aut, cre], Antonio Forcina [aut]
Maintainer: Francesco Bartolucci <[email protected]>
License: GPL (>= 2)
Version: 2.0
Built: 2024-11-21 03:40:16 UTC
Source: https://github.com/cran/LCCR

Help Index


Latent Class Capture-Recapture Models

Description

Estimation of latent class models with individual covariates for capture-recapture data. See Bartolucci, F. and Forcina, A. (2022), Estimating the size of a closed population by modeling latent and observed heterogeneity, Biometrics, 80(2), ujae017.

Details

The package provides functions to specify latent class models for capture-recapture data with individual covariates, simulate data from the specified model and estimate it on the basis of observed data, including the possibility to obtain a profile confidence interval for the population size.

The latent class models may be specified by a log-linear or a recursive logit parametrization of the conditional distribution of the capture configurations given the latent class. The log-linear parametrization is based on main effects that may depend on some covariates and may include bivariate interaction terms. The recursive logit parametrization allows us to model the dependence of capture probabilities on previous capture history. Linear constraints on the model parameters may be assumed to make the model more parsimonious. Covariates may also affect the latent class weights by a Multinomial logit parametrization.

Estimation of the specified model is based on the unconditional likelihood method following the approach formalized in Forcina and Bartolucci (2021), which may be seen as a refinement of the one in Liu et al. (2017). The approach uses as additional parameters the weights associated to the different strata that are estimated together with the model parameters and the population size. Functions for constructing a profile confidence interval for the population size are provided; this proceduire is recommended as an alternative to using the normal approximation.

Functions for conditional maximum likelihood estimation as described in Bartolucci and Forcina (2006) are also included in the package.

Author(s)

Francesco Bartolucci [aut, cre], Antonio Forcina [aut]

Maintainer: Francesco Bartolucci <[email protected]>

References

Bartolucci, F. and Forcina, A. (2006). Estimating the size of a closed population by modeling latent and observed heterogeneity. Journal of the American Statistical Association, 101, 786-794.

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Liu, Y., Li, P., and Qin, J. (2017). Maximum empirical likelihood estimation for abundance in a closed population from capture-recapture data. Biometrika, 104, 527-543.

Examples

data(data_sim2)
# estimate latent class model with 2 classes, same main log-linear effect across lists,
# one covariate affecting the weights, and bivariate interaction between consecutive lists
est = estLCCR(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")
est
# compute profile confidence interval
conf = confint(est)
conf
plot(conf)

Aggregate capture-recapture data

Description

Given a matrix of individual capture configurations, and the corresponding matrix and array of covariates (affecting the class weights and the conditional capture probabilities given the latent class), the function aggregates data, providing a stratified capture-recapture format.

Usage

aggr_data(Y, W = NULL, X = NULL)

Arguments

Y

matrix of frequencies of capture configurations

W

matrix of covariates affecting the class weights

X

array of covariates affecting the conditional capture probabilities

Value

Ya

matrix of aggregated frequencies of capture configurations

Wa

matrix of aggregated covariates affecting the class weights

Xa

array of aggregated covariates affecting the conditional capture probabilities

Author(s)

Francesco Bartolucci, Antonio Forcina

See Also

freq_data

Examples

# case without covariates
Y = rbind(c(0,1,0,0,0,0,0,0),c(0,0,0,1,0,0,0,0),c(0,0,0,0,0,0,1,0))
aggr_data(Y)

# case with covariates
W = c(1,1,2); X = as.matrix(c(0,0,2))
aggr_data(Y,W,X)

Confidence interval

Description

Profile confidence interval for a latent class model with covariates.

Usage

## S3 method for class 'estLCCR'
confint(object, parm = list(), level = 0.95, ...)

Arguments

object

output from estLCCR

parm

a list containing control arguments for the step length of the N values(step, default value depending on the estimate of N), range of N values in terms of distance of the log-likelhood from the its maximum (mult, default value 1.5), and maximum value of this grid as a multiple of the estimate of this parameter (max, default value 5)

level

the confidence level required

...

additional argument(s) for methods

Value

conf

confidence interval

Nv

vector of values of N tried

lkv

corresponding vector of log-likelihood values

level

level of confidence

Nh

point estimate of N

lkh

maximum log-likelihood values

lk1

log-likelihood value at the lower bound

lk2

log-likelihood value at the upper bound

step

step used in the grid search

err

error in the grid search

Author(s)

Francesco Bartolucci, Antonio Forcina

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Liu, Y., Li, P., and Qin, J. (2017). Maximum empirical likelihood estimation for abundance in a closed population from capture-recapture data. Biometrika, 104, 527-543.

See Also

estLCCR, plot.confLCCR

Examples

data(data_sim2)
est = estLCCR(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")
conf = confint(est)
plot(conf)

Confidence interval

Description

Profile confidence interval for a latent class model with covariates based on the CML method.

Usage

## S3 method for class 'estLCCRcon'
confint(object, parm = list(), level = 0.95, ...)

Arguments

object

output from estLCCR

parm

a list containing control arguments for the step length of the N values(step, default value depending on the estimate of N), range of N values in terms of distance of the log-likelhood from the its maximum (mult, default value 1.5), and maximum value of this grid as a multiple of the estimate of this parameter (max, default value 5)

level

the confidence level required

...

additional argument(s) for methods

Value

conf

confidence interval

Nv

vector of values of N tried

lkv

corresponding vector of log-likelihood values

level

level of confidence

Nh

point estimate of N

devh

minimum deviance

dev1

deviance at the lower bound

dev2

deviance at the upper bound

step

step used in the grid search

err

error in the grid search

Author(s)

Francesco Bartolucci, Antonio Forcina

References

Bartolucci, F. and Forcina, A. (2006). Estimating the size of a closed population by modeling latent and observed heterogeneity. Journal of the American Statistical Association, 101, 786-794.

See Also

estLCCR, plot.confLCCR

Examples

data(data_sim2)
est = estLCCRcon(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")
conf = confint(est)
plot(conf)

Simulated data 1

Description

Simulated capture-recapture data from a latent class model with 2 classes having the same weight on 5 lists.

Usage

data(data_sim1)

Format

A matrix containing the capture configurations at individual level.

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Examples

data(data_sim1)
est = estLCCR(Y=data_sim1,H=2)

Simulated data 2

Description

Simulated capture-recapture data from a latent class model with 2 classes, one covariate affecting the class weights, and bivariate loglinear interactions between consecutive lists.

Usage

data(data_sim2)

Format

A list containing capture configurations at individual level and corresponding covariates.

Y

capture configurations

W

values of the covariate affecting the class weights

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Examples

data(data_sim2)
est = estLCCR(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")

Simulated data 3

Description

Simulated capture-recapture data from a latent class model with 3 classes, one covariate affecting the logits of each response, and lag dependence.

Usage

data(data_sim3)

Format

A list containing capture configurations at individual level and corresponding covariates.

Y

capture configurations

X

values of the covariate affecting the conditional capture probabilities given the latent class

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Examples

data(data_sim3)
est = estLCCR(Y=data_sim3$Y,H=3,model="logit",X=data_sim3$X,flag="atleast")

Simulated data 4

Description

Simulated stratified capture-recapture data from a latent class model with 2 classes and covariates affecting both the class weights and the conditional capture probabilities given the latent class.

Usage

data(data_sim4)

Format

A list containing capture configurations at individual level and corresponding covariates.

Y

capture configurations

W

values of the covariate affecting the class weights

X

values of the covariate affecting the conditional capture probabilities given the latent class

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Examples

data(data_sim4)
est = estLCCR(Y=data_sim4$Y,H=2,X=data_sim4$X,W=data_sim4$W)

Design matrix for recursive logit parametrization

Description

For a latent class model for capture-recapture data, it provides design matrices for the recursive logit parametrization used to formulate the conditional distribution of capture configurations given the latent class. It is possible to include the effect of covariates and of previous captures.

Usage

design_matrix_logit(J, H = 1, main = c("LC", "same", "Rasch"), X = NULL,
                    free_cov = c("no", "class", "resp", "both"),
                    flag = c("no", "prev", "sum", "atleast"),
                    free_flag = c("no", "class", "resp", "both"))

Arguments

J

number of capture occasions

H

number of latent classes

main

"LC" for the latent class model in which there is a separate main effect for each capture occasion and latent class; "same" for the constrained model in which the main effect is the same across capture occasions but different across latent classes; "Rasch" for the constrained model in which each main effect is expressed in an additive form with a parameter related to the latent class and another parameter related to the capture occasion

X

array of covariates (n. strata x n. covariates x n. responses)

free_cov

"no" for constant effect of the covariates across capture occasions and latent classes; "class" for effect of covariates varying only with the latent class; "resp" for effect of covariates varying only with the capture occasion; "both" for effect of covariates varying with the capture occasion and the latent class

flag

"no" for no lag effect; "prev" for effect of the previous capture occasion only; "sum" for the effect of the sum of the previous capture occasions; "atleast" for the effect of at least one capture at the previous occasions

free_flag

"no" for constant effect of the previous capture occasions with respect to the occasion and the latent class; "class" for free effect only with respect to the latent class; "int" for free effect only with respect to the occasion; "both" for free effect with respect to capture occasion and latent class

Value

M

design matrices

par_list

list of parameter names

Main

list of capture configurations

Author(s)

Francesco Bartolucci, Antonio Foricna

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

See Also

design_matrix_loglin, matrix_logit, estLCCR


Design matrix for loglinear parametrization

Description

For a latent class model for capture-recapture data, it provides design matrices for the loglinear parametrization used to formulate the conditional distribution of the capture configurations given the latent class. It is possible to include the effect of covariates and bivariate interactions.

Usage

design_matrix_loglin(J, H = 1, main = c("LC", "same", "Rasch"), X = NULL,
                     free_cov = c("no", "class", "resp", "both"),
                     biv = NULL, free_biv = c("no", "class", "int", "both"))

Arguments

J

number of capture occasions

H

number of latent classes

main

"LC" for the latent class model in which there is a separate main effect for each capture occasion and latent class; "same" for the constrained model in which the main effect is the same across capture occasions but different across latent classes; "Rasch" for the constrained model in which each main effect is expressed in an additive form with a parameter related to the latent class and another parameter related to the capture occasion

X

array of covariates (n. strata x n. covariates x n. responses)

free_cov

"no" for constant effect of the covariates across capture occasions and latent classes; "class" for effect of covariates varying only with the latent class; "resp" for effect of covariates varying only with the capture occasion; "both" for effect of covariates varying with the capture occasion and the latent class

biv

matrix with two columns containing the list of bivariate interactions

free_biv

"no" for constant bivariate interation effect with respect to the occasion and the latent class; "class" for free interaction with respect to the latent class; "int" for free effect only with respect to the interation; "both" for free effect with respect to interation and latent class

Value

M

design matrices

par_list

list of parameter names

Main

list of capture configurations

Author(s)

Francesco Bartolucci, Antonio Foricna

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

See Also

design_matrix_logit, estLCCR


Estimate latent class models for capture-recapture data with individual covariates

Description

For a latent class model for stratified capture-recapture data with individual covariates, it estimates the model on the basis of observed data by the unconditional likelihood method, exploiting weights associated to the different strata. Estimation of the model parameters, included the population size, is based on an EM algorithm.

Usage

estLCCR(Y, H, model = c("loglin", "logit"), W = NULL, X = NULL, N = NULL, biv = NULL,
        flag = c("no", "prev", "sum", "atleast"),
        main = c("LC", "same", "Rasch"),
        free_cov = c("no", "class", "resp", "both"),
        free_biv = c("no", "class", "int", "both"),
        free_flag = c("no", "class", "resp", "both"),
        N0 = NULL, beta0 = NULL, lambda0 = NULL, control = list(),
        verb = TRUE, init_rand = FALSE, se_out = FALSE)

Arguments

Y

matrix of frequencies for each stratum (by row)

H

number of latent classes

model

"loglin" for loglinear parametrization; "logit" for recursive logit parametrization

W

matrix of covariates on the class weights

X

array of covariates (n. strata x n. covariates x n. responses)

N

fixed population size

biv

matrix with two columns containing the list of bivariate interactions (for loglinear parametrization)

flag

"no" for no lag effect; "prev" for effect of the previous capture occasion only; "sum" for the effect of the sum of the previous capture occasions; "atleast" for the effect of at least one capture at the previous occasions (for recursive logit parametrization)

main

"LC" for the latent class model in which there is a separate main effect for each capture occasion and latent class; "same" for the constrained model in which the main effect is the same across capture occasions but different across latent classes; "Rasch" for the constrained model in which each main effect is expressed in an additive form with a parameter related to the latent class and another parameter related to the capture occasion

free_cov

"no" for constant effect of the covariates across capture occasions and latent classes; "class" for effect of covariates varying only with the latent class; "resp" for effect of covariates varying only with the capture occasion; "both" for effect of covariates varying with the capture occasion and the latent class

free_biv

"no" for constant bivariate interation effect with respect to the occasion and the latent class; "class" for free interaction with respect to the latent class; "int" for free effect only with respect to the interation; "both" for free effect with respect to interation and latent class (for loglinear parametrization)

free_flag

"no" for constant effect of the previous capture occasions with respect to the occasion and the latent class; "class" for free effect only with respect to the latent class; "int" for free effect only with respect to the occasion; "both" for free effect with respect to capture occasion and latent class (for recursive logit parametrization)

N0

initial value of the population size

beta0

initial value of the parameters affecting the class weights

lambda0

initial value of the parameters affecting the conditional distribution of capture configurations given the latent class

control

a list containing control arguments for the maximum number of iterations of the EM algorithm (maxit, default value 5000) and relative tollerance (reltol, default value 101010^{-10})

verb

to have partial output during the model fitting

init_rand

to use a random initialization of the parameters

se_out

to require computation of the standard errors

Value

beta

estimate of the parameters affecting the class weights

lambda

estimate of the parameters affecting the conditional distribution of capture configurations given the latent class

lk

final log-likelihood value

N

estimate of the population size

np

number of free parameters

AIC

value of AIC for model selection

BIC

value of BIC for model selection

M

design matrices used for the recursive logit or loglinear parametrization of the conditional distribution of capture configurations given the latent class

tauv

estimate of the weights of each stratum

phiv

estimate of the probability of being never captured for each stratum

Piv

matrix of the probabilities of the latent classes for each stratum

Q

array of the conditional probabilities of the capture configurations given each latent class and stratum

seN

standard error for the estimate of N

sebeta

standard error for the estimate of beta

selambda

standard error for the estimate of lambda

lk1

component of the log-likelihood based on the binomial factor in N

lk2

component of the log-likelihood involving N and the overall probability of being never captured

lk3

component of the log-likelihood involving the capture probabilities

lk4

component of the log-likelihood involving the stratum weights

Author(s)

Francesco Bartolucci, Antonio Forcina

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

Liu, Y., Li, P., and Qin, J. (2017). Maximum empirical likelihood estimation for abundance in a closed population from capture-recapture data. Biometrika, 104, 527-543.

See Also

design_matrix_logit, design_matrix_loglin, simLCCR

Examples

# estimate latent class model with 2 classes having the same weight on 5 lists
data(data_sim1)
est = estLCCR(Y=data_sim1,H=2)
est

# estimate latent class model with 2 classes, one covariate affecting the weights and bivariate 
# loglinear interactions between consecutive lists
data(data_sim2)
est = estLCCR(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")
est

# estimate latent class model with 3 classes, one covariate affecting the logits of each response,
# and lag dependence
data(data_sim3)
est = estLCCR(Y=data_sim3$Y,H=3,model="logit",X=data_sim3$X,flag="atleast")
est

# estimate latent class model with 2 classes and covariates affecting both the class weights and
# conditional capture probabilities given the latent class
data(data_sim4)
est = estLCCR(Y=data_sim4$Y,H=2,X=data_sim4$X,W=data_sim4$W)
est

CML estimation of latent class models for capture-recapture data with individual covariates

Description

For a latent class model for stratified capture-recapture data with individual covariates, it estimates the model on the basis of observed data by the conditional likelihood method, exploiting weights associated to the different strata. Estimation of the model parameters, included the population size, is based on an EM algorithm.

Usage

estLCCRcon(Y, H, model = c("loglin", "logit"), W = NULL, X = NULL, N = NULL, biv = NULL,
        flag = c("no", "prev", "sum", "atleast"),
        main = c("LC", "same", "Rasch"),
        free_cov = c("no", "class", "resp", "both"),
        free_biv = c("no", "class", "int", "both"),
        free_flag = c("no", "class", "resp", "both"),
        beta0 = NULL, lambda0 = NULL, control = list(),
        verb = TRUE, init_rand = FALSE, se_out = FALSE)

Arguments

Y

matrix of frequencies for each stratum (by row)

H

number of latent classes

model

"loglin" for loglinear parametrization; "logit" for recursive logit parametrization

W

matrix of covariates on the class weights

X

array of covariates (n. strata x n. covariates x n. responses)

N

fixed population size

biv

matrix with two columns containing the list of bivariate interactions (for loglinear parametrization)

flag

"no" for no lag effect; "prev" for effect of the previous capture occasion only; "sum" for the effect of the sum of the previous capture occasions; "atleast" for the effect of at least one capture at the previous occasions (for recursive logit parametrization)

main

"LC" for the latent class model in which there is a separate main effect for each capture occasion and latent class; "same" for the constrained model in which the main effect is the same across capture occasions but different across latent classes; "Rasch" for the constrained model in which each main effect is expressed in an additive form with a parameter related to the latent class and another parameter related to the capture occasion

free_cov

"no" for constant effect of the covariates across capture occasions and latent classes; "class" for effect of covariates varying only with the latent class; "resp" for effect of covariates varying only with the capture occasion; "both" for effect of covariates varying with the capture occasion and the latent class

free_biv

"no" for constant bivariate interation effect with respect to the occasion and the latent class; "class" for free interaction with respect to the latent class; "int" for free effect only with respect to the interation; "both" for free effect with respect to interation and latent class (for loglinear parametrization)

free_flag

"no" for constant effect of the previous capture occasions with respect to the occasion and the latent class; "class" for free effect only with respect to the latent class; "int" for free effect only with respect to the occasion; "both" for free effect with respect to capture occasion and latent class (for recursive logit parametrization)

beta0

initial value of the parameters affecting the class weights

lambda0

initial value of the parameters affecting the conditional distribution of capture configurations given the latent class

control

a list containing control arguments for the maximum number of iterations of the EM algorithm (maxit, default value 5000) and relative tollerance (reltol, default value 101010^{-10})

verb

to have partial output during the model fitting

init_rand

to use a random initialization of the parameters

se_out

to require computation of the standard errors

Value

beta

estimate of the parameters affecting the class weights

lambda

estimate of the parameters affecting the conditional distribution of capture configurations given the latent class

lk

final log-likelihood value

dev

final value of the deviance that is used to build confidence intervals

N

estimate of the population size

np

number of free parameters

AIC

value of AIC for model selection

BIC

value of BIC for model selection

M

design matrices used for the recursive logit or loglinear parametrization of the conditional distribution of capture configurations given the latent class

phiv

estimate of the probability of being never captured for each stratum

Piv

matrix of the probabilities of the latent classes for each stratum

Q

array of the conditional probabilities of the capture configurations given each latent class and stratum

seN

standard error for the estimate of N

sebeta

standard error for the estimate of beta

selambda

standard error for the estimate of lambda

Author(s)

Francesco Bartolucci, Antonio Forcina

References

Bartolucci, F. and Forcina, A. (2006). Estimating the size of a closed population by modeling latent and observed heterogeneity. Journal of the American Statistical Association, 101, 786-794.

See Also

design_matrix_logit, design_matrix_loglin, simLCCR

Examples

# estimate latent class model with 2 classes having the same weight on 5 lists
data(data_sim1)
est = estLCCRcon(Y=data_sim1,H=2)
est

# estimate latent class model with 2 classes, one covariate affecting the weights and bivariate 
# loglinear interactions between consecutive lists
data(data_sim2)
est = estLCCRcon(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")
est

# estimate latent class model with 3 classes, one covariate affecting the logits of each response,
# and lag dependence
data(data_sim3)
est = estLCCRcon(Y=data_sim3$Y,H=3,model="logit",X=data_sim3$X,flag="atleast")
est

# estimate latent class model with 2 classes and covariates affecting both the class weights and
# conditional capture probabilities given the latent class
data(data_sim4)
est = estLCCRcon(Y=data_sim4$Y,H=2,X=data_sim4$X,W=data_sim4$W)
est

Convert capture-recapture configurations into frequency data

Description

Given a matrix of observed capture-recapture configurations, convert the data to a matrix of frequencies having the same number of rows and a number of columns equal to the number of possible configurations.

Usage

freq_data(R,count=rep(1,nrow(R)))

Arguments

R

Matrix of size n (sample size) x J (number of capture occastions) of observed capture-recapture configurations

count

Vector of counts for each configuration

Value

Y

Matrix of frequency of each capture configuration of size n x (2^J)

Author(s)

Francesco Bartolucci, Antonio Forcina

See Also

aggr_data

Examples

R = rbind(c(0,0,0,1),c(0,1,0,0),c(0,0,1,1),c(1,1,1,1),c(1,1,1,1))
Y = freq_data(R)

Design matrices of saturated logit parametrization

Description

For J binary responses, it provides design matrices A and B used to express the saturated recursive logit parametrization of type log(p) = [A*eta-B*log(1+exp(eta))].

Usage

matrix_logit(J)

Arguments

J

number of capture occasions

Value

A

first matrix involved in the recursive logit parametrization

B

second matrix involved in the recursive logit parametrization

Author(s)

Francesco Bartolucci, Antonio Foricna

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

See Also

matrix_logit, estLCCR


Plot profile confidence interval

Description

Plot for output from confint.estLCCR.

Usage

## S3 method for class 'confLCCR'
plot(x,...)

Arguments

x

an object of class condLCCR

...

further possible arguments

Value

M

matrix of binary configurations

Author(s)

Francesco Bartolucci, Antonio Forcina

Examples

data(data_sim2)
est = estLCCR(Y=data_sim2$Y,H=2,W=data_sim2$W,biv=matrix(c(1,2,3,4,2,3,4,5),4),main="same")
conf = confint(est)
plot(conf)

Print the output

Description

Given the output, it is written in a readable form.

Usage

## S3 method for class 'estLCCR'
print(x, ...)
## S3 method for class 'estLCCRcon'
print(x, ...)
## S3 method for class 'confLCCR'
print(x, ...)

Arguments

x

output from estLCCR, estLCCRcon or confint.estLCCR

...

further arguments passed to or from other methods

Value

No return value

Author(s)

Francesco Bartolucci, Antonio Forcina


Simulate capture-recapture data from a latent class model with individual covariates

Description

The function simulates capture-recapture data from a latent class model with individual covariates that may affect the class weights and/or the conditional distribution of capture configurations given the latent class. The data may be in disaggregated form (with each stratum having unitary dimension) or aggregated form (with strata having generic dimension).

Usage

simLCCR(H, J, beta, lambda, N, model = c("loglin", "logit"), Wc = NULL, Xc = NULL, 
        biv = NULL, flag = c("no", "prev", "sum", "atleast"),
        main = c("LC", "same", "Rasch"), 
        free_cov = c("no", "class", "resp", "both"),
        free_biv = c("no", "class", "int", "both"),
        free_flag = c("no", "class", "resp", "both"))

Arguments

H

number of latent classes

J

number of capture occasions

beta

value of the parameters affecting the class weights

lambda

value of the parameters affecting the conditional distribution of capture configurations given the latent

N

population size (with individual data); vector containing the size of any stratum (with aggregated data)

model

population size (with individual data); vector containing the size of any stratum (with aggregated data)

Wc

matrix of covariates affecting the class weights at population level

Xc

array of covariates at population level (n. strata x n. covariates x n. responses)

biv

matrix with two columns containing the list of bivariate interactions (for loglinear parametrization)

flag

"no" for no lag effect; "prev" for effect of the previous capture occasion only; "sum" for the effect of the sum of the previous capture occasions; "atleast" for the effect of at least one capture at the previous occasions (for recursive logit parametrization)

main

"LC" for the latent class model in which there is a separate main effect for each capture occasion and latent class; "same" for the constrained model in which the main effect is the same across capture occasions but different across latent classes; "Rasch" for the constrained model in which each main effect is expressed in an additive form with a parameter related to the latent class and another parameter related to the capture occasion

free_cov

"no" for constant effect of the covariates across capture occasions and latent classes; "class" for effect of covariates varying only with the latent class; "resp" for effect of covariates varying only with the capture occasion; "both" for effect of covariates varying with the capture occasion and the latent class

free_biv

"no" for constant bivariate interation effect with respect to the occasion and the latent class; "class" for free interaction with respect to the latent class; "int" for free effect only with respect to the interation; "both" for free effect with respect to interation and latent class (for loglinear parametrization)

free_flag

"no" for constant effect of the previous capture occasions with respect to the occasion and the latent class; "class" for free effect only with respect to the latent class; "int" for free effect only with respect to the occasion; "both" for free effect with respect to capture occasion and latent class (for recursive logit parametrization)

Value

Y

matrix of frequencies for each stratum (by row), only for captured indivdiuals

Yc

matrix of frequencies for each stratum (by row), for all indivdiuals

Piv

matrix of class weights for each stratum

Q

matrix of the conditional distribution of capture configurations given the latent class

Pm

matrix of the distribution of the capture configurations (with aggregated data)

R

matrix of single capture occasions (with individual data), only for captured individuals

U

vector of latent classes (with individual data)

Rc

matrix of single capture occasions (with individual data), for all individuals

W

matrix of covariates affecting the class weights, only for captured individuals

X

array of covariates affecting the conditional distribution of capture configurations given the latent class, only for captured individuals

Author(s)

Francesco Bartolucci, Antonio Forcina

References

Forcina, A. and Bartolucci, F. (2021). Estimating the size of a closed population by modeling latent and observed heterogeneity, arXiv:2106.03811.

See Also

design_matrix_logit, design_matrix_loglin, estLCCR

Examples

# simulate data from latent class model with 2 classes having the same weight on 5 lists
out = simLCCR(2,5,be=0,la=c(rep(-1,5),rep(1,5)),N=200)

# simulate data from a latent class model with 2 classes, one covariate affecting the weights and 
# bivariate loglinear interactions between consecutive lists
Wc = rnorm(200)
out = simLCCR(2,6,beta=c(0,1),lambda=c(-1,1,1),N=200,Wc=Wc,biv=matrix(c(1,2,3,4,2,3,4,5),4),
              main="same")

# simulate data from a latent class model with 3 classes, one covariate affecting the logits of 
# each response, and lag dependence
Xc = rnorm(200)
out = simLCCR(3,6,model="logit",beta=c(0,0),lambda=c(rep(-1,6),rep(0,6),rep(1,6),1,1),
              N=200,Xc=Xc,flag="atleast")

# simulate data from latent class model with 2 classes and covariates affecting both class weights
# and conditional probabilities of capture configurations given the latent class
Wc = c(-1,0,1); Xc = rnorm(3)
out = simLCCR(2,5,beta=c(0,0),lambda=c(rep(-1,5),rep(1,5),1),N=c(100,100,100),Wc=Wc,Xc=Xc)

Build matrix of binary vectors of a fixed lenght

Description

It creates all possible binary (with elements equal to 0 or 1) vectors of a specified length; these vectors are casted in a matrix having a number of columns equal to the vector length. If required, the binary vectors are constrained to have the same total (sum of their elements).

Usage

sq(J, t = NULL)

Arguments

J

legnth of binary vectors

t

possible fixed total

Value

M

matrix containing all binary vectors

Author(s)

Francesco Bartolucci, Antonio Forcina

Examples

# build matrix of all possible binary vectors of legnth 5
  M = sq(5)
  
# build matrix of all possible binary vectors of legnth 5 with total equal 2
  M = sq(5,2)

Summary of output

Description

Summary of output from fitting latent class models for capture-recapture data with covariates.

Usage

## S3 method for class 'estLCCR'
summary(object, ...)
## S3 method for class 'estLCCRcon'
summary(object, ...)
## S3 method for class 'confLCCR'
summary(object, ...)

Arguments

object

output from estLCCR,estLCCRcon or confint.estLCCR

...

further arguments passed to or from other methods

Value

No return value

Author(s)

Francesco Bartolucci, Antonio Forcina