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(7.0,519,6.9,517,6.7,510,6.7,509,6.5,501,6.4,507,6.5,569,6.5,580,6.5,578,6.7,565,6.8,547,7.2,555,7.6,562,7.6,561,7.2,555,6.4,544,6.1,537,6.3,543,7.1,594,7.5,611,7.4,613,7.1,611,6.8,594,6.9,595,7.2,591,7.4,589,7.3,584,6.9,573,6.9,567,6.8,569,7.1,621,7.2,629,7.1,628,7.0,612,6.9,595,7.1,597,7.3,593,7.5,590,7.5,580,7.5,574,7.3,573,7.0,573,6.7,620,6.5,626,6.5,620,6.5,588,6.6,566,6.8,557,6.9,561,6.9,549,6.8,532,6.8,526,6.5,511,6.1,499,6.1,555,5.9,565,5.7,542,5.9,527,5.9,510,6.1,514,6.3,517,6.2,508,5.9,493,5.7,490,5.4,469,5.6,478,6.2,528,6.3,534,6.0,518,5.6,506,5.5,502,5.9,516),dim=c(2,72),dimnames=list(c('wkgo','werkl'),1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('wkgo','werkl'),1:72))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No 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
wkgo werkl M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 7.0 519 1 0 0 0 0 0 0 0 0 0 0
2 6.9 517 0 1 0 0 0 0 0 0 0 0 0
3 6.7 510 0 0 1 0 0 0 0 0 0 0 0
4 6.7 509 0 0 0 1 0 0 0 0 0 0 0
5 6.5 501 0 0 0 0 1 0 0 0 0 0 0
6 6.4 507 0 0 0 0 0 1 0 0 0 0 0
7 6.5 569 0 0 0 0 0 0 1 0 0 0 0
8 6.5 580 0 0 0 0 0 0 0 1 0 0 0
9 6.5 578 0 0 0 0 0 0 0 0 1 0 0
10 6.7 565 0 0 0 0 0 0 0 0 0 1 0
11 6.8 547 0 0 0 0 0 0 0 0 0 0 1
12 7.2 555 0 0 0 0 0 0 0 0 0 0 0
13 7.6 562 1 0 0 0 0 0 0 0 0 0 0
14 7.6 561 0 1 0 0 0 0 0 0 0 0 0
15 7.2 555 0 0 1 0 0 0 0 0 0 0 0
16 6.4 544 0 0 0 1 0 0 0 0 0 0 0
17 6.1 537 0 0 0 0 1 0 0 0 0 0 0
18 6.3 543 0 0 0 0 0 1 0 0 0 0 0
19 7.1 594 0 0 0 0 0 0 1 0 0 0 0
20 7.5 611 0 0 0 0 0 0 0 1 0 0 0
21 7.4 613 0 0 0 0 0 0 0 0 1 0 0
22 7.1 611 0 0 0 0 0 0 0 0 0 1 0
23 6.8 594 0 0 0 0 0 0 0 0 0 0 1
24 6.9 595 0 0 0 0 0 0 0 0 0 0 0
25 7.2 591 1 0 0 0 0 0 0 0 0 0 0
26 7.4 589 0 1 0 0 0 0 0 0 0 0 0
27 7.3 584 0 0 1 0 0 0 0 0 0 0 0
28 6.9 573 0 0 0 1 0 0 0 0 0 0 0
29 6.9 567 0 0 0 0 1 0 0 0 0 0 0
30 6.8 569 0 0 0 0 0 1 0 0 0 0 0
31 7.1 621 0 0 0 0 0 0 1 0 0 0 0
32 7.2 629 0 0 0 0 0 0 0 1 0 0 0
33 7.1 628 0 0 0 0 0 0 0 0 1 0 0
34 7.0 612 0 0 0 0 0 0 0 0 0 1 0
35 6.9 595 0 0 0 0 0 0 0 0 0 0 1
36 7.1 597 0 0 0 0 0 0 0 0 0 0 0
37 7.3 593 1 0 0 0 0 0 0 0 0 0 0
38 7.5 590 0 1 0 0 0 0 0 0 0 0 0
39 7.5 580 0 0 1 0 0 0 0 0 0 0 0
40 7.5 574 0 0 0 1 0 0 0 0 0 0 0
41 7.3 573 0 0 0 0 1 0 0 0 0 0 0
42 7.0 573 0 0 0 0 0 1 0 0 0 0 0
43 6.7 620 0 0 0 0 0 0 1 0 0 0 0
44 6.5 626 0 0 0 0 0 0 0 1 0 0 0
45 6.5 620 0 0 0 0 0 0 0 0 1 0 0
46 6.5 588 0 0 0 0 0 0 0 0 0 1 0
47 6.6 566 0 0 0 0 0 0 0 0 0 0 1
48 6.8 557 0 0 0 0 0 0 0 0 0 0 0
49 6.9 561 1 0 0 0 0 0 0 0 0 0 0
50 6.9 549 0 1 0 0 0 0 0 0 0 0 0
51 6.8 532 0 0 1 0 0 0 0 0 0 0 0
52 6.8 526 0 0 0 1 0 0 0 0 0 0 0
53 6.5 511 0 0 0 0 1 0 0 0 0 0 0
54 6.1 499 0 0 0 0 0 1 0 0 0 0 0
55 6.1 555 0 0 0 0 0 0 1 0 0 0 0
56 5.9 565 0 0 0 0 0 0 0 1 0 0 0
57 5.7 542 0 0 0 0 0 0 0 0 1 0 0
58 5.9 527 0 0 0 0 0 0 0 0 0 1 0
59 5.9 510 0 0 0 0 0 0 0 0 0 0 1
60 6.1 514 0 0 0 0 0 0 0 0 0 0 0
61 6.3 517 1 0 0 0 0 0 0 0 0 0 0
62 6.2 508 0 1 0 0 0 0 0 0 0 0 0
63 5.9 493 0 0 1 0 0 0 0 0 0 0 0
64 5.7 490 0 0 0 1 0 0 0 0 0 0 0
65 5.4 469 0 0 0 0 1 0 0 0 0 0 0
66 5.6 478 0 0 0 0 0 1 0 0 0 0 0
67 6.2 528 0 0 0 0 0 0 1 0 0 0 0
68 6.3 534 0 0 0 0 0 0 0 1 0 0 0
69 6.0 518 0 0 0 0 0 0 0 0 1 0 0
70 5.6 506 0 0 0 0 0 0 0 0 0 1 0
71 5.5 502 0 0 0 0 0 0 0 0 0 0 1
72 5.9 516 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) werkl M1 M2 M3 M4
-0.10458 0.01219 0.36505 0.45729 0.39581 0.23965
M5 M6 M7 M8 M9 M10
0.14078 0.03511 -0.36074 -0.44520 -0.46844 -0.35232
M11
-0.20938
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.57853 -0.21065 -0.01003 0.23944 0.60425
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.104584 0.592950 -0.176 0.8606
werkl 0.012186 0.001042 11.690 <2e-16 ***
M1 0.365055 0.179337 2.036 0.0463 *
M2 0.457286 0.179364 2.549 0.0134 *
M3 0.395811 0.179868 2.201 0.0317 *
M4 0.239654 0.180499 1.328 0.1894
M5 0.140784 0.181919 0.774 0.4421
M6 0.035110 0.181607 0.193 0.8474
M7 -0.360738 0.181290 -1.990 0.0512 .
M8 -0.445201 0.183039 -2.432 0.0181 *
M9 -0.468443 0.181607 -2.579 0.0124 *
M10 -0.352323 0.179803 -1.959 0.0548 .
M11 -0.209381 0.179364 -1.167 0.2478
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.3106 on 59 degrees of freedom
Multiple R-squared: 0.749, Adjusted R-squared: 0.6979
F-statistic: 14.67 on 12 and 59 DF, p-value: 1.464e-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.6426042 0.71479151 0.35739575
[2,] 0.8213574 0.35728510 0.17864255
[3,] 0.7693778 0.46124437 0.23062219
[4,] 0.7806104 0.43877910 0.21938955
[5,] 0.9281381 0.14372389 0.07186195
[6,] 0.9616434 0.07671317 0.03835658
[7,] 0.9384758 0.12304833 0.06152416
[8,] 0.9301279 0.13974422 0.06987211
[9,] 0.9444103 0.11117946 0.05558973
[10,] 0.9397892 0.12042156 0.06021078
[11,] 0.9100058 0.17998832 0.08999416
[12,] 0.8687512 0.26249752 0.13124876
[13,] 0.8378506 0.32429885 0.16214942
[14,] 0.8086093 0.38278143 0.19139072
[15,] 0.7550400 0.48991998 0.24495999
[16,] 0.6838692 0.63226157 0.31613079
[17,] 0.6272137 0.74557263 0.37278632
[18,] 0.5546882 0.89062353 0.44531177
[19,] 0.4738968 0.94779365 0.52610317
[20,] 0.3919737 0.78394745 0.60802628
[21,] 0.3163678 0.63273563 0.68363219
[22,] 0.2579351 0.51587019 0.74206491
[23,] 0.2014227 0.40284534 0.79857733
[24,] 0.1829778 0.36595566 0.81702217
[25,] 0.2872743 0.57454855 0.71272572
[26,] 0.3503158 0.70063159 0.64968420
[27,] 0.3111071 0.62221420 0.68889290
[28,] 0.3026780 0.60535598 0.69732201
[29,] 0.4341694 0.86833876 0.56583062
[30,] 0.5500973 0.89980543 0.44990271
[31,] 0.5336200 0.93275999 0.46637999
[32,] 0.4429521 0.88590430 0.55704785
[33,] 0.3599341 0.71986818 0.64006591
[34,] 0.2924023 0.58480470 0.70759765
[35,] 0.2284575 0.45691493 0.77154253
[36,] 0.1873571 0.37471420 0.81264290
[37,] 0.2513568 0.50271366 0.74864317
[38,] 0.5805842 0.83883154 0.41941577
[39,] 0.7057141 0.58857185 0.29428592
[40,] 0.5763076 0.84738488 0.42369244
[41,] 0.5531683 0.89366349 0.44683174
> postscript(file="/var/www/html/rcomp/tmp/1zv7v1258984201.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/25ki31258984201.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/349xw1258984201.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/4fn3w1258984201.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/5zwqf1258984201.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 = 72
Frequency = 1
1 2 3 4 5
0.4150919047 0.2472320981 0.1940079891 0.3623503139 0.3587072904
6 7 8 9 10
0.2912663984 0.0315940715 -0.0179870140 0.0296267062 0.2719217446
11 12 13 14 15
0.4483243418 0.5414572094 0.4911018985 0.4110562778 0.1456463548
16 17 18 19 20
-0.3641531794 -0.4799820170 -0.2474229091 0.3269487191 0.6042527491
21 22 23 24 25
0.5031232128 0.1113742962 -0.1244089207 -0.2459753544 -0.2622867102
26 27 28 29 30
-0.1301465168 -0.1077422540 -0.2175417882 -0.0455564399 -0.0642540756
31 32 33 34 35
-0.0020682615 0.0849080953 0.0203360014 -0.0008115179 -0.0365947348
36 37 38 39 40
-0.0703469826 -0.1866583384 -0.0423323309 0.1410010024 0.3702723977
41 42 43 44 45
0.2813286755 0.0870026680 -0.3898824474 -0.5785344624 -0.4821774859
46 47 48 49 50
-0.2083519796 0.0167938740 0.1170855812 -0.1967122874 -0.1427139530
51 52 53 54 55
0.0259200790 0.2551914743 0.2368491495 0.0887529111 -0.1978045312
56 57 58 59 60
-0.4351998025 -0.3316839864 -0.0650173197 -0.0008005366 -0.0589244127
61 62 63 64 65
-0.2605364672 -0.3430955751 -0.3988331713 -0.4061192183 -0.3513466585
66 67 68 69 70
-0.1553449929 0.2312124494 0.3425604344 0.2607755519 -0.1091152237
71 72
-0.3033140238 -0.2832960409
> postscript(file="/var/www/html/rcomp/tmp/6fhbj1258984201.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 0.4150919047 NA
1 0.2472320981 0.4150919047
2 0.1940079891 0.2472320981
3 0.3623503139 0.1940079891
4 0.3587072904 0.3623503139
5 0.2912663984 0.3587072904
6 0.0315940715 0.2912663984
7 -0.0179870140 0.0315940715
8 0.0296267062 -0.0179870140
9 0.2719217446 0.0296267062
10 0.4483243418 0.2719217446
11 0.5414572094 0.4483243418
12 0.4911018985 0.5414572094
13 0.4110562778 0.4911018985
14 0.1456463548 0.4110562778
15 -0.3641531794 0.1456463548
16 -0.4799820170 -0.3641531794
17 -0.2474229091 -0.4799820170
18 0.3269487191 -0.2474229091
19 0.6042527491 0.3269487191
20 0.5031232128 0.6042527491
21 0.1113742962 0.5031232128
22 -0.1244089207 0.1113742962
23 -0.2459753544 -0.1244089207
24 -0.2622867102 -0.2459753544
25 -0.1301465168 -0.2622867102
26 -0.1077422540 -0.1301465168
27 -0.2175417882 -0.1077422540
28 -0.0455564399 -0.2175417882
29 -0.0642540756 -0.0455564399
30 -0.0020682615 -0.0642540756
31 0.0849080953 -0.0020682615
32 0.0203360014 0.0849080953
33 -0.0008115179 0.0203360014
34 -0.0365947348 -0.0008115179
35 -0.0703469826 -0.0365947348
36 -0.1866583384 -0.0703469826
37 -0.0423323309 -0.1866583384
38 0.1410010024 -0.0423323309
39 0.3702723977 0.1410010024
40 0.2813286755 0.3702723977
41 0.0870026680 0.2813286755
42 -0.3898824474 0.0870026680
43 -0.5785344624 -0.3898824474
44 -0.4821774859 -0.5785344624
45 -0.2083519796 -0.4821774859
46 0.0167938740 -0.2083519796
47 0.1170855812 0.0167938740
48 -0.1967122874 0.1170855812
49 -0.1427139530 -0.1967122874
50 0.0259200790 -0.1427139530
51 0.2551914743 0.0259200790
52 0.2368491495 0.2551914743
53 0.0887529111 0.2368491495
54 -0.1978045312 0.0887529111
55 -0.4351998025 -0.1978045312
56 -0.3316839864 -0.4351998025
57 -0.0650173197 -0.3316839864
58 -0.0008005366 -0.0650173197
59 -0.0589244127 -0.0008005366
60 -0.2605364672 -0.0589244127
61 -0.3430955751 -0.2605364672
62 -0.3988331713 -0.3430955751
63 -0.4061192183 -0.3988331713
64 -0.3513466585 -0.4061192183
65 -0.1553449929 -0.3513466585
66 0.2312124494 -0.1553449929
67 0.3425604344 0.2312124494
68 0.2607755519 0.3425604344
69 -0.1091152237 0.2607755519
70 -0.3033140238 -0.1091152237
71 -0.2832960409 -0.3033140238
72 NA -0.2832960409
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.2472320981 0.4150919047
[2,] 0.1940079891 0.2472320981
[3,] 0.3623503139 0.1940079891
[4,] 0.3587072904 0.3623503139
[5,] 0.2912663984 0.3587072904
[6,] 0.0315940715 0.2912663984
[7,] -0.0179870140 0.0315940715
[8,] 0.0296267062 -0.0179870140
[9,] 0.2719217446 0.0296267062
[10,] 0.4483243418 0.2719217446
[11,] 0.5414572094 0.4483243418
[12,] 0.4911018985 0.5414572094
[13,] 0.4110562778 0.4911018985
[14,] 0.1456463548 0.4110562778
[15,] -0.3641531794 0.1456463548
[16,] -0.4799820170 -0.3641531794
[17,] -0.2474229091 -0.4799820170
[18,] 0.3269487191 -0.2474229091
[19,] 0.6042527491 0.3269487191
[20,] 0.5031232128 0.6042527491
[21,] 0.1113742962 0.5031232128
[22,] -0.1244089207 0.1113742962
[23,] -0.2459753544 -0.1244089207
[24,] -0.2622867102 -0.2459753544
[25,] -0.1301465168 -0.2622867102
[26,] -0.1077422540 -0.1301465168
[27,] -0.2175417882 -0.1077422540
[28,] -0.0455564399 -0.2175417882
[29,] -0.0642540756 -0.0455564399
[30,] -0.0020682615 -0.0642540756
[31,] 0.0849080953 -0.0020682615
[32,] 0.0203360014 0.0849080953
[33,] -0.0008115179 0.0203360014
[34,] -0.0365947348 -0.0008115179
[35,] -0.0703469826 -0.0365947348
[36,] -0.1866583384 -0.0703469826
[37,] -0.0423323309 -0.1866583384
[38,] 0.1410010024 -0.0423323309
[39,] 0.3702723977 0.1410010024
[40,] 0.2813286755 0.3702723977
[41,] 0.0870026680 0.2813286755
[42,] -0.3898824474 0.0870026680
[43,] -0.5785344624 -0.3898824474
[44,] -0.4821774859 -0.5785344624
[45,] -0.2083519796 -0.4821774859
[46,] 0.0167938740 -0.2083519796
[47,] 0.1170855812 0.0167938740
[48,] -0.1967122874 0.1170855812
[49,] -0.1427139530 -0.1967122874
[50,] 0.0259200790 -0.1427139530
[51,] 0.2551914743 0.0259200790
[52,] 0.2368491495 0.2551914743
[53,] 0.0887529111 0.2368491495
[54,] -0.1978045312 0.0887529111
[55,] -0.4351998025 -0.1978045312
[56,] -0.3316839864 -0.4351998025
[57,] -0.0650173197 -0.3316839864
[58,] -0.0008005366 -0.0650173197
[59,] -0.0589244127 -0.0008005366
[60,] -0.2605364672 -0.0589244127
[61,] -0.3430955751 -0.2605364672
[62,] -0.3988331713 -0.3430955751
[63,] -0.4061192183 -0.3988331713
[64,] -0.3513466585 -0.4061192183
[65,] -0.1553449929 -0.3513466585
[66,] 0.2312124494 -0.1553449929
[67,] 0.3425604344 0.2312124494
[68,] 0.2607755519 0.3425604344
[69,] -0.1091152237 0.2607755519
[70,] -0.3033140238 -0.1091152237
[71,] -0.2832960409 -0.3033140238
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.2472320981 0.4150919047
2 0.1940079891 0.2472320981
3 0.3623503139 0.1940079891
4 0.3587072904 0.3623503139
5 0.2912663984 0.3587072904
6 0.0315940715 0.2912663984
7 -0.0179870140 0.0315940715
8 0.0296267062 -0.0179870140
9 0.2719217446 0.0296267062
10 0.4483243418 0.2719217446
11 0.5414572094 0.4483243418
12 0.4911018985 0.5414572094
13 0.4110562778 0.4911018985
14 0.1456463548 0.4110562778
15 -0.3641531794 0.1456463548
16 -0.4799820170 -0.3641531794
17 -0.2474229091 -0.4799820170
18 0.3269487191 -0.2474229091
19 0.6042527491 0.3269487191
20 0.5031232128 0.6042527491
21 0.1113742962 0.5031232128
22 -0.1244089207 0.1113742962
23 -0.2459753544 -0.1244089207
24 -0.2622867102 -0.2459753544
25 -0.1301465168 -0.2622867102
26 -0.1077422540 -0.1301465168
27 -0.2175417882 -0.1077422540
28 -0.0455564399 -0.2175417882
29 -0.0642540756 -0.0455564399
30 -0.0020682615 -0.0642540756
31 0.0849080953 -0.0020682615
32 0.0203360014 0.0849080953
33 -0.0008115179 0.0203360014
34 -0.0365947348 -0.0008115179
35 -0.0703469826 -0.0365947348
36 -0.1866583384 -0.0703469826
37 -0.0423323309 -0.1866583384
38 0.1410010024 -0.0423323309
39 0.3702723977 0.1410010024
40 0.2813286755 0.3702723977
41 0.0870026680 0.2813286755
42 -0.3898824474 0.0870026680
43 -0.5785344624 -0.3898824474
44 -0.4821774859 -0.5785344624
45 -0.2083519796 -0.4821774859
46 0.0167938740 -0.2083519796
47 0.1170855812 0.0167938740
48 -0.1967122874 0.1170855812
49 -0.1427139530 -0.1967122874
50 0.0259200790 -0.1427139530
51 0.2551914743 0.0259200790
52 0.2368491495 0.2551914743
53 0.0887529111 0.2368491495
54 -0.1978045312 0.0887529111
55 -0.4351998025 -0.1978045312
56 -0.3316839864 -0.4351998025
57 -0.0650173197 -0.3316839864
58 -0.0008005366 -0.0650173197
59 -0.0589244127 -0.0008005366
60 -0.2605364672 -0.0589244127
61 -0.3430955751 -0.2605364672
62 -0.3988331713 -0.3430955751
63 -0.4061192183 -0.3988331713
64 -0.3513466585 -0.4061192183
65 -0.1553449929 -0.3513466585
66 0.2312124494 -0.1553449929
67 0.3425604344 0.2312124494
68 0.2607755519 0.3425604344
69 -0.1091152237 0.2607755519
70 -0.3033140238 -0.1091152237
71 -0.2832960409 -0.3033140238
> 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/7bi2m1258984201.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/8c8c61258984201.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/9lt9g1258984202.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/10o6s11258984202.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/11hzel1258984202.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/128jig1258984202.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/13am961258984202.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/14m8wl1258984202.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/15cpe21258984202.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/16ld251258984202.tab")
+ }
>
> system("convert tmp/1zv7v1258984201.ps tmp/1zv7v1258984201.png")
> system("convert tmp/25ki31258984201.ps tmp/25ki31258984201.png")
> system("convert tmp/349xw1258984201.ps tmp/349xw1258984201.png")
> system("convert tmp/4fn3w1258984201.ps tmp/4fn3w1258984201.png")
> system("convert tmp/5zwqf1258984201.ps tmp/5zwqf1258984201.png")
> system("convert tmp/6fhbj1258984201.ps tmp/6fhbj1258984201.png")
> system("convert tmp/7bi2m1258984201.ps tmp/7bi2m1258984201.png")
> system("convert tmp/8c8c61258984201.ps tmp/8c8c61258984201.png")
> system("convert tmp/9lt9g1258984202.ps tmp/9lt9g1258984202.png")
> system("convert tmp/10o6s11258984202.ps tmp/10o6s11258984202.png")
>
>
> proc.time()
user system elapsed
2.626 1.608 3.465