-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathisFunctions.R
87 lines (80 loc) · 2.32 KB
/
isFunctions.R
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#' Greybox classes checkers
#'
#' Functions to check if an object is of the specified class
#'
#' The list of functions includes:
#' \itemize{
#' \item \code{is.greybox()} tests if the object was produced by a greybox function
#' (e.g. \link[greybox]{alm} / \link[greybox]{stepwise} / \link[greybox]{lmCombine}
#' / \link[greybox]{lmDynamic});
#' \item \code{is.alm()} tests if the object was produced by \code{alm()} function;
#' \item \code{is.occurrence()} tests if an occurrence part of the model was produced;
#' \item \code{is.greyboxC()} tests if the object was produced by \code{lmCombine()}
#' function;
#' \item \code{is.greyboxD()} tests if the object was produced by \code{lmDynamic()}
#' function;
#' \item \code{is.rmc()} tests if the object was produced by \code{rmc()} function;
#' \item \code{is.rollingOrigin()} tests if the object was produced by \code{ro()}
#' function;
#' \item \code{is.scale()} tests if the object is of the class "scale" (produced by
#' \link[greybox]{alm} or \link[greybox]{sm} in case of heteroscedastic model);
#' }
#'
#' @param x The object to check.
#' @return \code{TRUE} if this is the specified class and \code{FALSE} otherwise.
#'
#' @template author
#' @keywords ts univar
#' @examples
#'
#' xreg <- cbind(rlaplace(100,10,3),rnorm(100,50,5))
#' xreg <- cbind(100+0.5*xreg[,1]-0.75*xreg[,2]+rlaplace(100,0,3),xreg,rnorm(100,300,10))
#' colnames(xreg) <- c("y","x1","x2","Noise")
#'
#' ourModel <- alm(y~x1+x2, xreg, distribution="dnorm")
#'
#' is.alm(ourModel)
#' is.greybox(ourModel)
#' is.greyboxC(ourModel)
#' is.greyboxD(ourModel)
#'
#' @rdname isFunctions
#' @export
is.greybox <- function(x){
return(inherits(x,"greybox"))
}
#' @rdname isFunctions
#' @export
is.alm <- function(x){
return(inherits(x,"alm"))
}
#' @rdname isFunctions
#' @export
is.occurrence <- function(x){
return(inherits(x,"occurrence"))
}
#' @rdname isFunctions
#' @export
is.greyboxC <- function(x){
return(inherits(x,"greyboxC"))
}
#' @rdname isFunctions
#' @export
is.greyboxD <- function(x){
return(inherits(x,"greyboxD"))
}
#' @rdname isFunctions
#' @export
is.rollingOrigin <- function(x){
return(inherits(x,"rollingOrigin"))
}
#' @rdname isFunctions
#' @export
is.rmc <- function(x){
return(inherits(x,"rmc"))
}
#' @rdname isFunctions
#' @export
is.scale <- function(x){
return(inherits(x,"scale"))
}