| dg.Test-class {dynamicGraph} | R Documentation |
An example class for the test object for the model object of dynamicGraph.
An object of class dg.Test.
The methods label and width should be
implemented by you for your test object returned by the method
testEdge of your model object.
deviance:"numeric":
The deviance of the test. df:"numeric":
The df of the test. p:"numeric":
The p-value of the test. signature(object = "dg.Test"):
Return the label of the test. signature(object = "dg.Test"):
Return the width of the test. signature(.Object = "dg.Test"): ... signature(object = "dg.Test"): ... Jens Henrik Badsberg
# Part of the example "defaultObjects" of demo:
setClass("your.Test",
representation(name = "character",
deviance = "numeric", df = "numeric", p = "numeric"))
setMethod("setSlots", "your.Test",
function(object, arguments) {
for (i in seq(along = arguments)) {
name <- names(arguments)[i]
if (is.element(name, slotNames(object)))
slot(object, name) <- arguments[[i]]
else
message(paste("Argument '", name, "' not valid slot of '",
class(object), "', thus ignored.",
sep = "")) }
return(object)
})
setMethod("initialize", "your.Test",
function(.Object, ...) {
# print(c("initialize", "your.Test", class(.Object)))
Args <- list(...)
if (!is.element("df", names(Args)) ||
!is.element("deviance", names(Args))) {
Args <- (Args[!names(Args) == "df"])
Args <- (Args[!names(Args) == "deviance"])
.Object@df <- round(runif(1, 1, 25))
.Object@deviance <- rchisq(1, .Object@df)
.Object@p <- 1 - pchisq(.Object@deviance, .Object@df)
message("Just generating a random test!!!!")
}
.Object <- setSlots(.Object, Args)
return(.Object)
}
)
if (!isGeneric("label") && !isGeneric("label", where = 2)) {
if (is.function("label"))
fun <- label
else
fun <- function(object) standardGeneric("label")
setGeneric("label", fun)
}
setMethod("label", "your.Test",
function(object) format(object@p, digits = 4))
if (!isGeneric("width") && !isGeneric("width", where = 2)) {
if (is.function("width"))
fun <- width
else
fun <- function(object) standardGeneric("width")
setGeneric("width", fun)
}
setMethod("width", "your.Test",
function(object) round(2 + 5 * (1 - object@p)))
new("your.Test", name = "TestObject")