Title: | A Simple R Package for Classical Parametric Statistical Tests and Confidence Intervals in Large Samples |
---|---|
Description: | One and two sample mean and variance tests (differences and ratios) are considered. The test statistics are all expressed in the same form as the Student t-test, which facilitates their presentation in the classroom. This contribution also fills the gap of a robust (to non-normality) alternative to the chi-square single variance test for large samples, since no such procedure is implemented in standard statistical software. |
Authors: | Cqls Team |
Maintainer: | Pierre Lafaye de Micheaux <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.4 |
Built: | 2025-01-26 04:24:46 UTC |
Source: | https://github.com/cran/asympTest |
Performs one and two sample asymptotic (no gaussian assumption on distribution) parametric tests on vectors of data.
asymp.test(x,...) ## Default S3 method: asymp.test(x, y = NULL, parameter = c("mean", "var", "dMean", "dVar", "rMean", "rVar"), alternative = c("two.sided", "less", "greater"), reference = 0, conf.level = 0.95, rho = 1, ...) ## S3 method for class 'formula' asymp.test(formula, data, subset, na.action, ...)
asymp.test(x,...) ## Default S3 method: asymp.test(x, y = NULL, parameter = c("mean", "var", "dMean", "dVar", "rMean", "rVar"), alternative = c("two.sided", "less", "greater"), reference = 0, conf.level = 0.95, rho = 1, ...) ## S3 method for class 'formula' asymp.test(formula, data, subset, na.action, ...)
x |
a (non-empty) numeric vector of data values. |
y |
an optional (non-empty) numeric vector of data values. |
parameter |
a character string specifying the parameter under testing, must be one of "mean", "var", "dMean" (default), "dVar", "rMean", "rVar" |
alternative |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter. |
reference |
a number indicating the reference value of the parameter (difference or ratio true value for two sample test) |
conf.level |
confidence level of the interval. |
rho |
optional parameter (only used for parameters "dMean" and "dVar") for penalization (or enhancement) of the contribution of the second parameter. |
formula |
a formula of the form |
data |
an optional matrix or data frame (or similar: see
|
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function which indicates what should happen when
the data contain |
... |
further arguments to be passed to or from methods. |
Asymptotic parametric test and confidence intervals are based on the following unified statistic :
which asymptotically follows a .
stands for the parameter under testing
(mean/variance, difference/ratio of means or variances).
The term is calculated by the ad-hoc seTheta function (see
seMean
).
A list with class "htest" containing the following components:
statistic |
the value of the unified |
p.value |
the p-value for the test. |
conf.int |
a confidence interval for the parameter appropriate to the specified alternative hypothesis. |
estimate |
the estimated parameter depending on whether it wasa one-sample test or a two-sample test (in which case the estimated parameter can be a difference/ratio in means/variances). |
null.value |
the specified hypothesized value of parameter depending on whether it was a one-sample test or a two-sample test. |
alternative |
a character string describing the alternative hypothesis. |
method |
a character string indicating what type of asymptotictest was performed. |
data.name |
a character string giving the name(s) of the data. |
J.-F. Coeurjolly, R. Drouilhet, P. Lafaye de Micheaux, J.-F. Robineau
C oeurjolly, J.F. Drouilhet, R. Lafaye de Micheaux, P. Robineau, J.F. (2009) asympTest: a simple R package for performing classical parametric statistical tests and confidence intervals in large samples, The R Journal
t.test
, var.test
for normal distributed data.
## one sample x <- rnorm(70, mean = 1, sd = 2) asymp.test(x) asymp.test(x,par="mean",alt="g") asymp.test(x,par="mean",alt="l",ref=2) asymp.test(x,par="var",alt="g") asymp.test(x,par="var",alt="l",ref=2) ## two samples y <- rnorm(50, mean = 2, sd = 1) asymp.test(x,y) asymp.test(x,y,"rMean","l",.75) asymp.test(x,y,"dMean","l",0,rho=.75) asymp.test(x,y,"dVar") ## Formula interface asymp.test(uptake~Type,data=CO2)
## one sample x <- rnorm(70, mean = 1, sd = 2) asymp.test(x) asymp.test(x,par="mean",alt="g") asymp.test(x,par="mean",alt="l",ref=2) asymp.test(x,par="var",alt="g") asymp.test(x,par="var",alt="l",ref=2) ## two samples y <- rnorm(50, mean = 2, sd = 1) asymp.test(x,y) asymp.test(x,y,"rMean","l",.75) asymp.test(x,y,"dMean","l",0,rho=.75) asymp.test(x,y,"dVar") ## Formula interface asymp.test(uptake~Type,data=CO2)
A clinical trial focused dataset was developed using the Digitalis Investigation Group (DIG). This dataset was designed to replicate the results found in the February 1997 New England Journal of Medicine article. Note that statistical processes such as permutations within treatment groups were used to completely anonymize the data; therefore, inferences derived from the teaching dataset may not be valid. The DIG Trial was a randomized, double-blind, multicenter trial with more than 300 centers in the United States and Canada participating. The purpose of the trial was to examine the safety and efficacy of Digoxin in treating patients with congestive heart failure in sinus rhythm. Data on 5281 male and 1519 female collected.
This data frame contains the following columns:
Patient ID
(0=Placebo, 1=Treatment)
Calculated: age at randomization
Q5: Race, 1=White 2=Nonwhite
(1 = male or 2 = female)
Q3: Ejection fraction (percent)
Q3A: Ejection Fraction method
Q6: Chest X-ray (CT-Ratio)
Calculated: Body Mass Index (kg per M-squared)
Q9A: Serum Potassium level
Q9: Serum Creatinine (mg per dL)
Q10: Recommended Digoxin dose
Q12: Duration of CHF (months)
Q13: Rales
Q14: Elevated jugular venous pressure
Q15: Peripheral Edema
Q16: Dyspnea at Rest
Q17: Dyspnea on Exertion
Q18: Limitation of activity
Q19: S3 Gallop
Q20: Pulmonary congestion
Calculated: Sum of Q13-Q20, Y or N status
Q21: Heart Rate (beats per min)
Q22: Diastolic BP (mmHg)
Q22: Sysolic BP (mmHg)
Q23: NYHA Functional Class
Q24: CHF Etiology
Q25: Previous Myocardial Infarction
Q26: Current Angina
Q27: History of Diabetes
Q28: History of Hypertension
Q29: Digoxin within past week
Q30: Potassium sparing Diuretics
Q31: Other Diuretics
Q31A: Potassium supplements
Q32: Ace inhibitors
Q33: Nitrates
Q34: Hydralazine
Q35: Other Vasodilators
Q36: Dose of Digoxin per Placebo prescribed
Hosp: Cardiovascular Disease
Days randomization to First CVD Hosp
Hosp: Worsening Heart Failure
Days randomization to First WHF Hosp
Hosp: Digoxin Toxicity
Days rand. to First Digoxin Tox Hosp
Hosp: Myocardial Infarction
Days randomization to First MI Hosp
Hosp: Unstable Angina
Days rand. to First Unstable Angina Hosp
Hosp: Stroke
Days randomization to First Stroke Hosp
Hosp: Supraventricular Arrhythmia
Days rand. to First SupraVent Arr. Hosp
Hosp: Ventricular Arrhythmia
Days rand. to First Vent. Arr. Hosp
Hosp: Coronary Revascularization
Days rand. to First Cor. Revasc.
Hosp: Other Cardiovascular Event
Days rand. to First Other CVD Hosp
Hosp: Respiratory Infection
Days rand. to First Resp. Infection Hosp
Hosp: Other noncardiac, nonvascular
Days rand. to 1st Other Non CVD Hosp
Hosp: Any Hospitalization
Days randomization to First Any Hosp
Number of Hospitalizations
Vital Status of Patient 1=Death 0=Alive
Days till last followup or death
Cause of Death
Primary Endpt: Death or Hosp from HF
Days rand. to death or Hosp from WHF
NHLBI Teaching Dataset
The effect of digoxin on mortality and morbidity in patients with heart failure . The Digitalis Investigation Group. N En gl J Med. 1997 Feb 20;336(8):525-33
data(DIGdata)
data(DIGdata)
se functions compute the Standard Error of respectively mean, variance, difference of means, of variances and ratio of means and variances.
seMean(x,...) ## Default S3 method: seMean(x,...) seVar(x,...) ## Default S3 method: seVar(x,...) seDMean(x,...) ## Default S3 method: seDMean(x, y, rho = 1, ...) seDMeanG(x,...) ## Default S3 method: seDMeanG(x, y,...) seDVar(x,...) ## Default S3 method: seDVar(x, y, rho = 1, ...) seRMean(x,...) ## Default S3 method: seRMean(x, y, r0,...) seRVar(x,...) ## Default S3 method: seRVar(x, y, r0,...)
seMean(x,...) ## Default S3 method: seMean(x,...) seVar(x,...) ## Default S3 method: seVar(x,...) seDMean(x,...) ## Default S3 method: seDMean(x, y, rho = 1, ...) seDMeanG(x,...) ## Default S3 method: seDMeanG(x, y,...) seDVar(x,...) ## Default S3 method: seDVar(x, y, rho = 1, ...) seRMean(x,...) ## Default S3 method: seRMean(x, y, r0,...) seRVar(x,...) ## Default S3 method: seRVar(x, y, r0,...)
x |
a (non-empty) numeric vector of data values. |
y |
an optional (non-empty) numeric vector of data values. |
rho |
optional parameter for penalization (or enhancement) of the contribution of the second parameter. |
r0 |
an optional parameter for ratio of means (seRMean) or variances (seRVar). It acts as parameter r in seDMean and seDVar. Defaults are mean(x)/mean(y) in seRMean and var(x)/var(y) for seRVar. |
... |
further arguments to be passed to or from methods. |
se functions performs classical standard error estimation for parameters mean, variance, difference of means or variances, ratio of means or variances.
Return the value of the estimated standard error for the corresponding parameter.
J.-F. Coeurjolly, R. Drouilhet, P. Lafaye de Micheaux, J.-F. Robineau
Coeurjolly, J.F. Drouilhet, R. Lafaye de Micheaux, P. Robineau, J.F. (2008) asympTest: a simple R package for performing classical parametric statistical tests and confidence intervals in large samples, The R Journal
asymp.test
that used estimated standard error
for asymptotic parametric tests.
x <- rnorm(70, mean = 1, sd = 2) y <- rnorm(50, mean = 2, sd = 1) ## mean statistic asymp.test(x)$stat mean(x)/seMean(x) ## variance statistic asymp.test(x,param="var",alt="l",param0=2)$stat (var(x)-2)/seVar(x) ## difference of means statistic asymp.test(x,y)$stat (mean(x)-mean(y))/seDMean(x,y)
x <- rnorm(70, mean = 1, sd = 2) y <- rnorm(50, mean = 2, sd = 1) ## mean statistic asymp.test(x)$stat mean(x)/seMean(x) ## variance statistic asymp.test(x,param="var",alt="l",param0=2)$stat (var(x)-2)/seVar(x) ## difference of means statistic asymp.test(x,y)$stat (mean(x)-mean(y))/seDMean(x,y)