I sort of asked this before, but perhaps not explicitly enough. In my ctest collection, there are several chisquare-based tests. For some of them, it may be useful to also return information on expected (and observed) counts. The question is, how should this be done. Of course, there is no problem adding the corresponding components to the list returned by the functions. However, as these are of class `htest', the components don't show up in the printed output. (Of course, one can easily obtain them if they are in the list, but I think Peter is with me when I say that this is not the right thing in an intro course.) * Should we extend print.htest() to display info on expected and observed counts in case it is there? * (Should we have an extra argument to control this behavior?) * Or should there be a class "chisqtest" with a slightly different print and perhaps also summary method? * Or ...? -k =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Kurt Hornik <hornik@ci.tuwien.ac.at> writes:> > I sort of asked this before, but perhaps not explicitly enough. > > In my ctest collection, there are several chisquare-based tests. For > some of them, it may be useful to also return information on expected > (and observed) counts. The question is, how should this be done. Of > course, there is no problem adding the corresponding components to the > list returned by the functions. However, as these are of class `htest', > the components don't show up in the printed output. > > (Of course, one can easily obtain them if they are in the list, but I > think Peter is with me when I say that this is not the right thing in an > intro course.) > > * Should we extend print.htest() to display info on expected and > observed counts in case it is there? > > * (Should we have an extra argument to control this behavior?) > > * Or should there be a class "chisqtest" with a slightly different print > and perhaps also summary method? > > * Or ...?Couldn't the basic logic of print.lm/summary.lm/anova.lm be applied here too? I.e. h<-chisquare.test(blipblop) observed(h) fitted(h) partials(h) This might be implemented simply by adding items to the return list, and have fitted.htest() extract the relevant item if it is there. Or maybe slightly safer from a name-space point of view: add *one* extra item ("comp", say) which is a list containing the other stuff. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Martin Maechler
1997-Aug-22 06:59 UTC
R-alpha: class for chisquare tests; Thoughts on print & summary
Kurt, I think we hopefully are coming to an agreement that 1) your ctest collection should make its way into 'R core' ((and you are the one who can make it happen now ..)) 2) it should remain S-plus downward compatible as much as reasonably possible. My conclusions: a. keep class 'htest' b. extend print.htest (AND summary.htest !) to make it possible to display your extra info. b2. Yes, add extra arguments to print.htest / summary.htest to control this behavior. [this is also done for the correlation matrix in print.summary.lm in S (not yet in R ..)] alternatively, you would make a new class 'chisqtest' but give your test results BOTH classes class(res) <- c("chisqtest","htest") Such that you can use 'htest' methods in general, and just one print.chisqtest in particular. General note on 'print' (and 'summary') methods: ~~~~~~~~~~~~ ===== 1) I think we should keep to the S convention that EVERY print method semantically acts as print.foo <- function(x,.........) { ......... invisible(x) } [[a few days ago, I've patched print.lm (?I think) in order to do this]] 2) For summary, there are two approaches A. Just print summary information AND return something useful. B. Don't print anything in summary.foo but return an object of CLASS 'summary.foo' AND write a method print.summary.foo which nicely prints the summary.foo information and [see remark '1)' on "print"] invisibly returns its object. Approach 'B' is THE way to go useful for "big" things like 'lm'. IMHO it should be used in general as soon as quite a bit of "computing" is involved ("computing" is NOT computer intensive; just things that are tedious to re-type). =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-