R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(423,114,427,116,441,153,449,162,452,161,462,149,455,139,461,135,461,130,463,127,462,122,456,117,455,112,456,113,472,149,472,157,471,157,465,147,459,137,465,132,468,125,467,123,463,117,460,114,462,111,461,112,476,144,476,150,471,149,453,134,443,123,442,116,444,117,438,111,427,105,424,102,416,95,406,93,431,124,434,130,418,124,412,115,404,106,409,105,412,105,406,101,398,95,397,93,385,84,390,87,413,116,413,120,401,117,397,109,397,105,409,107,419,109,424,109,428,108,430,107),dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Y','X'),1:60))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 423 114 1 0 0 0 0 0 0 0 0 0 0 1
2 427 116 0 1 0 0 0 0 0 0 0 0 0 2
3 441 153 0 0 1 0 0 0 0 0 0 0 0 3
4 449 162 0 0 0 1 0 0 0 0 0 0 0 4
5 452 161 0 0 0 0 1 0 0 0 0 0 0 5
6 462 149 0 0 0 0 0 1 0 0 0 0 0 6
7 455 139 0 0 0 0 0 0 1 0 0 0 0 7
8 461 135 0 0 0 0 0 0 0 1 0 0 0 8
9 461 130 0 0 0 0 0 0 0 0 1 0 0 9
10 463 127 0 0 0 0 0 0 0 0 0 1 0 10
11 462 122 0 0 0 0 0 0 0 0 0 0 1 11
12 456 117 0 0 0 0 0 0 0 0 0 0 0 12
13 455 112 1 0 0 0 0 0 0 0 0 0 0 13
14 456 113 0 1 0 0 0 0 0 0 0 0 0 14
15 472 149 0 0 1 0 0 0 0 0 0 0 0 15
16 472 157 0 0 0 1 0 0 0 0 0 0 0 16
17 471 157 0 0 0 0 1 0 0 0 0 0 0 17
18 465 147 0 0 0 0 0 1 0 0 0 0 0 18
19 459 137 0 0 0 0 0 0 1 0 0 0 0 19
20 465 132 0 0 0 0 0 0 0 1 0 0 0 20
21 468 125 0 0 0 0 0 0 0 0 1 0 0 21
22 467 123 0 0 0 0 0 0 0 0 0 1 0 22
23 463 117 0 0 0 0 0 0 0 0 0 0 1 23
24 460 114 0 0 0 0 0 0 0 0 0 0 0 24
25 462 111 1 0 0 0 0 0 0 0 0 0 0 25
26 461 112 0 1 0 0 0 0 0 0 0 0 0 26
27 476 144 0 0 1 0 0 0 0 0 0 0 0 27
28 476 150 0 0 0 1 0 0 0 0 0 0 0 28
29 471 149 0 0 0 0 1 0 0 0 0 0 0 29
30 453 134 0 0 0 0 0 1 0 0 0 0 0 30
31 443 123 0 0 0 0 0 0 1 0 0 0 0 31
32 442 116 0 0 0 0 0 0 0 1 0 0 0 32
33 444 117 0 0 0 0 0 0 0 0 1 0 0 33
34 438 111 0 0 0 0 0 0 0 0 0 1 0 34
35 427 105 0 0 0 0 0 0 0 0 0 0 1 35
36 424 102 0 0 0 0 0 0 0 0 0 0 0 36
37 416 95 1 0 0 0 0 0 0 0 0 0 0 37
38 406 93 0 1 0 0 0 0 0 0 0 0 0 38
39 431 124 0 0 1 0 0 0 0 0 0 0 0 39
40 434 130 0 0 0 1 0 0 0 0 0 0 0 40
41 418 124 0 0 0 0 1 0 0 0 0 0 0 41
42 412 115 0 0 0 0 0 1 0 0 0 0 0 42
43 404 106 0 0 0 0 0 0 1 0 0 0 0 43
44 409 105 0 0 0 0 0 0 0 1 0 0 0 44
45 412 105 0 0 0 0 0 0 0 0 1 0 0 45
46 406 101 0 0 0 0 0 0 0 0 0 1 0 46
47 398 95 0 0 0 0 0 0 0 0 0 0 1 47
48 397 93 0 0 0 0 0 0 0 0 0 0 0 48
49 385 84 1 0 0 0 0 0 0 0 0 0 0 49
50 390 87 0 1 0 0 0 0 0 0 0 0 0 50
51 413 116 0 0 1 0 0 0 0 0 0 0 0 51
52 413 120 0 0 0 1 0 0 0 0 0 0 0 52
53 401 117 0 0 0 0 1 0 0 0 0 0 0 53
54 397 109 0 0 0 0 0 1 0 0 0 0 0 54
55 397 105 0 0 0 0 0 0 1 0 0 0 0 55
56 409 107 0 0 0 0 0 0 0 1 0 0 0 56
57 419 109 0 0 0 0 0 0 0 0 1 0 0 57
58 424 109 0 0 0 0 0 0 0 0 0 1 0 58
59 428 108 0 0 0 0 0 0 0 0 0 0 1 59
60 430 107 0 0 0 0 0 0 0 0 0 0 0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
210.0973 2.0122 4.3311 1.8743 -46.1727 -57.4978
M5 M6 M7 M8 M9 M10
-59.5154 -42.8282 -31.5653 -20.1732 -13.1958 -8.6037
M11 t
-3.1897 0.2445
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-31.525 -7.704 0.856 8.210 18.105
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 210.0973 38.6525 5.436 2.01e-06 ***
X 2.0122 0.2896 6.948 1.09e-08 ***
M1 4.3311 8.8890 0.487 0.628403
M2 1.8743 8.7144 0.215 0.830651
M3 -46.1727 10.8850 -4.242 0.000106 ***
M4 -57.4978 12.3534 -4.654 2.78e-05 ***
M5 -59.5154 12.0256 -4.949 1.04e-05 ***
M6 -42.8282 10.0932 -4.243 0.000106 ***
M7 -31.5653 8.9428 -3.530 0.000957 ***
M8 -20.1732 8.7004 -2.319 0.024911 *
M9 -13.1958 8.5985 -1.535 0.131715
M10 -8.6037 8.4275 -1.021 0.312638
M11 -3.1897 8.2534 -0.386 0.700935
t 0.2445 0.2225 1.099 0.277587
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 13.01 on 46 degrees of freedom
Multiple R-squared: 0.8093, Adjusted R-squared: 0.7554
F-statistic: 15.02 on 13 and 46 DF, p-value: 2.027e-12
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.2038606 4.077211e-01 7.961394e-01
[2,] 0.9479245 1.041510e-01 5.207551e-02
[3,] 0.9932151 1.356987e-02 6.784935e-03
[4,] 0.9991784 1.643273e-03 8.216366e-04
[5,] 0.9995574 8.852995e-04 4.426497e-04
[6,] 0.9995320 9.360621e-04 4.680311e-04
[7,] 0.9997205 5.589932e-04 2.794966e-04
[8,] 0.9997651 4.698416e-04 2.349208e-04
[9,] 0.9998691 2.618407e-04 1.309204e-04
[10,] 0.9999821 3.573663e-05 1.786831e-05
[11,] 0.9999485 1.030841e-04 5.154203e-05
[12,] 0.9999479 1.041465e-04 5.207323e-05
[13,] 0.9999681 6.383505e-05 3.191752e-05
[14,] 0.9999960 8.070534e-06 4.035267e-06
[15,] 0.9999960 8.027457e-06 4.013729e-06
[16,] 0.9999962 7.585948e-06 3.792974e-06
[17,] 0.9999972 5.674404e-06 2.837202e-06
[18,] 0.9999990 2.047370e-06 1.023685e-06
[19,] 0.9999987 2.608697e-06 1.304349e-06
[20,] 0.9999985 2.967153e-06 1.483576e-06
[21,] 0.9999981 3.835156e-06 1.917578e-06
[22,] 0.9999895 2.090396e-05 1.045198e-05
[23,] 0.9999616 7.688891e-05 3.844445e-05
[24,] 0.9999671 6.582579e-05 3.291290e-05
[25,] 0.9998994 2.012334e-04 1.006167e-04
[26,] 0.9999806 3.870098e-05 1.935049e-05
[27,] 0.9996235 7.530827e-04 3.765414e-04
> postscript(file="/var/www/html/rcomp/tmp/1q6du1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/2s4ap1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3w7sa1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/48fzg1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/565ab1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> qqline(mysum$resid)
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 60
Frequency = 1
1 2 3 4 5 6
-21.0635923 -18.8757919 -31.5245903 -30.5538693 -23.7685089 -6.5538693
7 8 9 10 11 12
-4.9392298 -2.5270302 0.3120085 3.5120085 6.9144484 7.5412876
13 14 15 16 17 18
12.0267252 13.2267252 4.5901264 -0.4269530 0.3462078 -2.4635518
19 20 21 22 23 24
0.1510877 4.5754869 14.4389248 12.6267252 15.0413647 14.6438047
25 26 27 28 29 30
18.1048431 17.3048431 15.7170427 14.7243625 13.5097230 8.7609613
31 32 33 34 35 36
9.3878004 10.8365988 3.6024399 4.8390387 0.2536782 -0.1438818
37 38 39 40 41 42
1.3659550 -2.3974462 8.0269530 10.0342728 7.8806313 3.0586720
43 44 45 46 47 48
1.6611119 -2.9632873 -7.1852466 -9.9730470 -11.5584074 -11.9681671
49 50 51 52 53 54
-10.4339311 -9.2583303 3.1904681 6.2221871 2.0319468 -2.8022121
55 56 57 58 59 60
-6.2607702 -9.9217682 -11.1681267 -11.0047255 -10.6510840 -10.0730433
> postscript(file="/var/www/html/rcomp/tmp/6r62b1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 -21.0635923 NA
1 -18.8757919 -21.0635923
2 -31.5245903 -18.8757919
3 -30.5538693 -31.5245903
4 -23.7685089 -30.5538693
5 -6.5538693 -23.7685089
6 -4.9392298 -6.5538693
7 -2.5270302 -4.9392298
8 0.3120085 -2.5270302
9 3.5120085 0.3120085
10 6.9144484 3.5120085
11 7.5412876 6.9144484
12 12.0267252 7.5412876
13 13.2267252 12.0267252
14 4.5901264 13.2267252
15 -0.4269530 4.5901264
16 0.3462078 -0.4269530
17 -2.4635518 0.3462078
18 0.1510877 -2.4635518
19 4.5754869 0.1510877
20 14.4389248 4.5754869
21 12.6267252 14.4389248
22 15.0413647 12.6267252
23 14.6438047 15.0413647
24 18.1048431 14.6438047
25 17.3048431 18.1048431
26 15.7170427 17.3048431
27 14.7243625 15.7170427
28 13.5097230 14.7243625
29 8.7609613 13.5097230
30 9.3878004 8.7609613
31 10.8365988 9.3878004
32 3.6024399 10.8365988
33 4.8390387 3.6024399
34 0.2536782 4.8390387
35 -0.1438818 0.2536782
36 1.3659550 -0.1438818
37 -2.3974462 1.3659550
38 8.0269530 -2.3974462
39 10.0342728 8.0269530
40 7.8806313 10.0342728
41 3.0586720 7.8806313
42 1.6611119 3.0586720
43 -2.9632873 1.6611119
44 -7.1852466 -2.9632873
45 -9.9730470 -7.1852466
46 -11.5584074 -9.9730470
47 -11.9681671 -11.5584074
48 -10.4339311 -11.9681671
49 -9.2583303 -10.4339311
50 3.1904681 -9.2583303
51 6.2221871 3.1904681
52 2.0319468 6.2221871
53 -2.8022121 2.0319468
54 -6.2607702 -2.8022121
55 -9.9217682 -6.2607702
56 -11.1681267 -9.9217682
57 -11.0047255 -11.1681267
58 -10.6510840 -11.0047255
59 -10.0730433 -10.6510840
60 NA -10.0730433
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -18.8757919 -21.0635923
[2,] -31.5245903 -18.8757919
[3,] -30.5538693 -31.5245903
[4,] -23.7685089 -30.5538693
[5,] -6.5538693 -23.7685089
[6,] -4.9392298 -6.5538693
[7,] -2.5270302 -4.9392298
[8,] 0.3120085 -2.5270302
[9,] 3.5120085 0.3120085
[10,] 6.9144484 3.5120085
[11,] 7.5412876 6.9144484
[12,] 12.0267252 7.5412876
[13,] 13.2267252 12.0267252
[14,] 4.5901264 13.2267252
[15,] -0.4269530 4.5901264
[16,] 0.3462078 -0.4269530
[17,] -2.4635518 0.3462078
[18,] 0.1510877 -2.4635518
[19,] 4.5754869 0.1510877
[20,] 14.4389248 4.5754869
[21,] 12.6267252 14.4389248
[22,] 15.0413647 12.6267252
[23,] 14.6438047 15.0413647
[24,] 18.1048431 14.6438047
[25,] 17.3048431 18.1048431
[26,] 15.7170427 17.3048431
[27,] 14.7243625 15.7170427
[28,] 13.5097230 14.7243625
[29,] 8.7609613 13.5097230
[30,] 9.3878004 8.7609613
[31,] 10.8365988 9.3878004
[32,] 3.6024399 10.8365988
[33,] 4.8390387 3.6024399
[34,] 0.2536782 4.8390387
[35,] -0.1438818 0.2536782
[36,] 1.3659550 -0.1438818
[37,] -2.3974462 1.3659550
[38,] 8.0269530 -2.3974462
[39,] 10.0342728 8.0269530
[40,] 7.8806313 10.0342728
[41,] 3.0586720 7.8806313
[42,] 1.6611119 3.0586720
[43,] -2.9632873 1.6611119
[44,] -7.1852466 -2.9632873
[45,] -9.9730470 -7.1852466
[46,] -11.5584074 -9.9730470
[47,] -11.9681671 -11.5584074
[48,] -10.4339311 -11.9681671
[49,] -9.2583303 -10.4339311
[50,] 3.1904681 -9.2583303
[51,] 6.2221871 3.1904681
[52,] 2.0319468 6.2221871
[53,] -2.8022121 2.0319468
[54,] -6.2607702 -2.8022121
[55,] -9.9217682 -6.2607702
[56,] -11.1681267 -9.9217682
[57,] -11.0047255 -11.1681267
[58,] -10.6510840 -11.0047255
[59,] -10.0730433 -10.6510840
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -18.8757919 -21.0635923
2 -31.5245903 -18.8757919
3 -30.5538693 -31.5245903
4 -23.7685089 -30.5538693
5 -6.5538693 -23.7685089
6 -4.9392298 -6.5538693
7 -2.5270302 -4.9392298
8 0.3120085 -2.5270302
9 3.5120085 0.3120085
10 6.9144484 3.5120085
11 7.5412876 6.9144484
12 12.0267252 7.5412876
13 13.2267252 12.0267252
14 4.5901264 13.2267252
15 -0.4269530 4.5901264
16 0.3462078 -0.4269530
17 -2.4635518 0.3462078
18 0.1510877 -2.4635518
19 4.5754869 0.1510877
20 14.4389248 4.5754869
21 12.6267252 14.4389248
22 15.0413647 12.6267252
23 14.6438047 15.0413647
24 18.1048431 14.6438047
25 17.3048431 18.1048431
26 15.7170427 17.3048431
27 14.7243625 15.7170427
28 13.5097230 14.7243625
29 8.7609613 13.5097230
30 9.3878004 8.7609613
31 10.8365988 9.3878004
32 3.6024399 10.8365988
33 4.8390387 3.6024399
34 0.2536782 4.8390387
35 -0.1438818 0.2536782
36 1.3659550 -0.1438818
37 -2.3974462 1.3659550
38 8.0269530 -2.3974462
39 10.0342728 8.0269530
40 7.8806313 10.0342728
41 3.0586720 7.8806313
42 1.6611119 3.0586720
43 -2.9632873 1.6611119
44 -7.1852466 -2.9632873
45 -9.9730470 -7.1852466
46 -11.5584074 -9.9730470
47 -11.9681671 -11.5584074
48 -10.4339311 -11.9681671
49 -9.2583303 -10.4339311
50 3.1904681 -9.2583303
51 6.2221871 3.1904681
52 2.0319468 6.2221871
53 -2.8022121 2.0319468
54 -6.2607702 -2.8022121
55 -9.9217682 -6.2607702
56 -11.1681267 -9.9217682
57 -11.0047255 -11.1681267
58 -10.6510840 -11.0047255
59 -10.0730433 -10.6510840
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7fetx1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8bhdn1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9xdka1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10bw2h1258736758.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11t62l1258736758.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/127fjr1258736758.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/135c551258736759.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/14l20x1258736759.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/15z7io1258736759.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/1699wa1258736759.tab")
+ }
>
> system("convert tmp/1q6du1258736758.ps tmp/1q6du1258736758.png")
> system("convert tmp/2s4ap1258736758.ps tmp/2s4ap1258736758.png")
> system("convert tmp/3w7sa1258736758.ps tmp/3w7sa1258736758.png")
> system("convert tmp/48fzg1258736758.ps tmp/48fzg1258736758.png")
> system("convert tmp/565ab1258736758.ps tmp/565ab1258736758.png")
> system("convert tmp/6r62b1258736758.ps tmp/6r62b1258736758.png")
> system("convert tmp/7fetx1258736758.ps tmp/7fetx1258736758.png")
> system("convert tmp/8bhdn1258736758.ps tmp/8bhdn1258736758.png")
> system("convert tmp/9xdka1258736758.ps tmp/9xdka1258736758.png")
> system("convert tmp/10bw2h1258736758.ps tmp/10bw2h1258736758.png")
>
>
> proc.time()
user system elapsed
2.363 1.532 2.803