[R] printing all htest class members

Rui Barradas ruipbarradas at sapo.pt
Thu Dec 15 18:26:05 CET 2011


Hello, 

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 related
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 of
orders and have all corresponding tests run.

It's easy to do this, but the print method doesn't print those extra values.
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))
attach(res)
nr <- nrow(res)

# 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()'
structure(
	list(statistic=c(Q=Q[1]),
		p.value=p[1],
		parameter=c(df=df[1]),
		alternative="It doesn't print 'all.orders' and I find 'null.value'
misleading",
		method="Test the 'print.htest' method using McLeod-Li test values.",
		data.name=deparse(substitute(x)),
		all.orders=structure(
			list(order=ord, df=df, Q=Q, p.value=p),
			.Names=c("order", "df", "Q", "p.value"),
			row.names=c(NA,-nr),
			class="data.frame"
		)
	),
	.Names=c("statistic","p.value","parameter","alternative",
			"method","data.name","all.orders"),
	class="htest"
)

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?

Thank you in advance,

Rui Barradas


--
View this message in context: http://r.789695.n4.nabble.com/printing-all-htest-class-members-tp4200872p4200872.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list