R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-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(6,100,6,9,9,99,2,8,7,108,4,3,8,103,0,4,1,99,8,7,9,115,0,7,9,90,8,1,7,95,9,9,2,114,4,4,9,108,2,9,8,112,6,3,3,109,1,3,0,105,0,3,7,105,0,2,5,118,5,8,7,103,7,6,9,112,5,2,6,116,6,6,4,96,6,6,5,101,9,0,8,116,5,4,5,119,3,9,9,115,4,5,0,108,5,2,0,111,5,8,3,108,8,3,8,121,8,9,1,109,6,8,3,112,2,8,2,119,6,8,5,104,1,5,2,105,3,4,5,115,0,4,4,124,1,1,3,116,8,6,0,107,5,2,7,115,6,1,8,116,2,3,8,116,3,8,3,119,0,9,1,111,9,1,9,118,6,7,0,106,9,2,8,103,2,5,8,118,6,0,7,118,7,5,4,102,8,0,3,100,6,1,0,94,9,6,2,94,5,3,1,102,9,9,1,95,3,3,8,92,5,5,7,102,7,8,6,91,5,7,1,89,5,4,5,104,2,8,1,105,2,1,1,99,0,2,7,95,5,0,3,90,5,8,8,96,1,7,5,113,0,5,7,101,9,0,5,101,4,9,7,113,6,8,2,96,6,2,4,97,8,2,0,114,9,9,0,112,5,5,5,108,4,9,3,107,0,0,1,103,5,9,1,107,5,0,3,122,3,9),dim=c(4,75),dimnames=list(c('steenkool','aardolie','uranium','metaal'),1:75))
> y <- array(NA,dim=c(4,75),dimnames=list(c('steenkool','aardolie','uranium','metaal'),1:75))
> 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 = 'Do not include Seasonal Dummies'
> par1 = '3'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
uranium steenkool aardolie metaal
1 6 6 100 9
2 2 9 99 8
3 4 7 108 3
4 0 8 103 4
5 8 1 99 7
6 0 9 115 7
7 8 9 90 1
8 9 7 95 9
9 4 2 114 4
10 2 9 108 9
11 6 8 112 3
12 1 3 109 3
13 0 0 105 3
14 0 7 105 2
15 5 5 118 8
16 7 7 103 6
17 5 9 112 2
18 6 6 116 6
19 6 4 96 6
20 9 5 101 0
21 5 8 116 4
22 3 5 119 9
23 4 9 115 5
24 5 0 108 2
25 5 0 111 8
26 8 3 108 3
27 8 8 121 9
28 6 1 109 8
29 2 3 112 8
30 6 2 119 8
31 1 5 104 5
32 3 2 105 4
33 0 5 115 4
34 1 4 124 1
35 8 3 116 6
36 5 0 107 2
37 6 7 115 1
38 2 8 116 3
39 3 8 116 8
40 0 3 119 9
41 9 1 111 1
42 6 9 118 7
43 9 0 106 2
44 2 8 103 5
45 6 8 118 0
46 7 7 118 5
47 8 4 102 0
48 6 3 100 1
49 9 0 94 6
50 5 2 94 3
51 9 1 102 9
52 3 1 95 3
53 5 8 92 5
54 7 7 102 8
55 5 6 91 7
56 5 1 89 4
57 2 5 104 8
58 2 1 105 1
59 0 1 99 2
60 5 7 95 0
61 5 3 90 8
62 1 8 96 7
63 0 5 113 5
64 9 7 101 0
65 4 5 101 9
66 6 7 113 8
67 6 2 96 2
68 8 4 97 2
69 9 0 114 9
70 5 0 112 5
71 4 5 108 9
72 0 3 107 0
73 5 1 103 9
74 5 1 107 0
75 3 3 122 9
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) steenkool aardolie metaal
10.41984 -0.09833 -0.05027 0.00832
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-5.362 -2.339 0.044 2.314 4.374
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 10.41984 3.95313 2.636 0.0103 *
steenkool -0.09833 0.10926 -0.900 0.3712
aardolie -0.05027 0.03754 -1.339 0.1848
metaal 0.00832 0.10779 0.077 0.9387
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.808 on 71 degrees of freedom
Multiple R-squared: 0.03971, Adjusted R-squared: -0.0008651
F-statistic: 0.9787 on 3 and 71 DF, p-value: 0.4078
> 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.5014083 0.9971833 0.4985917
[2,] 0.5282918 0.9434163 0.4717082
[3,] 0.3846598 0.7693197 0.6153402
[4,] 0.2699838 0.5399676 0.7300162
[5,] 0.4618545 0.9237090 0.5381455
[6,] 0.5532785 0.8934431 0.4467215
[7,] 0.7417068 0.5165864 0.2582932
[8,] 0.7683696 0.4632608 0.2316304
[9,] 0.7757882 0.4484236 0.2242118
[10,] 0.7620114 0.4759772 0.2379886
[11,] 0.7581612 0.4836775 0.2418388
[12,] 0.7597735 0.4804530 0.2402265
[13,] 0.6925399 0.6149201 0.3074601
[14,] 0.7803616 0.4392767 0.2196384
[15,] 0.7443020 0.5113961 0.2556980
[16,] 0.6813327 0.6373347 0.3186673
[17,] 0.6129694 0.7740612 0.3870306
[18,] 0.5408525 0.9182950 0.4591475
[19,] 0.4684731 0.9369462 0.5315269
[20,] 0.4965000 0.9929999 0.5035000
[21,] 0.6116642 0.7766716 0.3883358
[22,] 0.5483214 0.9033573 0.4516786
[23,] 0.5334001 0.9331998 0.4665999
[24,] 0.4888671 0.9777343 0.5111329
[25,] 0.5381768 0.9236464 0.4618232
[26,] 0.4977687 0.9955374 0.5022313
[27,] 0.5629906 0.8740189 0.4370094
[28,] 0.5541322 0.8917356 0.4458678
[29,] 0.5991640 0.8016720 0.4008360
[30,] 0.5332369 0.9335263 0.4667631
[31,] 0.5045472 0.9909057 0.4954528
[32,] 0.4645118 0.9290236 0.5354882
[33,] 0.4040583 0.8081166 0.5959417
[34,] 0.5027986 0.9944027 0.4972014
[35,] 0.5720762 0.8558477 0.4279238
[36,] 0.5407038 0.9185924 0.4592962
[37,] 0.5890582 0.8218835 0.4109418
[38,] 0.5802031 0.8395938 0.4197969
[39,] 0.5453501 0.9092998 0.4546499
[40,] 0.5597215 0.8805570 0.4402785
[41,] 0.5912753 0.8174495 0.4087247
[42,] 0.5373413 0.9253175 0.4626587
[43,] 0.5553506 0.8892988 0.4446494
[44,] 0.4867599 0.9735198 0.5132401
[45,] 0.5503078 0.8993844 0.4496922
[46,] 0.5189757 0.9620485 0.4810243
[47,] 0.4415566 0.8831133 0.5584434
[48,] 0.4204224 0.8408448 0.5795776
[49,] 0.3458215 0.6916429 0.6541785
[50,] 0.2785520 0.5571040 0.7214480
[51,] 0.2579442 0.5158885 0.7420558
[52,] 0.2406974 0.4813949 0.7593026
[53,] 0.4110646 0.8221291 0.5889354
[54,] 0.3254696 0.6509392 0.6745304
[55,] 0.2525320 0.5050639 0.7474680
[56,] 0.3260593 0.6521187 0.6739407
[57,] 0.4292521 0.8585042 0.5707479
[58,] 0.5829022 0.8341957 0.4170978
[59,] 0.5339615 0.9320771 0.4660385
[60,] 0.5237026 0.9525948 0.4762974
[61,] 0.3799650 0.7599300 0.6200350
[62,] 0.6196865 0.7606269 0.3803135
> postscript(file="/var/wessaorg/rcomp/tmp/148q11353014302.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/wessaorg/rcomp/tmp/24iox1353014302.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/wessaorg/rcomp/tmp/3d37t1353014302.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/wessaorg/rcomp/tmp/4vh4r1353014302.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/wessaorg/rcomp/tmp/5zhhs1353014302.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 = 75
Frequency = 1
1 2 3 4 5 6
1.122119352 -2.624841565 -0.327480227 -4.488814674 2.596845828 -3.812222941
7 8 9 10 11 12
2.980983193 3.969105266 -0.525834345 -2.180744153 1.971923460 -3.670528070
13 14 15 16 17 18
-5.166589999 -4.469965790 0.936946138 2.396215482 1.078572942 1.951378699
19 20 21 22 23 24
0.749347629 4.148942125 1.164677664 -1.021105582 0.204417782 -0.007463713
25 26 27 28 29 30
0.093420043 3.279203289 4.374419064 1.091211881 -2.561323953 1.692227416
31 32 33 34 35 36
-3.741853758 -1.978252118 -4.180578341 -2.801528605 3.656391336 -0.057732354
37 38 39 40 41 42
2.041040986 -1.827001975 -0.868603782 -4.217763824 4.249991694 2.338582984
43 44 45 46 47 48
3.891999004 -2.497135036 2.298496393 3.158565464 3.100881646 0.893694880
49 50 51 52 53 54
3.255493862 -0.522886812 3.731011030 -2.570947292 -0.050090091 2.329306117
55 56 57 58 59 60
-0.313657698 -0.880879502 -2.766814842 -3.051620155 -5.361552365 0.043988519
61 62 63 64 65 66
-0.667234064 -3.865656249 -4.289435985 4.345600368 -0.925941128 1.882261173
67 68 69 70 71 72
0.585970832 2.832897716 4.235905605 0.168649768 -0.574060638 -4.746104268
73 74 75
-0.218720329 0.057237490 -1.066957900
> postscript(file="/var/wessaorg/rcomp/tmp/6qac11353014302.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 = 75
Frequency = 1
lag(myerror, k = 1) myerror
0 1.122119352 NA
1 -2.624841565 1.122119352
2 -0.327480227 -2.624841565
3 -4.488814674 -0.327480227
4 2.596845828 -4.488814674
5 -3.812222941 2.596845828
6 2.980983193 -3.812222941
7 3.969105266 2.980983193
8 -0.525834345 3.969105266
9 -2.180744153 -0.525834345
10 1.971923460 -2.180744153
11 -3.670528070 1.971923460
12 -5.166589999 -3.670528070
13 -4.469965790 -5.166589999
14 0.936946138 -4.469965790
15 2.396215482 0.936946138
16 1.078572942 2.396215482
17 1.951378699 1.078572942
18 0.749347629 1.951378699
19 4.148942125 0.749347629
20 1.164677664 4.148942125
21 -1.021105582 1.164677664
22 0.204417782 -1.021105582
23 -0.007463713 0.204417782
24 0.093420043 -0.007463713
25 3.279203289 0.093420043
26 4.374419064 3.279203289
27 1.091211881 4.374419064
28 -2.561323953 1.091211881
29 1.692227416 -2.561323953
30 -3.741853758 1.692227416
31 -1.978252118 -3.741853758
32 -4.180578341 -1.978252118
33 -2.801528605 -4.180578341
34 3.656391336 -2.801528605
35 -0.057732354 3.656391336
36 2.041040986 -0.057732354
37 -1.827001975 2.041040986
38 -0.868603782 -1.827001975
39 -4.217763824 -0.868603782
40 4.249991694 -4.217763824
41 2.338582984 4.249991694
42 3.891999004 2.338582984
43 -2.497135036 3.891999004
44 2.298496393 -2.497135036
45 3.158565464 2.298496393
46 3.100881646 3.158565464
47 0.893694880 3.100881646
48 3.255493862 0.893694880
49 -0.522886812 3.255493862
50 3.731011030 -0.522886812
51 -2.570947292 3.731011030
52 -0.050090091 -2.570947292
53 2.329306117 -0.050090091
54 -0.313657698 2.329306117
55 -0.880879502 -0.313657698
56 -2.766814842 -0.880879502
57 -3.051620155 -2.766814842
58 -5.361552365 -3.051620155
59 0.043988519 -5.361552365
60 -0.667234064 0.043988519
61 -3.865656249 -0.667234064
62 -4.289435985 -3.865656249
63 4.345600368 -4.289435985
64 -0.925941128 4.345600368
65 1.882261173 -0.925941128
66 0.585970832 1.882261173
67 2.832897716 0.585970832
68 4.235905605 2.832897716
69 0.168649768 4.235905605
70 -0.574060638 0.168649768
71 -4.746104268 -0.574060638
72 -0.218720329 -4.746104268
73 0.057237490 -0.218720329
74 -1.066957900 0.057237490
75 NA -1.066957900
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.624841565 1.122119352
[2,] -0.327480227 -2.624841565
[3,] -4.488814674 -0.327480227
[4,] 2.596845828 -4.488814674
[5,] -3.812222941 2.596845828
[6,] 2.980983193 -3.812222941
[7,] 3.969105266 2.980983193
[8,] -0.525834345 3.969105266
[9,] -2.180744153 -0.525834345
[10,] 1.971923460 -2.180744153
[11,] -3.670528070 1.971923460
[12,] -5.166589999 -3.670528070
[13,] -4.469965790 -5.166589999
[14,] 0.936946138 -4.469965790
[15,] 2.396215482 0.936946138
[16,] 1.078572942 2.396215482
[17,] 1.951378699 1.078572942
[18,] 0.749347629 1.951378699
[19,] 4.148942125 0.749347629
[20,] 1.164677664 4.148942125
[21,] -1.021105582 1.164677664
[22,] 0.204417782 -1.021105582
[23,] -0.007463713 0.204417782
[24,] 0.093420043 -0.007463713
[25,] 3.279203289 0.093420043
[26,] 4.374419064 3.279203289
[27,] 1.091211881 4.374419064
[28,] -2.561323953 1.091211881
[29,] 1.692227416 -2.561323953
[30,] -3.741853758 1.692227416
[31,] -1.978252118 -3.741853758
[32,] -4.180578341 -1.978252118
[33,] -2.801528605 -4.180578341
[34,] 3.656391336 -2.801528605
[35,] -0.057732354 3.656391336
[36,] 2.041040986 -0.057732354
[37,] -1.827001975 2.041040986
[38,] -0.868603782 -1.827001975
[39,] -4.217763824 -0.868603782
[40,] 4.249991694 -4.217763824
[41,] 2.338582984 4.249991694
[42,] 3.891999004 2.338582984
[43,] -2.497135036 3.891999004
[44,] 2.298496393 -2.497135036
[45,] 3.158565464 2.298496393
[46,] 3.100881646 3.158565464
[47,] 0.893694880 3.100881646
[48,] 3.255493862 0.893694880
[49,] -0.522886812 3.255493862
[50,] 3.731011030 -0.522886812
[51,] -2.570947292 3.731011030
[52,] -0.050090091 -2.570947292
[53,] 2.329306117 -0.050090091
[54,] -0.313657698 2.329306117
[55,] -0.880879502 -0.313657698
[56,] -2.766814842 -0.880879502
[57,] -3.051620155 -2.766814842
[58,] -5.361552365 -3.051620155
[59,] 0.043988519 -5.361552365
[60,] -0.667234064 0.043988519
[61,] -3.865656249 -0.667234064
[62,] -4.289435985 -3.865656249
[63,] 4.345600368 -4.289435985
[64,] -0.925941128 4.345600368
[65,] 1.882261173 -0.925941128
[66,] 0.585970832 1.882261173
[67,] 2.832897716 0.585970832
[68,] 4.235905605 2.832897716
[69,] 0.168649768 4.235905605
[70,] -0.574060638 0.168649768
[71,] -4.746104268 -0.574060638
[72,] -0.218720329 -4.746104268
[73,] 0.057237490 -0.218720329
[74,] -1.066957900 0.057237490
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.624841565 1.122119352
2 -0.327480227 -2.624841565
3 -4.488814674 -0.327480227
4 2.596845828 -4.488814674
5 -3.812222941 2.596845828
6 2.980983193 -3.812222941
7 3.969105266 2.980983193
8 -0.525834345 3.969105266
9 -2.180744153 -0.525834345
10 1.971923460 -2.180744153
11 -3.670528070 1.971923460
12 -5.166589999 -3.670528070
13 -4.469965790 -5.166589999
14 0.936946138 -4.469965790
15 2.396215482 0.936946138
16 1.078572942 2.396215482
17 1.951378699 1.078572942
18 0.749347629 1.951378699
19 4.148942125 0.749347629
20 1.164677664 4.148942125
21 -1.021105582 1.164677664
22 0.204417782 -1.021105582
23 -0.007463713 0.204417782
24 0.093420043 -0.007463713
25 3.279203289 0.093420043
26 4.374419064 3.279203289
27 1.091211881 4.374419064
28 -2.561323953 1.091211881
29 1.692227416 -2.561323953
30 -3.741853758 1.692227416
31 -1.978252118 -3.741853758
32 -4.180578341 -1.978252118
33 -2.801528605 -4.180578341
34 3.656391336 -2.801528605
35 -0.057732354 3.656391336
36 2.041040986 -0.057732354
37 -1.827001975 2.041040986
38 -0.868603782 -1.827001975
39 -4.217763824 -0.868603782
40 4.249991694 -4.217763824
41 2.338582984 4.249991694
42 3.891999004 2.338582984
43 -2.497135036 3.891999004
44 2.298496393 -2.497135036
45 3.158565464 2.298496393
46 3.100881646 3.158565464
47 0.893694880 3.100881646
48 3.255493862 0.893694880
49 -0.522886812 3.255493862
50 3.731011030 -0.522886812
51 -2.570947292 3.731011030
52 -0.050090091 -2.570947292
53 2.329306117 -0.050090091
54 -0.313657698 2.329306117
55 -0.880879502 -0.313657698
56 -2.766814842 -0.880879502
57 -3.051620155 -2.766814842
58 -5.361552365 -3.051620155
59 0.043988519 -5.361552365
60 -0.667234064 0.043988519
61 -3.865656249 -0.667234064
62 -4.289435985 -3.865656249
63 4.345600368 -4.289435985
64 -0.925941128 4.345600368
65 1.882261173 -0.925941128
66 0.585970832 1.882261173
67 2.832897716 0.585970832
68 4.235905605 2.832897716
69 0.168649768 4.235905605
70 -0.574060638 0.168649768
71 -4.746104268 -0.574060638
72 -0.218720329 -4.746104268
73 0.057237490 -0.218720329
74 -1.066957900 0.057237490
> 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/wessaorg/rcomp/tmp/7s0911353014302.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/wessaorg/rcomp/tmp/8dwxz1353014302.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/wessaorg/rcomp/tmp/9o37y1353014302.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/wessaorg/rcomp/tmp/109jyb1353014302.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11bgvb1353014302.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/wessaorg/rcomp/tmp/12k2lk1353014302.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/wessaorg/rcomp/tmp/13tuv11353014302.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/wessaorg/rcomp/tmp/14l7fl1353014303.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/wessaorg/rcomp/tmp/15kdba1353014303.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/wessaorg/rcomp/tmp/161suo1353014303.tab")
+ }
>
> try(system("convert tmp/148q11353014302.ps tmp/148q11353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/24iox1353014302.ps tmp/24iox1353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/3d37t1353014302.ps tmp/3d37t1353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/4vh4r1353014302.ps tmp/4vh4r1353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/5zhhs1353014302.ps tmp/5zhhs1353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/6qac11353014302.ps tmp/6qac11353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/7s0911353014302.ps tmp/7s0911353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/8dwxz1353014302.ps tmp/8dwxz1353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/9o37y1353014302.ps tmp/9o37y1353014302.png",intern=TRUE))
character(0)
> try(system("convert tmp/109jyb1353014302.ps tmp/109jyb1353014302.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
8.865 1.529 10.380