1##
2## Setting methods for classes
3##
4show.urca <- function(object){
5  title <- paste("#", object@test.name, "Unit Root / Cointegration Test #", sep=" ")
6  row <- paste(rep("#", nchar(title)), collapse="")
7  cat("\n")
8  cat(row, "\n")
9  cat(title, "\n")
10  cat(row, "\n")
11  cat("\n")
12  cat("The value of the test statistic is:", round(object@teststat, 4), "\n")
13  cat('\n')
14}
15
16setMethod("show", "ur.kpss", show.urca)
17setMethod("show", "ca.jo", show.urca)
18setMethod("show", "cajo.test", show.urca)
19setMethod("show", "ca.po", show.urca)
20setMethod("show", "ur.pp", show.urca)
21setMethod("show", "ur.df", show.urca)
22setMethod("show", "ur.sp", show.urca)
23setMethod("show", "ur.za", show.urca)
24setMethod("show", "ur.ers", show.urca)
25
26setMethod("show", "sumurca", function(object){
27  if(object@classname=="ur.za"){
28    title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
29    row <- paste(rep("#", nchar(title)), collapse="")
30    cat("\n")
31    cat(row, "\n")
32    cat(title, "\n")
33    cat(row, "\n")
34    cat("\n")
35    print(summary(object@testreg))
36    cat('\n')
37    cat('Teststatistic:', round(object@teststat, 4), '\n')
38    cat('Critical values: 0.01=', object@cval[1], '0.05=', object@cval[2], '0.1=', object@cval[3], '\n')
39    cat('\n')
40    cat('Potential break point at position:', object@bpoint, '\n')
41    cat('\n')
42    invisible(object)
43  }else if(object@classname=="ur.sp"){
44    title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
45    row <- paste(rep("#", nchar(title)), collapse="")
46    cat("\n")
47    cat(row, "\n")
48    cat(title, "\n")
49    cat(row, "\n")
50    cat("\n")
51    print(object@testreg)
52    cat('\n')
53    cat('Value of test-statistic is:', round(object@teststat, 4), '\n')
54    cat('Critical value for a significance level of', object@signif, '\n')
55    cat('is:', object@cval, '\n')
56    cat('\n')
57    invisible(object)
58  }else if(object@classname=="ur.pp"){
59    title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
60    row <- paste(rep("#", nchar(title)), collapse="")
61    cat("\n")
62    cat(row, "\n")
63    cat(title, "\n")
64    cat(row, "\n")
65    cat("\n")
66    cat('Test regression', object@model, '\n')
67    cat('\n')
68    print(object@testreg)
69    cat('\n')
70    cat('Value of test-statistic, type:', object@type,' is:', round(object@teststat, 4), '\n')
71    cat('\n')
72    print(object@auxstat)
73    cat('\n')
74    if(identical(object@type, "Z-tau")){
75      cat('Critical values for Z statistics: \n')
76      print(object@cval)
77      cat('\n')
78    }
79    invisible(object)
80  }else if(object@classname=="ur.df"){
81    title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
82    row <- paste(rep("#", nchar(title)), collapse="")
83    cat("\n")
84    cat(row, "\n")
85    cat(title, "\n")
86    cat(row, "\n")
87    cat("\n")
88    cat('Test regression', object@model, '\n')
89    cat('\n')
90    print(object@testreg)
91    cat('\n')
92    cat('Value of test-statistic is:', round(object@teststat, 4), '\n')
93    cat('\n')
94    cat('Critical values for test statistics: \n')
95    print(object@cval)
96    cat('\n')
97    invisible(object)
98  }else if(object@classname=="ca.po"){
99    title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
100    row <- paste(rep("#", nchar(title)), collapse="")
101    cat("\n")
102    cat(row, "\n")
103    cat(title, "\n")
104    cat(row, "\n")
105    cat("\n")
106    cat("Test of type", object@type, "\ndetrending of series", object@model, "\n")
107    cat("\n")
108    print(object@testreg)
109    cat('\n')
110    cat('Value of test-statistic is:', round(object@teststat, 4), '\n')
111    cat('\n')
112    cat('Critical values of', object@type, "are:\n")
113    print(object@cval)
114    cat('\n')
115    invisible(object)
116    }else if(object@classname=="ur.kpss"){
117      title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
118      row <- paste(rep("#", nchar(title)), collapse="")
119      cat("\n")
120      cat(row, "\n")
121      cat(title, "\n")
122      cat(row, "\n")
123      cat("\n")
124      cat('Test is of type:', object@type, 'with', object@lag, 'lags. \n')
125      cat('\n')
126      cat('Value of test-statistic is:', round(object@teststat, 4), '\n')
127      cat('\n')
128      cat('Critical value for a significance level of: \n')
129      print(object@cval)
130      cat('\n')
131      invisible(object)
132    }else if(object@classname=="cajo.test"){
133      title <- paste("#", object@test.name, "#", sep=" ")
134      row <- paste(rep("#", nchar(title)), collapse="")
135      cat("\n")
136      cat(row, "\n")
137      cat(title, "\n")
138      cat(row, "\n")
139      cat("\n")
140      cat(object@type, "\n")
141      cat("\n")
142      cat("The VECM has been estimated subject to: \n")
143      cat("beta=H*phi and/or alpha=A*psi\n")
144      if(!is.null(object@H)){
145        cat("\n")
146        print(object@H)
147        cat("\n")
148      }
149      if(!is.null(object@A)){
150        cat("\n")
151        print(object@A)
152        cat("\n")
153      }
154      cat("Eigenvalues of restricted VAR (lambda):\n")
155      print(round(object@lambda, 4))
156      cat('\n')
157      cat("The value of the likelihood ratio test statistic:\n")
158      cat(round(object@teststat, 2), "distributed as chi square with", object@pval[2], "df.\n")
159      cat("The p-value of the test statistic is:", round(object@pval[1], 2), "\n")
160      cat("\n")
161      cat("Eigenvectors, normalised to first column\n")
162      cat("of the restricted VAR:\n")
163      cat("\n")
164      print(round(object@V, 4))
165      cat("\n")
166      cat("Weights W of the restricted VAR:\n")
167      cat("\n")
168      print(round(object@W, 4))
169      cat("\n")
170      invisible(object)
171    }else if(object@classname=="ca.jo"){
172      title <- paste("#", object@test.name, "#", sep=" ")
173      row <- paste(rep("#", nchar(title)), collapse="")
174      cat("\n")
175      cat(row, "\n")
176      cat(title, "\n")
177      cat(row, "\n")
178      cat("\n")
179      cat("Test type:", object@type, ",", object@model, "\n")
180      cat("\n")
181      cat("Eigenvalues (lambda):\n")
182      print(object@lambda)
183      cat('\n')
184      if(!(is.null(object@cval))){
185        res1 <- as.matrix(round(object@teststat, 2))
186        colnames(res1) <- "test"
187        result <- cbind(res1, object@cval)
188        cat("Values of teststatistic and critical values of test:\n")
189        cat("\n")
190        print(result)
191        cat("\n")
192      }else{
193        cat("Values of test statistic\n")
194        cat("\n")
195        result <- as.matrix(object@teststat)
196        rownames(result) <- c(paste("r <= ", (object@P-1):1, " |",sep=""), "r = 0  |")
197        print(result)
198        cat("\n")
199        invisible(object)
200      }
201      cat("Eigenvectors, normalised to first column:\n")
202      cat("(These are the cointegration relations)\n")
203      cat("\n")
204      print(object@V)
205      cat("\n")
206      cat("Weights W:\n")
207      cat("(This is the loading matrix)\n")
208      cat("\n")
209      print(object@W)
210      cat("\n")
211      invisible(object)
212    }else if(object@classname=="ur.ers"){
213      title <- paste("#", object@test.name, "Unit Root Test #", sep=" ")
214      row <- paste(rep("#", nchar(title)), collapse="")
215      cat("\n")
216      cat(row, "\n")
217      cat(title, "\n")
218      cat(row, "\n")
219      cat("\n")
220      cat("Test of type", object@type, "\ndetrending of series", object@model, "\n")
221      cat("\n")
222      if(!is.null(object@testreg)){
223        print(object@testreg)
224        cat('\n')
225      }
226      cat('Value of test-statistic is:', round(object@teststat, 4), '\n')
227      cat('\n')
228      cat('Critical values of', object@type, "are:\n")
229      print(object@cval)
230      cat('\n')
231      invisible(object)
232    }
233})
234