R version 2.12.0 (2010-10-15)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-pc-linux-gnu (32-bit)
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(695,0,638,0,762,0,635,0,721,0,854,0,418,0,367,0,824,0,687,0,601,0,676,0,740,0,691,0,683,0,594,0,729,0,731,0,386,0,331,0,707,0,715,0,657,0,653,0,642,0,643,0,718,0,654,0,632,0,731,0,392,1,344,1,792,1,852,1,649,1,629,1,685,1,617,1,715,1,715,1,629,1,916,1,531,1,357,1,917,1,828,1,708,1,858,1,775,1,785,1,1006,1,789,1,734,1,906,1,532,1,387,1,991,1,841,1,892,1,782,1,813,1,793,1,978,1,775,1,797,1,946,1,594,1,438,1,1022,1,868,1),dim=c(2,70),dimnames=list(c('Y','X'),1:70))
> y <- array(NA,dim=c(2,70),dimnames=list(c('Y','X'),1:70))
> 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
> 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 695 0 1 0 0 0 0 0 0 0 0 0 0 1
2 638 0 0 1 0 0 0 0 0 0 0 0 0 2
3 762 0 0 0 1 0 0 0 0 0 0 0 0 3
4 635 0 0 0 0 1 0 0 0 0 0 0 0 4
5 721 0 0 0 0 0 1 0 0 0 0 0 0 5
6 854 0 0 0 0 0 0 1 0 0 0 0 0 6
7 418 0 0 0 0 0 0 0 1 0 0 0 0 7
8 367 0 0 0 0 0 0 0 0 1 0 0 0 8
9 824 0 0 0 0 0 0 0 0 0 1 0 0 9
10 687 0 0 0 0 0 0 0 0 0 0 1 0 10
11 601 0 0 0 0 0 0 0 0 0 0 0 1 11
12 676 0 0 0 0 0 0 0 0 0 0 0 0 12
13 740 0 1 0 0 0 0 0 0 0 0 0 0 13
14 691 0 0 1 0 0 0 0 0 0 0 0 0 14
15 683 0 0 0 1 0 0 0 0 0 0 0 0 15
16 594 0 0 0 0 1 0 0 0 0 0 0 0 16
17 729 0 0 0 0 0 1 0 0 0 0 0 0 17
18 731 0 0 0 0 0 0 1 0 0 0 0 0 18
19 386 0 0 0 0 0 0 0 1 0 0 0 0 19
20 331 0 0 0 0 0 0 0 0 1 0 0 0 20
21 707 0 0 0 0 0 0 0 0 0 1 0 0 21
22 715 0 0 0 0 0 0 0 0 0 0 1 0 22
23 657 0 0 0 0 0 0 0 0 0 0 0 1 23
24 653 0 0 0 0 0 0 0 0 0 0 0 0 24
25 642 0 1 0 0 0 0 0 0 0 0 0 0 25
26 643 0 0 1 0 0 0 0 0 0 0 0 0 26
27 718 0 0 0 1 0 0 0 0 0 0 0 0 27
28 654 0 0 0 0 1 0 0 0 0 0 0 0 28
29 632 0 0 0 0 0 1 0 0 0 0 0 0 29
30 731 0 0 0 0 0 0 1 0 0 0 0 0 30
31 392 1 0 0 0 0 0 0 1 0 0 0 0 31
32 344 1 0 0 0 0 0 0 0 1 0 0 0 32
33 792 1 0 0 0 0 0 0 0 0 1 0 0 33
34 852 1 0 0 0 0 0 0 0 0 0 1 0 34
35 649 1 0 0 0 0 0 0 0 0 0 0 1 35
36 629 1 0 0 0 0 0 0 0 0 0 0 0 36
37 685 1 1 0 0 0 0 0 0 0 0 0 0 37
38 617 1 0 1 0 0 0 0 0 0 0 0 0 38
39 715 1 0 0 1 0 0 0 0 0 0 0 0 39
40 715 1 0 0 0 1 0 0 0 0 0 0 0 40
41 629 1 0 0 0 0 1 0 0 0 0 0 0 41
42 916 1 0 0 0 0 0 1 0 0 0 0 0 42
43 531 1 0 0 0 0 0 0 1 0 0 0 0 43
44 357 1 0 0 0 0 0 0 0 1 0 0 0 44
45 917 1 0 0 0 0 0 0 0 0 1 0 0 45
46 828 1 0 0 0 0 0 0 0 0 0 1 0 46
47 708 1 0 0 0 0 0 0 0 0 0 0 1 47
48 858 1 0 0 0 0 0 0 0 0 0 0 0 48
49 775 1 1 0 0 0 0 0 0 0 0 0 0 49
50 785 1 0 1 0 0 0 0 0 0 0 0 0 50
51 1006 1 0 0 1 0 0 0 0 0 0 0 0 51
52 789 1 0 0 0 1 0 0 0 0 0 0 0 52
53 734 1 0 0 0 0 1 0 0 0 0 0 0 53
54 906 1 0 0 0 0 0 1 0 0 0 0 0 54
55 532 1 0 0 0 0 0 0 1 0 0 0 0 55
56 387 1 0 0 0 0 0 0 0 1 0 0 0 56
57 991 1 0 0 0 0 0 0 0 0 1 0 0 57
58 841 1 0 0 0 0 0 0 0 0 0 1 0 58
59 892 1 0 0 0 0 0 0 0 0 0 0 1 59
60 782 1 0 0 0 0 0 0 0 0 0 0 0 60
61 813 1 1 0 0 0 0 0 0 0 0 0 0 61
62 793 1 0 1 0 0 0 0 0 0 0 0 0 62
63 978 1 0 0 1 0 0 0 0 0 0 0 0 63
64 775 1 0 0 0 1 0 0 0 0 0 0 0 64
65 797 1 0 0 0 0 1 0 0 0 0 0 0 65
66 946 1 0 0 0 0 0 1 0 0 0 0 0 66
67 594 1 0 0 0 0 0 0 1 0 0 0 0 67
68 438 1 0 0 0 0 0 0 0 1 0 0 0 68
69 1022 1 0 0 0 0 0 0 0 0 1 0 0 69
70 868 1 0 0 0 0 0 0 0 0 0 1 0 70
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
612.858 8.276 20.363 -12.964 100.042 -19.452
M5 M6 M7 M8 M9 M10
-8.945 128.561 -247.479 -355.139 146.867 67.040
M11 t
-15.373 2.827
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-116.434 -33.315 -2.989 38.068 140.640
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 612.8578 32.5134 18.849 < 2e-16 ***
X 8.2755 30.8354 0.268 0.789395
M1 20.3632 39.3053 0.518 0.606445
M2 -12.9639 39.2911 -0.330 0.742673
M3 100.0423 39.2913 2.546 0.013669 *
M4 -19.4515 39.3059 -0.495 0.622625
M5 -8.9453 39.3350 -0.227 0.820930
M6 128.5609 39.3783 3.265 0.001871 **
M7 -247.4788 39.2846 -6.300 4.93e-08 ***
M8 -355.1393 39.2725 -9.043 1.54e-12 ***
M9 146.8669 39.2748 3.739 0.000435 ***
M10 67.0398 39.2915 1.706 0.093508 .
M11 -15.3729 41.0100 -0.375 0.709183
t 2.8271 0.7527 3.756 0.000413 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 64.83 on 56 degrees of freedom
Multiple R-squared: 0.8757, Adjusted R-squared: 0.8469
F-statistic: 30.36 on 13 and 56 DF, p-value: < 2.2e-16
> 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.44780453 0.895609055 0.552195472
[2,] 0.58399008 0.832019844 0.416009922
[3,] 0.43527723 0.870554457 0.564722772
[4,] 0.34094508 0.681890170 0.659054915
[5,] 0.38746442 0.774928837 0.612535581
[6,] 0.33925889 0.678517784 0.660741108
[7,] 0.34262851 0.685257020 0.657371490
[8,] 0.24936861 0.498737215 0.750631393
[9,] 0.19405675 0.388113497 0.805943252
[10,] 0.14055618 0.281112366 0.859443817
[11,] 0.10518100 0.210361995 0.894819002
[12,] 0.10526538 0.210530764 0.894734618
[13,] 0.11276594 0.225531883 0.887234059
[14,] 0.07858944 0.157178873 0.921410563
[15,] 0.05297627 0.105952538 0.947023731
[16,] 0.03769507 0.075390148 0.962304926
[17,] 0.02955045 0.059100903 0.970449548
[18,] 0.12686113 0.253722250 0.873138875
[19,] 0.09930980 0.198619610 0.900690195
[20,] 0.13006350 0.260126992 0.869936504
[21,] 0.09341003 0.186820055 0.906589973
[22,] 0.10580038 0.211600752 0.894199624
[23,] 0.54359446 0.912811073 0.456405536
[24,] 0.54455642 0.910887153 0.455443577
[25,] 0.67048756 0.659024871 0.329512436
[26,] 0.77033667 0.459326659 0.229663329
[27,] 0.80612407 0.387751860 0.193875930
[28,] 0.73000839 0.539983215 0.269991607
[29,] 0.76976461 0.460470782 0.230235391
[30,] 0.70713666 0.585726671 0.292863336
[31,] 0.95650310 0.086993802 0.043496901
[32,] 0.99627571 0.007448589 0.003724294
[33,] 0.99054181 0.018916383 0.009458191
[34,] 0.98110547 0.037789069 0.018894534
[35,] 0.99365775 0.012684493 0.006342247
[36,] 0.99807179 0.003856425 0.001928212
[37,] 0.99305275 0.013894495 0.006947247
> postscript(file="/var/www/rcomp/tmp/1opas1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/2opas1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/3hgrv1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/4hgrv1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/5hgrv1292927279.ps",horizontal=F,onefile=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 = 70
Frequency = 1
1 2 3 4 5 6
58.9518561 32.4518561 40.6185228 30.2851895 102.9518561 95.6185228
7 8 9 10 11 12
32.8311098 86.6644432 38.8311098 -21.1688902 -27.5834107 29.2165893
13 14 15 16 17 18
70.0262181 51.5262181 -72.3071152 -44.6404486 77.0262181 -61.3071152
19 20 21 22 23 24
-33.0945282 16.7388051 -112.0945282 -27.0945282 -5.5090487 -27.7090487
25 26 27 28 29 30
-61.8994200 -30.3994200 -71.2327533 -18.5660866 -53.8994200 -95.2327533
31 32 33 34 35 36
-69.2956883 -12.4623550 -69.2956883 67.7043117 -55.7102088 -93.9102088
37 38 39 40 41 42
-61.1005800 -98.6005800 -116.4339134 0.2327533 -99.1005800 47.5660866
43 44 45 46 47 48
35.7786736 -33.3879930 21.7786736 9.7786736 -30.6358469 101.1641531
49 50 51 52 53 54
-5.0262181 35.4737819 140.6404486 40.3071152 -28.0262181 3.6404486
55 56 57 58 59 60
2.8530356 -37.3136311 61.8530356 -11.1469644 119.4385151 -8.7614849
61 62 63 64 65 66
-0.9518561 9.5481439 78.7148105 -7.6185228 1.0481439 9.7148105
67 68 69 70
30.9273975 -20.2392691 58.9273975 -18.0726025
> postscript(file="/var/www/rcomp/tmp/6988g1292927279.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 70
Frequency = 1
lag(myerror, k = 1) myerror
0 58.9518561 NA
1 32.4518561 58.9518561
2 40.6185228 32.4518561
3 30.2851895 40.6185228
4 102.9518561 30.2851895
5 95.6185228 102.9518561
6 32.8311098 95.6185228
7 86.6644432 32.8311098
8 38.8311098 86.6644432
9 -21.1688902 38.8311098
10 -27.5834107 -21.1688902
11 29.2165893 -27.5834107
12 70.0262181 29.2165893
13 51.5262181 70.0262181
14 -72.3071152 51.5262181
15 -44.6404486 -72.3071152
16 77.0262181 -44.6404486
17 -61.3071152 77.0262181
18 -33.0945282 -61.3071152
19 16.7388051 -33.0945282
20 -112.0945282 16.7388051
21 -27.0945282 -112.0945282
22 -5.5090487 -27.0945282
23 -27.7090487 -5.5090487
24 -61.8994200 -27.7090487
25 -30.3994200 -61.8994200
26 -71.2327533 -30.3994200
27 -18.5660866 -71.2327533
28 -53.8994200 -18.5660866
29 -95.2327533 -53.8994200
30 -69.2956883 -95.2327533
31 -12.4623550 -69.2956883
32 -69.2956883 -12.4623550
33 67.7043117 -69.2956883
34 -55.7102088 67.7043117
35 -93.9102088 -55.7102088
36 -61.1005800 -93.9102088
37 -98.6005800 -61.1005800
38 -116.4339134 -98.6005800
39 0.2327533 -116.4339134
40 -99.1005800 0.2327533
41 47.5660866 -99.1005800
42 35.7786736 47.5660866
43 -33.3879930 35.7786736
44 21.7786736 -33.3879930
45 9.7786736 21.7786736
46 -30.6358469 9.7786736
47 101.1641531 -30.6358469
48 -5.0262181 101.1641531
49 35.4737819 -5.0262181
50 140.6404486 35.4737819
51 40.3071152 140.6404486
52 -28.0262181 40.3071152
53 3.6404486 -28.0262181
54 2.8530356 3.6404486
55 -37.3136311 2.8530356
56 61.8530356 -37.3136311
57 -11.1469644 61.8530356
58 119.4385151 -11.1469644
59 -8.7614849 119.4385151
60 -0.9518561 -8.7614849
61 9.5481439 -0.9518561
62 78.7148105 9.5481439
63 -7.6185228 78.7148105
64 1.0481439 -7.6185228
65 9.7148105 1.0481439
66 30.9273975 9.7148105
67 -20.2392691 30.9273975
68 58.9273975 -20.2392691
69 -18.0726025 58.9273975
70 NA -18.0726025
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 32.4518561 58.9518561
[2,] 40.6185228 32.4518561
[3,] 30.2851895 40.6185228
[4,] 102.9518561 30.2851895
[5,] 95.6185228 102.9518561
[6,] 32.8311098 95.6185228
[7,] 86.6644432 32.8311098
[8,] 38.8311098 86.6644432
[9,] -21.1688902 38.8311098
[10,] -27.5834107 -21.1688902
[11,] 29.2165893 -27.5834107
[12,] 70.0262181 29.2165893
[13,] 51.5262181 70.0262181
[14,] -72.3071152 51.5262181
[15,] -44.6404486 -72.3071152
[16,] 77.0262181 -44.6404486
[17,] -61.3071152 77.0262181
[18,] -33.0945282 -61.3071152
[19,] 16.7388051 -33.0945282
[20,] -112.0945282 16.7388051
[21,] -27.0945282 -112.0945282
[22,] -5.5090487 -27.0945282
[23,] -27.7090487 -5.5090487
[24,] -61.8994200 -27.7090487
[25,] -30.3994200 -61.8994200
[26,] -71.2327533 -30.3994200
[27,] -18.5660866 -71.2327533
[28,] -53.8994200 -18.5660866
[29,] -95.2327533 -53.8994200
[30,] -69.2956883 -95.2327533
[31,] -12.4623550 -69.2956883
[32,] -69.2956883 -12.4623550
[33,] 67.7043117 -69.2956883
[34,] -55.7102088 67.7043117
[35,] -93.9102088 -55.7102088
[36,] -61.1005800 -93.9102088
[37,] -98.6005800 -61.1005800
[38,] -116.4339134 -98.6005800
[39,] 0.2327533 -116.4339134
[40,] -99.1005800 0.2327533
[41,] 47.5660866 -99.1005800
[42,] 35.7786736 47.5660866
[43,] -33.3879930 35.7786736
[44,] 21.7786736 -33.3879930
[45,] 9.7786736 21.7786736
[46,] -30.6358469 9.7786736
[47,] 101.1641531 -30.6358469
[48,] -5.0262181 101.1641531
[49,] 35.4737819 -5.0262181
[50,] 140.6404486 35.4737819
[51,] 40.3071152 140.6404486
[52,] -28.0262181 40.3071152
[53,] 3.6404486 -28.0262181
[54,] 2.8530356 3.6404486
[55,] -37.3136311 2.8530356
[56,] 61.8530356 -37.3136311
[57,] -11.1469644 61.8530356
[58,] 119.4385151 -11.1469644
[59,] -8.7614849 119.4385151
[60,] -0.9518561 -8.7614849
[61,] 9.5481439 -0.9518561
[62,] 78.7148105 9.5481439
[63,] -7.6185228 78.7148105
[64,] 1.0481439 -7.6185228
[65,] 9.7148105 1.0481439
[66,] 30.9273975 9.7148105
[67,] -20.2392691 30.9273975
[68,] 58.9273975 -20.2392691
[69,] -18.0726025 58.9273975
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 32.4518561 58.9518561
2 40.6185228 32.4518561
3 30.2851895 40.6185228
4 102.9518561 30.2851895
5 95.6185228 102.9518561
6 32.8311098 95.6185228
7 86.6644432 32.8311098
8 38.8311098 86.6644432
9 -21.1688902 38.8311098
10 -27.5834107 -21.1688902
11 29.2165893 -27.5834107
12 70.0262181 29.2165893
13 51.5262181 70.0262181
14 -72.3071152 51.5262181
15 -44.6404486 -72.3071152
16 77.0262181 -44.6404486
17 -61.3071152 77.0262181
18 -33.0945282 -61.3071152
19 16.7388051 -33.0945282
20 -112.0945282 16.7388051
21 -27.0945282 -112.0945282
22 -5.5090487 -27.0945282
23 -27.7090487 -5.5090487
24 -61.8994200 -27.7090487
25 -30.3994200 -61.8994200
26 -71.2327533 -30.3994200
27 -18.5660866 -71.2327533
28 -53.8994200 -18.5660866
29 -95.2327533 -53.8994200
30 -69.2956883 -95.2327533
31 -12.4623550 -69.2956883
32 -69.2956883 -12.4623550
33 67.7043117 -69.2956883
34 -55.7102088 67.7043117
35 -93.9102088 -55.7102088
36 -61.1005800 -93.9102088
37 -98.6005800 -61.1005800
38 -116.4339134 -98.6005800
39 0.2327533 -116.4339134
40 -99.1005800 0.2327533
41 47.5660866 -99.1005800
42 35.7786736 47.5660866
43 -33.3879930 35.7786736
44 21.7786736 -33.3879930
45 9.7786736 21.7786736
46 -30.6358469 9.7786736
47 101.1641531 -30.6358469
48 -5.0262181 101.1641531
49 35.4737819 -5.0262181
50 140.6404486 35.4737819
51 40.3071152 140.6404486
52 -28.0262181 40.3071152
53 3.6404486 -28.0262181
54 2.8530356 3.6404486
55 -37.3136311 2.8530356
56 61.8530356 -37.3136311
57 -11.1469644 61.8530356
58 119.4385151 -11.1469644
59 -8.7614849 119.4385151
60 -0.9518561 -8.7614849
61 9.5481439 -0.9518561
62 78.7148105 9.5481439
63 -7.6185228 78.7148105
64 1.0481439 -7.6185228
65 9.7148105 1.0481439
66 30.9273975 9.7148105
67 -20.2392691 30.9273975
68 58.9273975 -20.2392691
69 -18.0726025 58.9273975
> 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/rcomp/tmp/72h8j1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/82h8j1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/92h8j1292927279.ps",horizontal=F,onefile=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/rcomp/tmp/10vq741292927279.ps",horizontal=F,onefile=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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11gr6s1292927279.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/rcomp/tmp/129ind1292927279.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/rcomp/tmp/13gj271292927279.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/rcomp/tmp/14jkiv1292927279.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/rcomp/tmp/15cbix1292927279.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/rcomp/tmp/16qlx61292927279.tab")
+ }
>
> try(system("convert tmp/1opas1292927279.ps tmp/1opas1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/2opas1292927279.ps tmp/2opas1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/3hgrv1292927279.ps tmp/3hgrv1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/4hgrv1292927279.ps tmp/4hgrv1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/5hgrv1292927279.ps tmp/5hgrv1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/6988g1292927279.ps tmp/6988g1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/72h8j1292927279.ps tmp/72h8j1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/82h8j1292927279.ps tmp/82h8j1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/92h8j1292927279.ps tmp/92h8j1292927279.png",intern=TRUE))
character(0)
> try(system("convert tmp/10vq741292927279.ps tmp/10vq741292927279.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.170 1.170 4.315