From 0a2c6873234065d4183f48f4fb3dfeba0bb37a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Sat, 15 Mar 2014 11:41:07 -0400 Subject: [PATCH] Modification des messages --- R/chisquare.test.R | 26 ++++++++++++-------------- R/md.test.R | 10 ++-------- man/chisquare.test.Rd | 4 ++-- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/R/chisquare.test.R b/R/chisquare.test.R index 4ac609b..6861baa 100644 --- a/R/chisquare.test.R +++ b/R/chisquare.test.R @@ -1,10 +1,12 @@ # Pearson's Chi-Squared test based on the characteristic function # # Author: François Pelletier +# +# LGPL 3.0 ############################################################################### #' Pearson's Chi-Squared test based on the characteristic function -#' @param DATA.hist histogram object of the data +#' @param datahist histogram object of the data #' @param FUN Characteristic function (integral) or #' Saddlepoint distribution approximation (saddlepoint) #' @param ... FUN arguments @@ -15,30 +17,26 @@ #' degree of freedom, hypothesis reject boolean and p.value #' @export chisquare.test #' @author François Pelletier -chisquare.test <- function(DATA.hist,FUN,...,alpha=0.05,method="integral") +chisquare.test <- function(datahist,FUN,...,alpha=0.05,method="integral") { # Compute expected values for each histogram breaks using the characteristic function - classes <- DATA.hist$breaks + classes <- datahist$breaks + observed <- datahist$counts if(method=="integral") { expected <- diff(cftocdf(classes,FUN,...)* - sum(observed <- DATA.hist$counts)) + sum(observed)) } else if(method=="saddlepoint") { expected <- diff(FUN(classes,...)* - sum(observed <- DATA.hist$counts)) + sum(observed)) } - # Compute the test statistic using chi-square distribution - p.value <- pchisq(chisquare.stat<-sum((observed-expected)^2/expected), - df<-length(classes)-2,lower.tail=FALSE) - # Print output - cat("Chi-Square Test based on CF\n\nTest statistic: ",chisquare.stat, - "\nDegree of freedom: ",df, - "\nP-value: ",p.value, - "\nReject H0 with confidence level ",1-alpha,"?: ",p.value= alpha - # Print output - cat("Minimum distance test based on a transform\n\nTest statistic: ",md.stat, - "\nDegree of freedom: ",df, - "\nP-value: ",p.value, - "\nReject H0 with confidence level ",1-alpha,"?: ",reject) # Create the return list - list(md.stat=md.stat,df=df,reject=reject,p.value=p.value) + list(md.stat=md.stat,df=df,p.value=p.value) } diff --git a/man/chisquare.test.Rd b/man/chisquare.test.Rd index 109696f..d2b5382 100644 --- a/man/chisquare.test.Rd +++ b/man/chisquare.test.Rd @@ -2,10 +2,10 @@ \alias{chisquare.test} \title{Pearson's Chi-Squared test based on the characteristic function} \usage{ -chisquare.test(DATA.hist, FUN, ..., alpha = 0.05, method = "integral") +chisquare.test(datahist, FUN, ..., alpha = 0.05, method = "integral") } \arguments{ - \item{DATA.hist}{histogram object of the data} + \item{datahist}{histogram object of the data} \item{FUN}{Characteristic function (integral) or Saddlepoint distribution approximation (saddlepoint)}