Title: | Compute Chi-Square Measures with Corrections |
---|---|
Description: | Chi-square tests are computed with corrections. |
Authors: | Aurélie Siberchicot, Eléonore Hellard, Dominique Pontier, David Fouchet and Franck Sauvage |
Maintainer: | Aurélie Siberchicot <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.4 |
Built: | 2024-10-24 06:30:26 UTC |
Source: | https://github.com/lbbe-software/interatrix |
This function implements a method to correct for shared risk factors in the search for interactions. It provides the observed chi-square value, a measure of association between two parasites, and simulates bootstrapped data taking risk factors into account.
chi2Corr(formula, data.obs, namepara1, namepara2, nsimu)
chi2Corr(formula, data.obs, namepara1, namepara2, nsimu)
formula |
a string of characters indicating a symbolic description of the model of shared risk factors to be fitted without any response variable |
data.obs |
the name of the data set to be used |
namepara1 |
the name of the column giving the status to the first parasite |
namepara2 |
the name of the column giving the status to the second parasite |
nsimu |
an integer indicating the number of repetitions for the bootstrap simulation |
The value returned is a list containing:
formula |
the model fitted without any response variable |
time |
duration in seconds of the simulations |
chi2.corr.obs |
the Pearson's chi2 statistic calculated on |
dispcoeff |
the estimated coefficient of over- (or under-) dispersion, defined as the mean of the bootstrapped values of the corrected chi-square. |
pval1 |
p-value of the corrected chi-square test under the null hypothesis of independence of the two parasites.
|
pval2 |
p-value of the corrected chi-square test under the null hypothesis of independence of the two parasites.
|
tab.th |
expected frequencies, ie. the contingency table calculated on the theoretical (bootstrapped) data |
tab.obs |
observed frequencies, ie. the contingency table calculated on |
chi2.corr.sim |
a vector containing the |
The distribution of the bootstrapped corrected chi-squares (an histogram) is also provided.
pval2
is better than pval1
but requires running enough simulations, wich may be long in some cases. pval1
allows working with smaller numbers of simualtions when simulation times are too long.
True versus False Parasite Interactions: A Robust Method to Take Risk Factors into Account and Its Application to Feline Viruses. Hellard E., Pontier D., Sauvage F., Poulet H. and Fouchet D. (2012). PLoS ONE 7(1): e29618. doi:10.1371/journal.pone.0029618.
## Not run: library(Interatrix) data(dataInteratrix) res1 <- chi2Corr("F1+F2*F3+F4", dataInteratrix, "Parasite1", "Parasite2", 500) ## End(Not run)
## Not run: library(Interatrix) data(dataInteratrix) res1 <- chi2Corr("F1+F2*F3+F4", dataInteratrix, "Parasite1", "Parasite2", 500) ## End(Not run)
This function implements a method to correct for the cumulative effect of age and for other potentially confounding risk factors in the search for interactions. It provides the observed chi-square value, a measure of the association between two parasites, and simulates bootstrapped data taking risk factors into account.
chi2CorrAge(formula, data.obs, namepara1, namepara2, nameage, w1, w2, mort, a, nsimu, nbcore = 3)
chi2CorrAge(formula, data.obs, namepara1, namepara2, nameage, w1, w2, mort, a, nsimu, nbcore = 3)
formula |
a string of characters indicating a symbolic description of the model of shared risk factors (including age) to be fitted without any response variable |
data.obs |
the name of the data set to be used |
namepara1 |
the name of the column giving the status to the first parasite |
namepara2 |
the name of the column giving the status to the second parasite |
nameage |
the column name of the age classes |
w1 |
a real number between 0 and 1 indicating the antibodies' disappearance rate of the first studied parasite |
w2 |
a real number between 0 and 1 indicating the antibodies' disappearance rate of the second studied parasite |
mort |
a vector of real numbers between 0 and 1 giving the mortality rates of all age classes |
a |
a vector of integers giving the bounds of the age classes |
nsimu |
an integer indicating the number of repetitions for the bootstrap simulation |
nbcore |
an integer indicating the number of cores available on the computer to set up a parallel calculation |
The value returned is a list containing:
formula |
the model fitted without any response variable |
time |
duration in seconds of the simulations |
nbcore |
the number of cores used for parallel simulations |
chi2.corr.obs |
the Pearson's chi2 statistic calculated on |
pval |
p-value of the corrected chi-square test under the null hypothesis of independence of the two parasites.
|
tab.th |
expected frequencies, ie. the contingency table calculated on the theoretical (bootstrapped) data |
tab.obs |
observed frequencies, ie. the contingency table calculated on |
chi2.corr.sim |
a vector containing the |
The distribution of the bootstrapped corrected chi-squares (an histogram) is also provided.
Unknown age in health disorders: a method to account for its cumulative effect and an application to feline viruses interactions. Hellard E., Pontier D., Siberchicot A., Sauvage F. and Fouchet D. (2015). Epidemics 11: 48-55. doi:10.1016/j.epidem.2015.02.004.
## Not run: library(Interatrix) data(dataInteratrix) res2 <- chi2CorrAge("F1+F2+AGE", dataInteratrix, "Parasite1", "Parasite2", "AGE", w1 = 0, w2 = 0, mort = c(0.2, 0.2, 0.2), a = c(0, 1, 2, 10), nsimu = 500, nbcore = 2) ## End(Not run)
## Not run: library(Interatrix) data(dataInteratrix) res2 <- chi2CorrAge("F1+F2+AGE", dataInteratrix, "Parasite1", "Parasite2", "AGE", w1 = 0, w2 = 0, mort = c(0.2, 0.2, 0.2), a = c(0, 1, 2, 10), nsimu = 500, nbcore = 2) ## End(Not run)
A generated data set provided to test the Interatrix
package.
data(dataInteratrix)
data(dataInteratrix)
A data frame with 100 observations for the following variables:
F1
a numeric vector containing a factor with three modalities
F2
a numeric vector containing a continuous variable
F3
a numeric vector containing a factor with two modalities
F4
a numeric vector containing a continuous variable
Parasite1
a numeric vector containing the serological status to the first parasite
Parasite2
a numeric vector containing the serological status to the second parasite
AGE
a numeric vector containing a factor with three modalities indicating the age classes
data(dataInteratrix)
data(dataInteratrix)
Internal functions for the Interatrix package.
list2ascii(x,file = paste(deparse(substitute(x)), ".txt", sep = ""))
## internal functions for chi2Corr() and chi2CorrGUI()
obsdata_chi2corr(formula, data, name1, name2)
chi2corrboot(data, formula, sero1, sero2)
simudata_chi2corr(formula, data, name1, name2, nbsimu, pvir1, pvir2, chi2corrobs)
## internal functions for chi2CorrAge() and chi2CorrAgeGUI()
SensTransMatrix(para, listmodel, rate, agenum, a)
EstimParam(paranum, rate, listmodel, agenum, v0, tol = 0.00000001, maxit = 50000, a, mort)
ModelClass(para, formula, data, agemax, nameage)
calcInfectProba(data, formula, namepara1, namepara2, nameage, w1, w2, mort, a, v0para1, v0para2)
obsdata_chi2corrage(formula, data, name1, name2, nameage, w1, w2, mort, a, v0para1, v0para2)
simudata_chi2corrage(formula, data, name1, name2, nameage, w1, w2, mort, a, v0para1, v0para2, matprobainfect)
This function opens a graphical interface and helps step by step to compute corrected chi-square tests.
InteratrixGUI()
InteratrixGUI()
A first interactive graphical interface is opened to choose between two methods. When all parameters are defined by the user, simulation results are printed to the R console, saved in a file and plotted as an histogram.