Title: | Goodness-of-Fit Tests for Capture-Recapture Models |
---|---|
Description: | Performs goodness-of-fit tests for capture-recapture models as described by Gimenez et al. (2018) <doi:10.1111/2041-210X.13014>. Also contains several functions to process capture-recapture data. |
Authors: | Olivier Gimenez [aut, cre] , Jean-Dominique Lebreton [ctb], Remi Choquet [ctb], Roger Pradel [ctb] |
Maintainer: | Olivier Gimenez <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.2 |
Built: | 2024-11-13 06:01:39 UTC |
Source: | https://github.com/oliviergimenez/r2ucare |
This function performs maximum likelihood inference for multinomial mixture distributions.
coef_mixtures(Mp, Np)
coef_mixtures(Mp, Np)
Mp |
a matrix of mixtures (a row matrix if a vector) |
Np |
a matrix of bases (a row matrix if a vector) |
This function returns a list of maximum likelihood estimates for the cells of a mixture distribution:
P matrix of cell probabilities estimates for mixtures
PI matrix of mixture probabilities
GAM matrix of cell probabilities estimates for bases
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
Yantis, S., Meyer, D. E., and Smith, J. E. K. (1991). Analyses of multinomial mixture distributions: New tests for stochastic models of cognition and action. Psychological Bulletin 110, 350–374.
This function calculates the deviance of multinomial mixture distributions.
deviance_mixture(x, M, N, s, n, nbmel)
deviance_mixture(x, M, N, s, n, nbmel)
x |
value to which the deviance is to be evaluated |
M |
a vector of mixtures (see coef_mixtures.R) |
N |
a vector of bases (see coef_mixtures.R) |
s |
number of bases |
n |
number of cell probabilities |
nbmel |
number of mixtures |
This function returns the value of the deviance for mixture distributions.
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
Yantis, S., Meyer, D. E., and Smith, J. E. K. (1991). Analyses of multinomial mixture distributions: New tests for stochastic models of cognition and action. Psychological Bulletin 110, 350–374.
This function calculates expected values for a rxc contingency table.
expval_table(M)
expval_table(M)
M |
a matrix of observed probabilities |
A matrix of expected values.
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
This function carries out goodness-of-fit tests for contingency tables from the power-divergence family.
gof_test(lambda, observes, theoriques)
gof_test(lambda, observes, theoriques)
lambda |
parameter defining the statistic to be used: lambda = -0.5 is for the Freeman-Tuckey statistic, lambda = 0 for the G2 statistic, lambda = 2/3 for the Cressie-Read statistic and lambda = 1 for the classical Chi-square statistic |
observes |
vector of observed probabilities |
theoriques |
vector of theoretical/expected probabilities |
This function returns the value of the goodness-of-fit statistic.
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
This function pools together individuals with the same encounter capture-recapture history.
group_data(X, effX)
group_data(X, effX)
X |
matrix of capture-recapture histories |
effX |
vector with numbers of individuals with that particular capture-recapture history |
matrix with grouped capture-recapture histories and counts in the last column
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
# Generate fake capture-recapture dataset X = matrix(round(runif(300)),nrow=100) freq=rep(1,100) cbind(X,freq) group_data(X,freq)
# Generate fake capture-recapture dataset X = matrix(round(runif(300)),nrow=100) freq=rep(1,100) cbind(X,freq) group_data(X,freq)
This function pools together individuals with the same encounter capture-recapture history along specified directions given by columns.
group_data_gen(X, effX, s)
group_data_gen(X, effX, s)
X |
matrix of capture-recapture histories |
effX |
vector with numbers of individuals with that particular capture-recapture history |
s |
scalar or vector of columns along which the grouping should be done |
matrix with grouped capture-recapture histories and counts in the last column
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
This function tests independence in 2x2 contingency tables
ind_test_22(M, threshold = 2, rounding = 3)
ind_test_22(M, threshold = 2, rounding = 3)
M |
is a 2x2 contingency table |
threshold |
is a threshold for low expected numbers; default is 2 |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a vector with statistic of quadratic chi2 or inv chi2 corresponding to pvalue of Fisher test, p-value of quadratic chi2 test or Fisher test for low numbers, signed test and test performed (Chi-square, Fisher or None).
Olivier Gimenez <[email protected]>,Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
This function tests independence in rxc contingency tables
ind_test_rc(M, threshold = 2, rounding = 3)
ind_test_rc(M, threshold = 2, rounding = 3)
M |
is an r by c table of non-negative integers |
threshold |
is a threshold for low expected numbers; default is 2 |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a vector with statistic of quadratic chi2 or inv chi2 corresponding to pvalue of Fisher test, p-value of quadratic chi2 test or Fisher test for low numbers, degree of freedom and test performed (Chi-square, Fisher or None).
Olivier Gimenez <[email protected]>,Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
This function computes the inverse (or reciprocal) of the generalized logit link function.
inv_logit_gen(petitv)
inv_logit_gen(petitv)
petitv |
vector of values to be transformed |
ev vector of transformed values
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
This function calculates the m-array, the number of released and never seen again individuals; deals with more than 1 group
marray(X, freq)
marray(X, freq)
X |
a matrix of encounter histories over K occasions |
freq |
is a vector with the number of individuals having the corresponding encounter history |
This function returns a list with R the number of released individuals (K-1 x g matrix), m the m-array (K-1 x K-1 x g array) with upper triangle filled only and never the number of individuals never recaptured (K-1 x g matrix).
Olivier Gimenez <[email protected]>,Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # get female data mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] # get number of released individuals (R), # the m-array (m) and # the number of individuals never seen again (never) marray(dip.fem.hist,dip.fem.freq)
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # get female data mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] # get number of released individuals (R), # the m-array (m) and # the number of individuals never seen again (never) marray(dip.fem.hist,dip.fem.freq)
This function calculates the m-array for multistate capture-recapture data, the number of released and never seen again individuals.
multimarray(X, freq)
multimarray(X, freq)
X |
a matrix of encounter histories over K occasions |
freq |
is a vector with the number of individuals having the corresponding encounter history |
This function returns a matrix in which R the number of released individuals is in the first column, the number of individuals never recaptured (K-1) is in the last column and m the m-array (K-1 x K-1) with upper triangle filled only is in sandwich between these two vectors.
Olivier Gimenez <[email protected]>,Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # build m-array multimarray(geese.hist, geese.freq)
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # build m-array multimarray(geese.hist, geese.freq)
This function performs the overall goodness-of-fit test for the Cormack-Jolly-Seber model. It is obtained as the sum of the 4 components Test3.SR, Test3.SM, Test2.CT and Test2.CL.
overall_CJS(X, freq, rounding = 3)
overall_CJS(X, freq, rounding = 3)
X |
is a matrix of encounter histories |
freq |
is a vector of the number of individuals with the corresponding encounter history |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a data.frame with the value of the test statistic, the degrees of freedom and the p-value of the test.
Olivier Gimenez <[email protected]>,Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for females overall_CJS(dip.fem.hist, dip.fem.freq)
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for females overall_CJS(dip.fem.hist, dip.fem.freq)
This function performs the overall goodness-of-fit test for the Jolly-Move model. It is obtained as the sum of the 5 components Test3G.SR, Test3G.SM, Test3G.WBWA, TestM.ITEC, TestM.LTEC. To perform the goodness-of-fit test for the Arnason-Schwarz model, both the Arnason-Schwarz (AS) and the Jolly-Move models need to be fitted to the data (to our knowledge, only E-SURGE can fit the JMV model). Assuming the overall goodness-of-fit test for the JMV model has produced the value stat_jmv for the test statistic, get the deviance (say dev_as and dev_jmv) and number of estimated parameters (say dof_as and dof_jmv) for both the AS and JMV models. Then, finally, the p-value of the goodness-of-fit test for the AS model is obtained as 1 - pchisq(stat_as,dof_as) where stat_as = stat_jmv + (dev_as - dev_jmv) and dof_as = dof_jmv + (dof_jmv - dof_as)
overall_JMV(X, freq, rounding = 3)
overall_JMV(X, freq, rounding = 3)
X |
is a matrix of encounter histories |
freq |
is a vector of the number of individuals with the corresponding encounter history |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a data.frame with the value of the test statistic, the degrees of freedom and the p-value of the test.
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
# read in Geese dataset library(RMark) geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = convert.inp(geese) geese.hist = matrix(as.numeric(unlist(strsplit(geese$ch, ''))),nrow=nrow(geese),byrow=TRUE) geese.freq = geese$freq # encounter histories and number of individuals with corresponding histories X = geese.hist freq = geese.freq # load R2ucare package library(R2ucare) # perform overall gof test overall_JMV(X, freq)
# read in Geese dataset library(RMark) geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = convert.inp(geese) geese.hist = matrix(as.numeric(unlist(strsplit(geese$ch, ''))),nrow=nrow(geese),byrow=TRUE) geese.freq = geese$freq # encounter histories and number of individuals with corresponding histories X = geese.hist freq = geese.freq # load R2ucare package library(R2ucare) # perform overall gof test overall_JMV(X, freq)
This function pools columns of a 2xK contingency table (if needed, ie if low numbers present)
pool2K(M, low = 2)
pool2K(M, low = 2)
M |
is a 2 by K contingency table (or a K by 2 table) |
low |
is a threshold for low expected numbers; default is 2 (if this argument is big enough, the table is pooled down to 2 x 2; if this argument is 0, the table is not pooled) |
This function returns a matrix with the pooled contingency table.
Olivier Gimenez <[email protected]>, Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
This function pools rows and columns of a rxc contingency table according to Pradel et al. (2003).
pooling_ct(table)
pooling_ct(table)
table |
is a rxc contingency table |
This function returns a matrix with the pooled contingency table.
Olivier Gimenez <[email protected]>, Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
Pradel R., Wintrebert C.M.A. and Gimenez O. (2003). A proposal for a goodness-of-fit test to the Arnason-Schwarz multisite capture-recapture model. Biometrics 59: 43-53.
This function pools rows and columns of a rxc bases and mixture table according to Pradel et al. (2003). It provides the components of TestM in the multisite goodness-of-fit tests.
pooling_mixtures(nk, nj, a, mixandbases)
pooling_mixtures(nk, nj, a, mixandbases)
nk |
number of mixtures |
nj |
number of bases |
a |
number of sites/states |
mixandbases |
matrix with mixtures and bases |
This function returns a matrix with the pooled table.
Olivier Gimenez <[email protected]>, Rémi Choquet, Jean-Dominique Lebreton, Anne-Marie Reboulet, Roger Pradel
Pradel R., Wintrebert C.M.A. and Gimenez O. (2003). A proposal for a goodness-of-fit test to the Arnason-Schwarz multisite capture-recapture model. Biometrics 59: 43-53.
This function reads in capture-recapture dataset with the Headed format. It ignores all forms of censorship for now, and drops continuous covariates because no goodness-of-fit test exists for such models
read_headed(file)
read_headed(file)
file |
text file with Headed format |
list with first component the matrix of encounter histories, second components the vector of number of individuals with corresponding histories and, if relevant, third component vector/matrix with group(s)
Olivier Gimenez <[email protected]>
# read in Dipper dataset dipper = system.file("extdata", "ed.txt", package = "R2ucare") read_headed(dipper) # read in Geese dataset geese = system.file("extdata", "geese.txt", package = "R2ucare") read_headed(geese)
# read in Dipper dataset dipper = system.file("extdata", "ed.txt", package = "R2ucare") read_headed(dipper) # read in Geese dataset geese = system.file("extdata", "geese.txt", package = "R2ucare") read_headed(geese)
This function reads in capture-recapture dataset with the Input format. It is a wrapper for the function convert.inp from package RMark. It drops continuous covariates because no goodness-of-fit test exists for such models
read_inp(file, group.df = NULL)
read_inp(file, group.df = NULL)
file |
text file with Input format (extension .inp) |
group.df |
dataframe with grouping variables; contains a row for each group defined in the input file row1=group1, row2=group2 etc. Names and number of columns in the dataframe is set by user to define grouping variables in RMark dataframe |
list with first component the matrix of encounter histories, second components the vector of number of individuals with corresponding histories and, if relevant, third component vector/matrix with group(s)
Olivier Gimenez <[email protected]>
# read in Dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # read in Geese dataset geese = system.file("extdata", "geese.inp", package = "R2ucare") read_inp(geese)
# read in Dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # read in Geese dataset geese = system.file("extdata", "geese.inp", package = "R2ucare") read_inp(geese)
This function reformat the outputs of multinomial mixture distributions parameters.
reconstitution(x, s, n, nbmel)
reconstitution(x, s, n, nbmel)
x |
vector with cell probabilities estimates for mixtures and bases, along with mixture probilities |
s |
number of bases |
n |
number of cell probabilities |
nbmel |
number of mixtures |
This function returns a list of maximum likelihood estimates for the cells of a mixture distribution with:
P matrix of cell probabilities estimates for mixtures
PI matrix of mixture probabilities
GAM matrix of cell probabilities estimates for bases
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
This function creates a large matrix consisting of an m-by-n tiling of copies of X. The dimensions of the returned matrix are nrow(X)*m x ncol(X)*n. This is the equivalent of the repmat MATLAB function.
repmat(X, m, n)
repmat(X, m, n)
X |
matrix to be replicated |
m |
row dimension of replication |
n |
column dimension of replication |
A replicated matrix of X with dimensions nrow(X)*m x ncol(X)*n.
Olivier Gimenez <[email protected]>
This function performs Test2.CL
test2cl(X, freq, verbose = TRUE, rounding = 3)
test2cl(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with 5 columns for components i (2:K-3) (in rows) of test2.cli following Pradel 1993 (in Lebreton and North, Birkhauser Verlag): component, degree of freedom, statistic of the test, p-value, test performed.
Olivier Gimenez <[email protected]>, Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for males X = dip.mal.hist freq = dip.mal.freq res.males = test2cl(X,freq) res.males
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for males X = dip.mal.hist freq = dip.mal.freq res.males = test2cl(X,freq) res.males
This function performs Test2.CT
test2ct(X, freq, verbose = TRUE, rounding = 3)
test2ct(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with 5 columns for components i (2:K-2) (in rows) of test2.Cti: component, degree of freedom, statistic of the test, p-value, signed test, test performed.
Olivier Gimenez <[email protected]>, Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for females X = dip.fem.hist freq = dip.fem.freq res.females = test2ct(X,freq) res.females
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for females X = dip.fem.hist freq = dip.fem.freq res.females = test2ct(X,freq) res.females
This function performs Test3G.SM
test3Gsm(X, freq, verbose = TRUE, rounding = 3)
test3Gsm(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with occasion, site, the value of the test statistic, degree of freedom, p-value and test performed (chi-square, Fisher or none).
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform Test.3.GSm test3Gsm(geese.hist,geese.freq)
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform Test.3.GSm test3Gsm(geese.hist,geese.freq)
This function performs Test3G.SR
test3Gsr(X, freq, verbose = TRUE, rounding = 3)
test3Gsr(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with occasion, site, the value of the test statistic, degree of freedom, p-value and test performed (chi-square, Fisher or none).
Olivier Gimenez <[email protected]>, Rémi Choquet, Roger Pradel
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform Test3.GSR test3Gsr(geese.hist,geese.freq)
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform Test3.GSR test3Gsr(geese.hist,geese.freq)
This function performs Test3G.WBWA
test3Gwbwa(X, freq, verbose = TRUE, rounding = 3)
test3Gwbwa(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with occasion, site, the value of the test statistic, degree of freedom, p-value and test performed (chi-square, Fisher or none).
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform Test.3GWBWA test3Gwbwa(geese.hist,geese.freq)
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform Test.3GWBWA test3Gwbwa(geese.hist,geese.freq)
This function performs Test3.SM
test3sm(X, freq, verbose = TRUE, rounding = 3)
test3sm(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with 5 columns for components i (2:K-1) (in rows) of test3.smi: component, degree of freedom, statistic of the test, p-value, test performed.
Olivier Gimenez <[email protected]>, Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for females res.females = test3sm(dip.fem.hist, dip.fem.freq) res.females
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # for females res.females = test3sm(dip.fem.hist, dip.fem.freq) res.females
This function performs Test3.SR
test3sr(X, freq, verbose = TRUE, rounding = 3)
test3sr(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with 4 columns for components i (2:K-1) (in rows) of test3.sri: component, statistic of the test, p-value, signed test, test performed.
Olivier Gimenez <[email protected]>, Jean-Dominique Lebreton, Rémi Choquet, Roger Pradel
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # Test3SR for males res.males = test3sr(dip.mal.hist, dip.mal.freq) res.males
# read in the classical dipper dataset dipper = system.file("extdata", "ed.inp", package = "R2ucare") dipper = read_inp(dipper,group.df=data.frame(sex=c('Male','Female'))) # Get encounter histories, counts and groups: dip.hist = dipper$encounter_histories dip.freq = dipper$sample_size dip.group = dipper$groups # split the dataset in males/females mask = (dip.group == 'Female') dip.fem.hist = dip.hist[mask,] dip.fem.freq = dip.freq[mask] mask = (dip.group == 'Male') dip.mal.hist = dip.hist[mask,] dip.mal.freq = dip.freq[mask] # Test3SR for males res.males = test3sr(dip.mal.hist, dip.mal.freq) res.males
This function performs TestM.ITEC
testMitec(X, freq, verbose = TRUE, rounding = 3)
testMitec(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with occasion, the value of the test statistic, degree of freedom, p-value and test performed (chi-square, Fisher or none).
Olivier Gimenez <[email protected]>, Rémi Choquet, Roger Pradel
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform TestM.ITEC testMitec(geese.hist,geese.freq)
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform TestM.ITEC testMitec(geese.hist,geese.freq)
This function performs TestM.LTEC
testMltec(X, freq, verbose = TRUE, rounding = 3)
testMltec(X, freq, verbose = TRUE, rounding = 3)
X |
is a matrix of encounter histories with K occasions |
freq |
is a vector of the number of individuals with the corresponding encounter history |
verbose |
controls the level of the details in the outputs; default is TRUE for all details |
rounding |
is the level of rounding for outputs; default is 3 |
This function returns a list with first component the overall test and second component a data.frame with occasion, the value of the test statistic, degree of freedom, p-value and test performed (chi-square, Fisher or none).
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform TestM.LTEC testMltec(geese.hist, geese.freq)
# Read in Geese dataset: geese = system.file("extdata", "geese.inp", package = "R2ucare") geese = read_inp(geese) # Get encounter histories and number of individuals with corresponding histories geese.hist = geese$encounter_histories geese.freq = geese$sample_size # perform TestM.LTEC testMltec(geese.hist, geese.freq)
This function splits encounter histories in as many individual histories as required.
ungroup_data(X, effX)
ungroup_data(X, effX)
X |
matrix of encounter capture-recapture histories |
effX |
vector with numbers of individuals with that particular encounter history |
matrix with ungrouped capture-recapture histories and counts in the last column (should be 1s)
Olivier Gimenez <[email protected]>, Roger Pradel, Rémi Choquet
# Generate fake capture-recapture dataset X = matrix(round(runif(9)),nrow=3) freq=c(4,3,-8) cbind(X,freq) ungroup_data(X,freq)
# Generate fake capture-recapture dataset X = matrix(round(runif(9)),nrow=3) freq=c(4,3,-8) cbind(X,freq) ungroup_data(X,freq)