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(9627
+ ,2249
+ ,8700
+ ,9487
+ ,8947
+ ,2687
+ ,9627
+ ,8700
+ ,9283
+ ,4359
+ ,8947
+ ,9627
+ ,8829
+ ,5382
+ ,9283
+ ,8947
+ ,9947
+ ,4459
+ ,8829
+ ,9283
+ ,9628
+ ,6398
+ ,9947
+ ,8829
+ ,9318
+ ,4596
+ ,9628
+ ,9947
+ ,9605
+ ,3024
+ ,9318
+ ,9628
+ ,8640
+ ,1887
+ ,9605
+ ,9318
+ ,9214
+ ,2070
+ ,8640
+ ,9605
+ ,9567
+ ,1351
+ ,9214
+ ,8640
+ ,8547
+ ,2218
+ ,9567
+ ,9214
+ ,9185
+ ,2461
+ ,8547
+ ,9567
+ ,9470
+ ,3028
+ ,9185
+ ,8547
+ ,9123
+ ,4784
+ ,9470
+ ,9185
+ ,9278
+ ,4975
+ ,9123
+ ,9470
+ ,10170
+ ,4607
+ ,9278
+ ,9123
+ ,9434
+ ,6249
+ ,10170
+ ,9278
+ ,9655
+ ,4809
+ ,9434
+ ,10170
+ ,9429
+ ,3157
+ ,9655
+ ,9434
+ ,8739
+ ,1910
+ ,9429
+ ,9655
+ ,9552
+ ,2228
+ ,8739
+ ,9429
+ ,9687
+ ,1594
+ ,9552
+ ,8739
+ ,9019
+ ,2467
+ ,9687
+ ,9552
+ ,9672
+ ,2222
+ ,9019
+ ,9687
+ ,9206
+ ,3607
+ ,9672
+ ,9019
+ ,9069
+ ,4685
+ ,9206
+ ,9672
+ ,9788
+ ,4962
+ ,9069
+ ,9206
+ ,10312
+ ,5770
+ ,9788
+ ,9069
+ ,10105
+ ,5480
+ ,10312
+ ,9788
+ ,9863
+ ,5000
+ ,10105
+ ,10312
+ ,9656
+ ,3228
+ ,9863
+ ,10105
+ ,9295
+ ,1993
+ ,9656
+ ,9863
+ ,9946
+ ,2288
+ ,9295
+ ,9656
+ ,9701
+ ,1580
+ ,9946
+ ,9295
+ ,9049
+ ,2111
+ ,9701
+ ,9946
+ ,10190
+ ,2192
+ ,9049
+ ,9701
+ ,9706
+ ,3601
+ ,10190
+ ,9049
+ ,9765
+ ,4665
+ ,9706
+ ,10190
+ ,9893
+ ,4876
+ ,9765
+ ,9706
+ ,9994
+ ,5813
+ ,9893
+ ,9765
+ ,10433
+ ,5589
+ ,9994
+ ,9893
+ ,10073
+ ,5331
+ ,10433
+ ,9994
+ ,10112
+ ,3075
+ ,10073
+ ,10433
+ ,9266
+ ,2002
+ ,10112
+ ,10073
+ ,9820
+ ,2306
+ ,9266
+ ,10112
+ ,10097
+ ,1507
+ ,9820
+ ,9266
+ ,9115
+ ,1992
+ ,10097
+ ,9820
+ ,10411
+ ,2487
+ ,9115
+ ,10097
+ ,9678
+ ,3490
+ ,10411
+ ,9115
+ ,10408
+ ,4647
+ ,9678
+ ,10411
+ ,10153
+ ,5594
+ ,10408
+ ,9678
+ ,10368
+ ,5611
+ ,10153
+ ,10408
+ ,10581
+ ,5788
+ ,10368
+ ,10153
+ ,10597
+ ,6204
+ ,10581
+ ,10368
+ ,10680
+ ,3013
+ ,10597
+ ,10581
+ ,9738
+ ,1931
+ ,10680
+ ,10597
+ ,9556
+ ,2549
+ ,9738
+ ,10680)
+ ,dim=c(4
+ ,58)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2')
+ ,1:58))
> y <- array(NA,dim=c(4,58),dimnames=list(c('Y','X','Y1','Y2'),1:58))
> 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 Y1 Y2 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 9627 2249 8700 9487 1 0 0 0 0 0 0 0 0 0 0 1
2 8947 2687 9627 8700 0 1 0 0 0 0 0 0 0 0 0 2
3 9283 4359 8947 9627 0 0 1 0 0 0 0 0 0 0 0 3
4 8829 5382 9283 8947 0 0 0 1 0 0 0 0 0 0 0 4
5 9947 4459 8829 9283 0 0 0 0 1 0 0 0 0 0 0 5
6 9628 6398 9947 8829 0 0 0 0 0 1 0 0 0 0 0 6
7 9318 4596 9628 9947 0 0 0 0 0 0 1 0 0 0 0 7
8 9605 3024 9318 9628 0 0 0 0 0 0 0 1 0 0 0 8
9 8640 1887 9605 9318 0 0 0 0 0 0 0 0 1 0 0 9
10 9214 2070 8640 9605 0 0 0 0 0 0 0 0 0 1 0 10
11 9567 1351 9214 8640 0 0 0 0 0 0 0 0 0 0 1 11
12 8547 2218 9567 9214 0 0 0 0 0 0 0 0 0 0 0 12
13 9185 2461 8547 9567 1 0 0 0 0 0 0 0 0 0 0 13
14 9470 3028 9185 8547 0 1 0 0 0 0 0 0 0 0 0 14
15 9123 4784 9470 9185 0 0 1 0 0 0 0 0 0 0 0 15
16 9278 4975 9123 9470 0 0 0 1 0 0 0 0 0 0 0 16
17 10170 4607 9278 9123 0 0 0 0 1 0 0 0 0 0 0 17
18 9434 6249 10170 9278 0 0 0 0 0 1 0 0 0 0 0 18
19 9655 4809 9434 10170 0 0 0 0 0 0 1 0 0 0 0 19
20 9429 3157 9655 9434 0 0 0 0 0 0 0 1 0 0 0 20
21 8739 1910 9429 9655 0 0 0 0 0 0 0 0 1 0 0 21
22 9552 2228 8739 9429 0 0 0 0 0 0 0 0 0 1 0 22
23 9687 1594 9552 8739 0 0 0 0 0 0 0 0 0 0 1 23
24 9019 2467 9687 9552 0 0 0 0 0 0 0 0 0 0 0 24
25 9672 2222 9019 9687 1 0 0 0 0 0 0 0 0 0 0 25
26 9206 3607 9672 9019 0 1 0 0 0 0 0 0 0 0 0 26
27 9069 4685 9206 9672 0 0 1 0 0 0 0 0 0 0 0 27
28 9788 4962 9069 9206 0 0 0 1 0 0 0 0 0 0 0 28
29 10312 5770 9788 9069 0 0 0 0 1 0 0 0 0 0 0 29
30 10105 5480 10312 9788 0 0 0 0 0 1 0 0 0 0 0 30
31 9863 5000 10105 10312 0 0 0 0 0 0 1 0 0 0 0 31
32 9656 3228 9863 10105 0 0 0 0 0 0 0 1 0 0 0 32
33 9295 1993 9656 9863 0 0 0 0 0 0 0 0 1 0 0 33
34 9946 2288 9295 9656 0 0 0 0 0 0 0 0 0 1 0 34
35 9701 1580 9946 9295 0 0 0 0 0 0 0 0 0 0 1 35
36 9049 2111 9701 9946 0 0 0 0 0 0 0 0 0 0 0 36
37 10190 2192 9049 9701 1 0 0 0 0 0 0 0 0 0 0 37
38 9706 3601 10190 9049 0 1 0 0 0 0 0 0 0 0 0 38
39 9765 4665 9706 10190 0 0 1 0 0 0 0 0 0 0 0 39
40 9893 4876 9765 9706 0 0 0 1 0 0 0 0 0 0 0 40
41 9994 5813 9893 9765 0 0 0 0 1 0 0 0 0 0 0 41
42 10433 5589 9994 9893 0 0 0 0 0 1 0 0 0 0 0 42
43 10073 5331 10433 9994 0 0 0 0 0 0 1 0 0 0 0 43
44 10112 3075 10073 10433 0 0 0 0 0 0 0 1 0 0 0 44
45 9266 2002 10112 10073 0 0 0 0 0 0 0 0 1 0 0 45
46 9820 2306 9266 10112 0 0 0 0 0 0 0 0 0 1 0 46
47 10097 1507 9820 9266 0 0 0 0 0 0 0 0 0 0 1 47
48 9115 1992 10097 9820 0 0 0 0 0 0 0 0 0 0 0 48
49 10411 2487 9115 10097 1 0 0 0 0 0 0 0 0 0 0 49
50 9678 3490 10411 9115 0 1 0 0 0 0 0 0 0 0 0 50
51 10408 4647 9678 10411 0 0 1 0 0 0 0 0 0 0 0 51
52 10153 5594 10408 9678 0 0 0 1 0 0 0 0 0 0 0 52
53 10368 5611 10153 10408 0 0 0 0 1 0 0 0 0 0 0 53
54 10581 5788 10368 10153 0 0 0 0 0 1 0 0 0 0 0 54
55 10597 6204 10581 10368 0 0 0 0 0 0 1 0 0 0 0 55
56 10680 3013 10597 10581 0 0 0 0 0 0 0 1 0 0 0 56
57 9738 1931 10680 10597 0 0 0 0 0 0 0 0 1 0 0 57
58 9556 2549 9738 10680 0 0 0 0 0 0 0 0 0 1 0 58
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 M1 M2
1.153e+04 -2.595e-01 -6.226e-02 -2.297e-01 1.012e+03 6.882e+02
M3 M4 M5 M6 M7 M8
1.327e+03 1.409e+03 2.010e+03 2.079e+03 1.856e+03 1.246e+03
M9 M10 M11 t
1.282e+02 6.245e+02 5.212e+02 2.643e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-491.274 -120.639 1.404 132.895 407.378
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.153e+04 2.074e+03 5.560 1.70e-06 ***
X -2.596e-01 1.240e-01 -2.094 0.04237 *
Y1 -6.226e-02 1.646e-01 -0.378 0.70710
Y2 -2.297e-01 1.632e-01 -1.407 0.16674
M1 1.012e+03 2.105e+02 4.805 2.00e-05 ***
M2 6.882e+02 2.047e+02 3.361 0.00166 **
M3 1.327e+03 3.758e+02 3.532 0.00102 **
M4 1.409e+03 4.023e+02 3.503 0.00111 **
M5 2.010e+03 4.149e+02 4.846 1.75e-05 ***
M6 2.079e+03 4.624e+02 4.496 5.36e-05 ***
M7 1.856e+03 4.250e+02 4.368 8.05e-05 ***
M8 1.246e+03 2.084e+02 5.982 4.21e-07 ***
M9 1.282e+02 1.606e+02 0.798 0.42916
M10 6.245e+02 1.992e+02 3.135 0.00314 **
M11 5.212e+02 2.233e+02 2.334 0.02443 *
t 2.643e+01 4.764e+00 5.547 1.78e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 230.4 on 42 degrees of freedom
Multiple R-squared: 0.8508, Adjusted R-squared: 0.7975
F-statistic: 15.96 on 15 and 42 DF, p-value: 9.897e-13
> 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.7226057 0.5547885 0.2773943
[2,] 0.6658380 0.6683241 0.3341620
[3,] 0.5301355 0.9397290 0.4698645
[4,] 0.4132348 0.8264696 0.5867652
[5,] 0.3863760 0.7727519 0.6136240
[6,] 0.4652589 0.9305179 0.5347411
[7,] 0.3709137 0.7418275 0.6290863
[8,] 0.2669831 0.5339663 0.7330169
[9,] 0.5176962 0.9646076 0.4823038
[10,] 0.4885150 0.9770300 0.5114850
[11,] 0.5102088 0.9795825 0.4897912
[12,] 0.4426850 0.8853700 0.5573150
[13,] 0.3576850 0.7153700 0.6423150
[14,] 0.3671820 0.7343639 0.6328180
[15,] 0.3115070 0.6230141 0.6884930
[16,] 0.5523050 0.8953900 0.4476950
[17,] 0.4358954 0.8717908 0.5641046
[18,] 0.3496766 0.6993531 0.6503234
[19,] 0.2571313 0.5142626 0.7428687
[20,] 0.4117793 0.8235586 0.5882207
[21,] 0.2882919 0.5765837 0.7117081
> postscript(file="/var/www/html/rcomp/tmp/1uvst1258996165.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/28xht1258996165.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/3o3001258996165.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/41i611258996165.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/53uok1258996165.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 = 58
Frequency = 1
1 2 3 4 5 6
362.9378623 -29.3071213 245.8812560 -186.4969316 113.3007794 167.5595387
7 8 9 10 11 12
-176.5458207 193.1960286 -28.4091923 76.2123091 133.5980645 -12.8138494
13 14 15 16 17 18
-332.3043412 202.4252133 -189.8783097 -50.0905756 48.8067203 -265.2203470
19 20 21 22 23 24
-62.2378312 -288.9733822 -174.1120881 103.8476945 43.3357301 291.8002718
25 26 27 28 29 30
-167.5033753 -89.6834019 -491.2741241 75.4246883 194.8985756 15.0461371
31 32 33 34 35 36
-47.3879271 -193.5987654 148.2211649 283.0589062 -111.1833173 3.6491156
37 38 39 40 41 42
30.6787356 130.7859292 32.5215746 -0.8408853 -262.6652074 58.5391641
43 44 45 46 47 48
-121.2064476 -6.0167531 -118.9351703 -52.4582358 -65.7504773 -282.6355379
49 50 51 52 53 54
106.1911186 -214.2206193 402.7496033 162.0037041 -94.3408679 24.0755071
55 56 57 58
407.3780266 295.3928721 173.2352857 -410.6606740
> postscript(file="/var/www/html/rcomp/tmp/6milk1258996165.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 362.9378623 NA
1 -29.3071213 362.9378623
2 245.8812560 -29.3071213
3 -186.4969316 245.8812560
4 113.3007794 -186.4969316
5 167.5595387 113.3007794
6 -176.5458207 167.5595387
7 193.1960286 -176.5458207
8 -28.4091923 193.1960286
9 76.2123091 -28.4091923
10 133.5980645 76.2123091
11 -12.8138494 133.5980645
12 -332.3043412 -12.8138494
13 202.4252133 -332.3043412
14 -189.8783097 202.4252133
15 -50.0905756 -189.8783097
16 48.8067203 -50.0905756
17 -265.2203470 48.8067203
18 -62.2378312 -265.2203470
19 -288.9733822 -62.2378312
20 -174.1120881 -288.9733822
21 103.8476945 -174.1120881
22 43.3357301 103.8476945
23 291.8002718 43.3357301
24 -167.5033753 291.8002718
25 -89.6834019 -167.5033753
26 -491.2741241 -89.6834019
27 75.4246883 -491.2741241
28 194.8985756 75.4246883
29 15.0461371 194.8985756
30 -47.3879271 15.0461371
31 -193.5987654 -47.3879271
32 148.2211649 -193.5987654
33 283.0589062 148.2211649
34 -111.1833173 283.0589062
35 3.6491156 -111.1833173
36 30.6787356 3.6491156
37 130.7859292 30.6787356
38 32.5215746 130.7859292
39 -0.8408853 32.5215746
40 -262.6652074 -0.8408853
41 58.5391641 -262.6652074
42 -121.2064476 58.5391641
43 -6.0167531 -121.2064476
44 -118.9351703 -6.0167531
45 -52.4582358 -118.9351703
46 -65.7504773 -52.4582358
47 -282.6355379 -65.7504773
48 106.1911186 -282.6355379
49 -214.2206193 106.1911186
50 402.7496033 -214.2206193
51 162.0037041 402.7496033
52 -94.3408679 162.0037041
53 24.0755071 -94.3408679
54 407.3780266 24.0755071
55 295.3928721 407.3780266
56 173.2352857 295.3928721
57 -410.6606740 173.2352857
58 NA -410.6606740
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -29.3071213 362.9378623
[2,] 245.8812560 -29.3071213
[3,] -186.4969316 245.8812560
[4,] 113.3007794 -186.4969316
[5,] 167.5595387 113.3007794
[6,] -176.5458207 167.5595387
[7,] 193.1960286 -176.5458207
[8,] -28.4091923 193.1960286
[9,] 76.2123091 -28.4091923
[10,] 133.5980645 76.2123091
[11,] -12.8138494 133.5980645
[12,] -332.3043412 -12.8138494
[13,] 202.4252133 -332.3043412
[14,] -189.8783097 202.4252133
[15,] -50.0905756 -189.8783097
[16,] 48.8067203 -50.0905756
[17,] -265.2203470 48.8067203
[18,] -62.2378312 -265.2203470
[19,] -288.9733822 -62.2378312
[20,] -174.1120881 -288.9733822
[21,] 103.8476945 -174.1120881
[22,] 43.3357301 103.8476945
[23,] 291.8002718 43.3357301
[24,] -167.5033753 291.8002718
[25,] -89.6834019 -167.5033753
[26,] -491.2741241 -89.6834019
[27,] 75.4246883 -491.2741241
[28,] 194.8985756 75.4246883
[29,] 15.0461371 194.8985756
[30,] -47.3879271 15.0461371
[31,] -193.5987654 -47.3879271
[32,] 148.2211649 -193.5987654
[33,] 283.0589062 148.2211649
[34,] -111.1833173 283.0589062
[35,] 3.6491156 -111.1833173
[36,] 30.6787356 3.6491156
[37,] 130.7859292 30.6787356
[38,] 32.5215746 130.7859292
[39,] -0.8408853 32.5215746
[40,] -262.6652074 -0.8408853
[41,] 58.5391641 -262.6652074
[42,] -121.2064476 58.5391641
[43,] -6.0167531 -121.2064476
[44,] -118.9351703 -6.0167531
[45,] -52.4582358 -118.9351703
[46,] -65.7504773 -52.4582358
[47,] -282.6355379 -65.7504773
[48,] 106.1911186 -282.6355379
[49,] -214.2206193 106.1911186
[50,] 402.7496033 -214.2206193
[51,] 162.0037041 402.7496033
[52,] -94.3408679 162.0037041
[53,] 24.0755071 -94.3408679
[54,] 407.3780266 24.0755071
[55,] 295.3928721 407.3780266
[56,] 173.2352857 295.3928721
[57,] -410.6606740 173.2352857
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -29.3071213 362.9378623
2 245.8812560 -29.3071213
3 -186.4969316 245.8812560
4 113.3007794 -186.4969316
5 167.5595387 113.3007794
6 -176.5458207 167.5595387
7 193.1960286 -176.5458207
8 -28.4091923 193.1960286
9 76.2123091 -28.4091923
10 133.5980645 76.2123091
11 -12.8138494 133.5980645
12 -332.3043412 -12.8138494
13 202.4252133 -332.3043412
14 -189.8783097 202.4252133
15 -50.0905756 -189.8783097
16 48.8067203 -50.0905756
17 -265.2203470 48.8067203
18 -62.2378312 -265.2203470
19 -288.9733822 -62.2378312
20 -174.1120881 -288.9733822
21 103.8476945 -174.1120881
22 43.3357301 103.8476945
23 291.8002718 43.3357301
24 -167.5033753 291.8002718
25 -89.6834019 -167.5033753
26 -491.2741241 -89.6834019
27 75.4246883 -491.2741241
28 194.8985756 75.4246883
29 15.0461371 194.8985756
30 -47.3879271 15.0461371
31 -193.5987654 -47.3879271
32 148.2211649 -193.5987654
33 283.0589062 148.2211649
34 -111.1833173 283.0589062
35 3.6491156 -111.1833173
36 30.6787356 3.6491156
37 130.7859292 30.6787356
38 32.5215746 130.7859292
39 -0.8408853 32.5215746
40 -262.6652074 -0.8408853
41 58.5391641 -262.6652074
42 -121.2064476 58.5391641
43 -6.0167531 -121.2064476
44 -118.9351703 -6.0167531
45 -52.4582358 -118.9351703
46 -65.7504773 -52.4582358
47 -282.6355379 -65.7504773
48 106.1911186 -282.6355379
49 -214.2206193 106.1911186
50 402.7496033 -214.2206193
51 162.0037041 402.7496033
52 -94.3408679 162.0037041
53 24.0755071 -94.3408679
54 407.3780266 24.0755071
55 295.3928721 407.3780266
56 173.2352857 295.3928721
57 -410.6606740 173.2352857
> 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/710nb1258996165.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/839aw1258996165.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/984ih1258996165.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/1057wu1258996165.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/115hln1258996165.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/12s8hg1258996165.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/13cv9t1258996166.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/14upcm1258996166.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/15zpet1258996166.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/16ayr01258996166.tab")
+ }
>
> system("convert tmp/1uvst1258996165.ps tmp/1uvst1258996165.png")
> system("convert tmp/28xht1258996165.ps tmp/28xht1258996165.png")
> system("convert tmp/3o3001258996165.ps tmp/3o3001258996165.png")
> system("convert tmp/41i611258996165.ps tmp/41i611258996165.png")
> system("convert tmp/53uok1258996165.ps tmp/53uok1258996165.png")
> system("convert tmp/6milk1258996165.ps tmp/6milk1258996165.png")
> system("convert tmp/710nb1258996165.ps tmp/710nb1258996165.png")
> system("convert tmp/839aw1258996165.ps tmp/839aw1258996165.png")
> system("convert tmp/984ih1258996165.ps tmp/984ih1258996165.png")
> system("convert tmp/1057wu1258996165.ps tmp/1057wu1258996165.png")
>
>
> proc.time()
user system elapsed
2.346 1.605 3.309