Learn R Programming

stsm (version 1.7)

stsm-validObject-methods: Check the Validity of an Object of Class stsm

Description

Methods to check the validity of an object of class stsm.

Usage

"check.bounds"(x) "validObject"(object)

Arguments

x
an object of class stsm.
object
an object of class stsm.

Value

If the input object is valid according to the class definition, the logical TRUE is returned. Otherwise, an error message is returned.

Details

check.bounds checks that the values in the slot pars lie within the lower and upper bounds. These bounds are stored in the slots lower and upper. Default values or specific values can be given when creating the object by means of stsm.model.

check.bounds is called by validObject. In some settings it may be required to check only that the parameters are within the required bounds.

validObject checks additional requirements: e.g. all the parameters taking part in the selected model are either in the slots pars, nopars or cpar;

it is also checked that the parameters are no duplicated in those slots.

This method is called by stsm-set-methods defined for the slots pars, nopars or cpar. That's why it is safer to use the setter methods instead of a direct modification through the operator @<-.

See Also

stsm and examples in stsm-set-methods.

Examples

Run this code
m <- stsm.model(model = "llm+seas", y = JohnsonJohnson, 
  pars = c("var1" = 2, "var2" = 15, "var3" = 30))
validObject(m)

# force a wrong value (negative variance)
m@pars[1] <- -1
try(validObject(m))
try(check.bounds(m))

# duplicates not allowed
m <- stsm.model(model = "llm+seas", y = JohnsonJohnson, 
  pars = c("var1" = 2, "var2" = 15, "var3" = 30))
# try to define 'var1', already in 'pars', in the slot 'nopars'
try(m <- set.nopars(m, c(var1=22)))
# force a duplicate
m@nopars <- c(m@nopars, var1 = 22)
try(validObject(m))

Run the code above in your browser using DataLab