Check the Validity of an Object of Class stsm

Description

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

Usage

1
2
3
4
## S4 method for signature 'stsm'
check.bounds(x)
## S4 method for signature 'stsm'
validObject(object)

Arguments

x

an object of class stsm.

object

an object of class stsm.

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 @<-.

Value

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

See Also

stsm-class and examples in stsm-set-methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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))