[R] printing all htest class members
dwinsemius at comcast.net
Thu Dec 15 20:04:29 CET 2011
On Dec 15, 2011, at 12:26 PM, Rui Barradas wrote:
> I've posted a question about this subject yesterday, but since there
> was no
> R code to comment,
> no one did.
> I'm trying to have the print method for class 'htest' print some extra
> information common in some test, like the time series linearity
> tests. Many of them have an 'order' parameter, representing a lag or
> embedding dimension, and it would be a nice feature to pass a vector
> orders and have all corresponding tests run.
> It's easy to do this, but the print method doesn't print those extra
> Here the code goes:
> #Some values from the McLeod-Li test, with x <- rnorm(100)
> res <- data.frame(ord=2:4, df=ord, Q=c(0.0129, 0.049, 0.0684),
> p=c(0.9936, 0.9972, 0.9994))
> nr <- nrow(res)
My problem reading this is that you are using the attach function
which generally confuses discussions and then you are not actually
creating any object with a class of htest. Print methods are
dispatched by class value.
> # print.htest prints everything but 'all.orders'
> # but when it's named 'null.value' it works and it's easier to make
> # it work, all what's needed is 'null.value=res', whithout the need
> # for a second 'structure()'
You seem to be transcribing a conversation inside your head. Most of
the four lines above has no connection to what you typed earlier.
This does nothing. No object is created.
> alternative="It doesn't print 'all.orders' and I find 'null.value'
> method="Test the 'print.htest' method using McLeod-Li test values.",
> list(order=ord, df=df, Q=Q, p.value=p),
> .Names=c("order", "df", "Q", "p.value"),
> Is there a way to have 'all.orders' printed by 'print.htest' ?
> The problem is NOT the return values, at least the time wasn't wasted,
> I can use them for whatever I'll do next.
> If not, anyone has any suggestions?
Yes. Give the code you are actually using!
David Winsemius, MD
West Hartford, CT
More information about the R-help