1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#' Method to get the names of ill-defined parameters
#'
#' @param object The object to investigate
#' @param x The object to be printed
#' @param conf.level The confidence level for checking p values
#' @param \dots For potential future extensions
#' @return For [mkinfit] objects, a character vector of parameter names
#' For [mmkin] objects, an object of class 'illparms.mmkin' with a
#' suitable printing method.
#' @export
illparms <- function(object, ...)
{
UseMethod("illparms", object)
}
#' @rdname illparms
#' @export
#' @examples
#' fit <- mkinfit("FOMC", FOCUS_2006_A, quiet = TRUE)
#' illparms(fit)
illparms.mkinfit <- function(object, conf.level = 0.95, ...) {
p_values <- suppressWarnings(summary(object)$bpar[, "Pr(>t)"])
na <- is.na(p_values)
failed <- p_values > 1 - conf.level
names(parms(object))[na | failed]
}
#' @rdname illparms
#' @export
#' @examples
#' \dontrun{
#' fits <- mmkin(
#' c("SFO", "FOMC"),
#' list("FOCUS A" = FOCUS_2006_A,
#' "FOCUS C" = FOCUS_2006_C),
#' quiet = TRUE)
#' illparms(fits)
#' }
illparms.mmkin <- function(object, conf.level = 0.95, ...) {
result <- lapply(object,
function(fit) {
if (inherits(fit, "try-error")) return("E")
ill <- illparms(fit, conf.level = conf.level)
if (length(ill) > 0) {
return(paste(ill, collapse = ", "))
} else {
return("")
}
})
result <- unlist(result)
dim(result) <- dim(object)
dimnames(result) <- dimnames(object)
class(result) <- "illparms.mmkin"
return(result)
}
#' @rdname illparms
#' @export
print.illparms.mmkin <- function(x, ...) {
class(x) <- NULL
print(x, quote = FALSE)
}
|