Function to check whether the argument is coherent and in the correct format.

is.theta(theta, check.class = TRUE)

Arguments

theta

A list on the theta-form described in rtheta

check.class

Logical. If TRUE, the class of theta is also checked.

Value

logical. Returns TRUE if theta is coherent and in the correct format. Otherwise, the function returns FALSE with an accompanying warning message of the problem.

See also

Author

Anders Ellern Bilgrau <anders.ellern.bilgrau@gmail.com>

Examples

theta1 <- rtheta() # Create a random correctly formatted theta is.theta(theta1)
#> [1] TRUE
theta2 <- rtheta(d = 3, m = 5) theta2$m <- 6 # m is now incoherent with the number of components is.theta(theta2)
#> Warning: theta[[3]] is not a vector of length 6 as defined by theta[[1]]
#> [1] FALSE
theta3 <- rtheta(d = 4, m = 2) theta3$sigma$comp1[1, 2] <- 0 # Making the covariance matrix non-symmetric is.theta(theta3)
#> Warning: Not all covariance matrices are symmetric.
#> [1] FALSE
theta4 <- rtheta(d = 10, m = 10) theta4$sigma$comp1[1, 1] <- 0 # Destroy positive semi-definiteness is.theta(theta4)
#> Warning: Not all covariance matrices are postive semi-definite.
#> [1] FALSE
theta5 <- rtheta() names(theta5) <- c("m", "d", "prop", "mu", "sigmas") # Incorrect names is.theta(theta5)
#> Warning: names(theta) does not equal c("m", "d", "pie", "mu", "sigma")
#> [1] FALSE