R version 2.13.0 (2011-04-13)
Copyright (C) 2011 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(11
+ ,8
+ ,7
+ ,18
+ ,12
+ ,20
+ ,4
+ ,2
+ ,16
+ ,12
+ ,9
+ ,22
+ ,14
+ ,18
+ ,5
+ ,0
+ ,24
+ ,24
+ ,19
+ ,22
+ ,25
+ ,24
+ ,4
+ ,0
+ ,15
+ ,16
+ ,12
+ ,19
+ ,15
+ ,20
+ ,4
+ ,4
+ ,17
+ ,19
+ ,16
+ ,25
+ ,20
+ ,20
+ ,9
+ ,0
+ ,19
+ ,16
+ ,17
+ ,28
+ ,21
+ ,24
+ ,8
+ ,-1
+ ,19
+ ,15
+ ,9
+ ,16
+ ,15
+ ,21
+ ,11
+ ,0
+ ,28
+ ,28
+ ,28
+ ,28
+ ,28
+ ,28
+ ,4
+ ,1
+ ,26
+ ,21
+ ,20
+ ,21
+ ,11
+ ,10
+ ,4
+ ,0
+ ,15
+ ,18
+ ,16
+ ,22
+ ,22
+ ,22
+ ,6
+ ,3
+ ,26
+ ,22
+ ,22
+ ,24
+ ,22
+ ,19
+ ,4
+ ,-1
+ ,24
+ ,22
+ ,12
+ ,26
+ ,24
+ ,23
+ ,4
+ ,4
+ ,25
+ ,25
+ ,18
+ ,28
+ ,23
+ ,24
+ ,4
+ ,1
+ ,22
+ ,20
+ ,20
+ ,24
+ ,24
+ ,24
+ ,11
+ ,0
+ ,15
+ ,16
+ ,12
+ ,20
+ ,21
+ ,25
+ ,4
+ ,-2
+ ,21
+ ,19
+ ,16
+ ,26
+ ,20
+ ,24
+ ,4
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,5
+ ,20
+ ,22
+ ,23
+ ,14
+ ,-3
+ ,16
+ ,11
+ ,10
+ ,19
+ ,12
+ ,17
+ ,11
+ ,-2
+ ,22
+ ,23
+ ,22
+ ,24
+ ,24
+ ,23
+ ,4
+ ,1
+ ,25
+ ,19
+ ,17
+ ,27
+ ,18
+ ,27
+ ,4
+ ,-4
+ ,22
+ ,18
+ ,20
+ ,23
+ ,19
+ ,24
+ ,5
+ ,1
+ ,22
+ ,23
+ ,18
+ ,24
+ ,22
+ ,23
+ ,4
+ ,0)
+ ,dim=c(8
+ ,64)
+ ,dimnames=list(c('I1'
+ ,'I2'
+ ,'I3'
+ ,'E1'
+ ,'E2'
+ ,'E3'
+ ,'A'
+ ,'test')
+ ,1:64))
> y <- array(NA,dim=c(8,64),dimnames=list(c('I1','I2','I3','E1','E2','E3','A','test'),1:64))
> 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 = '8'
> 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
test I1 I2 I3 E1 E2 E3 A
1 2 11 8 7 18 12 20 4
2 0 16 12 9 22 14 18 5
3 0 24 24 19 22 25 24 4
4 4 15 16 12 19 15 20 4
5 0 17 19 16 25 20 20 9
6 -1 19 16 17 28 21 24 8
7 0 19 15 9 16 15 21 11
8 1 28 28 28 28 28 28 4
9 0 26 21 20 21 11 10 4
10 3 15 18 16 22 22 22 6
11 -1 26 22 22 24 22 19 4
12 4 24 22 12 26 24 23 4
13 1 25 25 18 28 23 24 4
14 0 22 20 20 24 24 24 11
15 -2 15 16 12 20 21 25 4
16 -4 21 19 16 26 20 24 4
17 2 27 26 21 28 25 28 6
18 2 26 20 17 23 24 22 8
19 -4 22 19 17 24 21 26 5
20 2 22 23 18 22 25 21 9
21 2 20 18 15 21 23 26 4
22 0 21 16 20 25 20 23 7
23 -3 22 21 21 21 22 24 4
24 2 21 20 12 26 25 25 4
25 0 8 15 6 23 23 24 7
26 4 22 19 13 21 19 20 12
27 2 20 19 19 27 21 24 7
28 2 17 20 14 23 25 23 8
29 -4 23 19 12 23 24 23 4
30 3 20 19 17 19 24 21 9
31 3 20 19 9 23 21 21 4
32 2 19 18 10 24 28 24 4
33 -1 22 17 11 27 18 23 4
34 -3 18 22 16 25 26 24 4
35 3 18 14 11 24 12 24 4
36 0 23 24 20 28 20 25 4
37 0 24 21 17 20 20 23 4
38 0 23 20 14 19 24 27 4
39 3 20 18 16 21 22 23 12
40 0 22 24 15 18 23 23 4
41 2 22 19 15 27 19 24 5
42 -1 15 16 10 25 24 26 15
43 3 19 16 18 21 16 23 10
44 2 21 15 10 27 19 20 5
45 2 20 15 16 23 18 18 9
46 -2 18 14 5 27 25 26 4
47 0 16 16 10 25 17 25 7
48 -2 17 13 8 19 17 23 5
49 0 24 26 16 24 24 18 4
50 6 19 18 16 23 22 26 4
51 -3 24 21 24 24 20 23 8
52 3 19 19 18 22 19 20 5
53 0 20 15 14 23 18 25 4
54 -2 19 21 9 26 20 26 4
55 1 21 17 21 26 21 24 6
56 0 15 18 7 16 21 22 10
57 2 22 25 16 25 25 28 4
58 2 14 12 8 20 21 24 11
59 -3 11 16 5 20 22 23 14
60 -2 16 11 10 19 12 17 11
61 1 22 23 22 24 24 23 4
62 -4 25 19 17 27 18 27 4
63 1 22 18 20 23 19 24 5
64 0 22 23 18 24 22 23 4
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) I1 I2 I3 E1 E2
3.008163 -0.045858 -0.005679 0.048702 -0.042152 0.063303
E3 A
-0.114411 0.008825
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4.3836 -1.3416 -0.0423 1.6701 5.7024
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.008163 3.393137 0.887 0.379
I1 -0.045858 0.130539 -0.351 0.727
I2 -0.005679 0.150675 -0.038 0.970
I3 0.048702 0.091381 0.533 0.596
E1 -0.042152 0.115508 -0.365 0.717
E2 0.063303 0.122055 0.519 0.606
E3 -0.114411 0.125135 -0.914 0.364
A 0.008825 0.114358 0.077 0.939
Residual standard error: 2.347 on 56 degrees of freedom
Multiple R-squared: 0.02999, Adjusted R-squared: -0.09127
F-statistic: 0.2473 on 7 and 56 DF, p-value: 0.971
> 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.0381760 0.0763520 0.9618240
[2,] 0.1653939 0.3307878 0.8346061
[3,] 0.1434619 0.2869237 0.8565381
[4,] 0.1141906 0.2283812 0.8858094
[5,] 0.3470297 0.6940594 0.6529703
[6,] 0.5752779 0.8494442 0.4247221
[7,] 0.5384969 0.9230062 0.4615031
[8,] 0.4976201 0.9952402 0.5023799
[9,] 0.5823437 0.8353126 0.4176563
[10,] 0.4951272 0.9902544 0.5048728
[11,] 0.4469380 0.8938760 0.5530620
[12,] 0.4011134 0.8022268 0.5988866
[13,] 0.4629606 0.9259211 0.5370394
[14,] 0.3968257 0.7936514 0.6031743
[15,] 0.3942090 0.7884180 0.6057910
[16,] 0.4649516 0.9299033 0.5350484
[17,] 0.4446545 0.8893091 0.5553455
[18,] 0.3687591 0.7375181 0.6312409
[19,] 0.5694148 0.8611704 0.4305852
[20,] 0.5307115 0.9385770 0.4692885
[21,] 0.5375604 0.9248792 0.4624396
[22,] 0.4811841 0.9623683 0.5188159
[23,] 0.4041649 0.8083299 0.5958351
[24,] 0.6026617 0.7946766 0.3973383
[25,] 0.6778967 0.6442067 0.3221033
[26,] 0.5997429 0.8005141 0.4002571
[27,] 0.5171441 0.9657119 0.4828559
[28,] 0.4325141 0.8650281 0.5674859
[29,] 0.4818787 0.9637574 0.5181213
[30,] 0.4044816 0.8089631 0.5955184
[31,] 0.4186055 0.8372110 0.5813945
[32,] 0.4012009 0.8024019 0.5987991
[33,] 0.5064834 0.9870332 0.4935166
[34,] 0.5901787 0.8196426 0.4098213
[35,] 0.7011622 0.5976756 0.2988378
[36,] 0.6768344 0.6463312 0.3231656
[37,] 0.6055243 0.7889514 0.3944757
[38,] 0.8380163 0.3239675 0.1619837
[39,] 0.8007090 0.3985820 0.1992910
[40,] 0.8587003 0.2825995 0.1412997
[41,] 0.7867174 0.4265652 0.2132826
[42,] 0.7250412 0.5499176 0.2749588
[43,] 0.6656448 0.6687103 0.3343552
> postscript(file="/var/wessaorg/rcomp/tmp/1jfxy1324169216.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/2p4b11324169216.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/3k2gp1324169216.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/483gi1324169216.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/5yc8k1324169216.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 = 64
Frequency = 1
1 2 3 4 5 6
1.45281952 -0.58821959 -0.64126610 3.29041864 -0.90335928 -1.34775844
7 8 9 10 11 12
-0.45954254 0.64721653 -1.37294906 2.00147860 -2.00485160 3.80578875
13 14 15 16 17 18
0.83849222 -0.71856573 -2.47519269 -4.17600644 2.10317031 1.36647317
19 20 21 22 23 24
-4.10646066 0.92268360 1.64930917 -0.57088632 -3.69966575 1.82237483
25 26 27 28 29 30
-0.65070462 3.34025591 1.58440548 1.15096048 -4.38356272 1.79379947
31 32 33 34 35 36
2.58605402 1.42807988 -0.84365047 -3.71851481 3.32365080 -0.05198700
37 38 39 40 41 42
-0.44310025 -0.18625371 2.25007942 -0.69459101 2.01518376 -1.33959943
43 44 45 46 47 48
2.49292746 1.73247553 1.02498060 -1.85179867 0.10556719 -2.23229316
49 50 51 52 53 54
-1.02266068 5.70235682 -3.65070112 2.06309968 -0.03261716 -1.68663363
55 56 57 58 59 60
0.48817590 -0.78511830 2.00290027 1.47485547 -3.69808833 -2.80981109
61 62 63 64
0.14843076 -3.52928449 0.59738803 -0.53015741
> postscript(file="/var/wessaorg/rcomp/tmp/69z2u1324169216.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 = 64
Frequency = 1
lag(myerror, k = 1) myerror
0 1.45281952 NA
1 -0.58821959 1.45281952
2 -0.64126610 -0.58821959
3 3.29041864 -0.64126610
4 -0.90335928 3.29041864
5 -1.34775844 -0.90335928
6 -0.45954254 -1.34775844
7 0.64721653 -0.45954254
8 -1.37294906 0.64721653
9 2.00147860 -1.37294906
10 -2.00485160 2.00147860
11 3.80578875 -2.00485160
12 0.83849222 3.80578875
13 -0.71856573 0.83849222
14 -2.47519269 -0.71856573
15 -4.17600644 -2.47519269
16 2.10317031 -4.17600644
17 1.36647317 2.10317031
18 -4.10646066 1.36647317
19 0.92268360 -4.10646066
20 1.64930917 0.92268360
21 -0.57088632 1.64930917
22 -3.69966575 -0.57088632
23 1.82237483 -3.69966575
24 -0.65070462 1.82237483
25 3.34025591 -0.65070462
26 1.58440548 3.34025591
27 1.15096048 1.58440548
28 -4.38356272 1.15096048
29 1.79379947 -4.38356272
30 2.58605402 1.79379947
31 1.42807988 2.58605402
32 -0.84365047 1.42807988
33 -3.71851481 -0.84365047
34 3.32365080 -3.71851481
35 -0.05198700 3.32365080
36 -0.44310025 -0.05198700
37 -0.18625371 -0.44310025
38 2.25007942 -0.18625371
39 -0.69459101 2.25007942
40 2.01518376 -0.69459101
41 -1.33959943 2.01518376
42 2.49292746 -1.33959943
43 1.73247553 2.49292746
44 1.02498060 1.73247553
45 -1.85179867 1.02498060
46 0.10556719 -1.85179867
47 -2.23229316 0.10556719
48 -1.02266068 -2.23229316
49 5.70235682 -1.02266068
50 -3.65070112 5.70235682
51 2.06309968 -3.65070112
52 -0.03261716 2.06309968
53 -1.68663363 -0.03261716
54 0.48817590 -1.68663363
55 -0.78511830 0.48817590
56 2.00290027 -0.78511830
57 1.47485547 2.00290027
58 -3.69808833 1.47485547
59 -2.80981109 -3.69808833
60 0.14843076 -2.80981109
61 -3.52928449 0.14843076
62 0.59738803 -3.52928449
63 -0.53015741 0.59738803
64 NA -0.53015741
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.58821959 1.45281952
[2,] -0.64126610 -0.58821959
[3,] 3.29041864 -0.64126610
[4,] -0.90335928 3.29041864
[5,] -1.34775844 -0.90335928
[6,] -0.45954254 -1.34775844
[7,] 0.64721653 -0.45954254
[8,] -1.37294906 0.64721653
[9,] 2.00147860 -1.37294906
[10,] -2.00485160 2.00147860
[11,] 3.80578875 -2.00485160
[12,] 0.83849222 3.80578875
[13,] -0.71856573 0.83849222
[14,] -2.47519269 -0.71856573
[15,] -4.17600644 -2.47519269
[16,] 2.10317031 -4.17600644
[17,] 1.36647317 2.10317031
[18,] -4.10646066 1.36647317
[19,] 0.92268360 -4.10646066
[20,] 1.64930917 0.92268360
[21,] -0.57088632 1.64930917
[22,] -3.69966575 -0.57088632
[23,] 1.82237483 -3.69966575
[24,] -0.65070462 1.82237483
[25,] 3.34025591 -0.65070462
[26,] 1.58440548 3.34025591
[27,] 1.15096048 1.58440548
[28,] -4.38356272 1.15096048
[29,] 1.79379947 -4.38356272
[30,] 2.58605402 1.79379947
[31,] 1.42807988 2.58605402
[32,] -0.84365047 1.42807988
[33,] -3.71851481 -0.84365047
[34,] 3.32365080 -3.71851481
[35,] -0.05198700 3.32365080
[36,] -0.44310025 -0.05198700
[37,] -0.18625371 -0.44310025
[38,] 2.25007942 -0.18625371
[39,] -0.69459101 2.25007942
[40,] 2.01518376 -0.69459101
[41,] -1.33959943 2.01518376
[42,] 2.49292746 -1.33959943
[43,] 1.73247553 2.49292746
[44,] 1.02498060 1.73247553
[45,] -1.85179867 1.02498060
[46,] 0.10556719 -1.85179867
[47,] -2.23229316 0.10556719
[48,] -1.02266068 -2.23229316
[49,] 5.70235682 -1.02266068
[50,] -3.65070112 5.70235682
[51,] 2.06309968 -3.65070112
[52,] -0.03261716 2.06309968
[53,] -1.68663363 -0.03261716
[54,] 0.48817590 -1.68663363
[55,] -0.78511830 0.48817590
[56,] 2.00290027 -0.78511830
[57,] 1.47485547 2.00290027
[58,] -3.69808833 1.47485547
[59,] -2.80981109 -3.69808833
[60,] 0.14843076 -2.80981109
[61,] -3.52928449 0.14843076
[62,] 0.59738803 -3.52928449
[63,] -0.53015741 0.59738803
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.58821959 1.45281952
2 -0.64126610 -0.58821959
3 3.29041864 -0.64126610
4 -0.90335928 3.29041864
5 -1.34775844 -0.90335928
6 -0.45954254 -1.34775844
7 0.64721653 -0.45954254
8 -1.37294906 0.64721653
9 2.00147860 -1.37294906
10 -2.00485160 2.00147860
11 3.80578875 -2.00485160
12 0.83849222 3.80578875
13 -0.71856573 0.83849222
14 -2.47519269 -0.71856573
15 -4.17600644 -2.47519269
16 2.10317031 -4.17600644
17 1.36647317 2.10317031
18 -4.10646066 1.36647317
19 0.92268360 -4.10646066
20 1.64930917 0.92268360
21 -0.57088632 1.64930917
22 -3.69966575 -0.57088632
23 1.82237483 -3.69966575
24 -0.65070462 1.82237483
25 3.34025591 -0.65070462
26 1.58440548 3.34025591
27 1.15096048 1.58440548
28 -4.38356272 1.15096048
29 1.79379947 -4.38356272
30 2.58605402 1.79379947
31 1.42807988 2.58605402
32 -0.84365047 1.42807988
33 -3.71851481 -0.84365047
34 3.32365080 -3.71851481
35 -0.05198700 3.32365080
36 -0.44310025 -0.05198700
37 -0.18625371 -0.44310025
38 2.25007942 -0.18625371
39 -0.69459101 2.25007942
40 2.01518376 -0.69459101
41 -1.33959943 2.01518376
42 2.49292746 -1.33959943
43 1.73247553 2.49292746
44 1.02498060 1.73247553
45 -1.85179867 1.02498060
46 0.10556719 -1.85179867
47 -2.23229316 0.10556719
48 -1.02266068 -2.23229316
49 5.70235682 -1.02266068
50 -3.65070112 5.70235682
51 2.06309968 -3.65070112
52 -0.03261716 2.06309968
53 -1.68663363 -0.03261716
54 0.48817590 -1.68663363
55 -0.78511830 0.48817590
56 2.00290027 -0.78511830
57 1.47485547 2.00290027
58 -3.69808833 1.47485547
59 -2.80981109 -3.69808833
60 0.14843076 -2.80981109
61 -3.52928449 0.14843076
62 0.59738803 -3.52928449
63 -0.53015741 0.59738803
> 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/7kwtf1324169216.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/8lie41324169216.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/9yb3n1324169216.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/10ffp01324169217.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/11h6pq1324169217.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/12a5881324169217.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/13hgsr1324169217.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/14fvm01324169217.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/15rfgc1324169217.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/16yuhw1324169217.tab")
+ }
>
> try(system("convert tmp/1jfxy1324169216.ps tmp/1jfxy1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/2p4b11324169216.ps tmp/2p4b11324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/3k2gp1324169216.ps tmp/3k2gp1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/483gi1324169216.ps tmp/483gi1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/5yc8k1324169216.ps tmp/5yc8k1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/69z2u1324169216.ps tmp/69z2u1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/7kwtf1324169216.ps tmp/7kwtf1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/8lie41324169216.ps tmp/8lie41324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/9yb3n1324169216.ps tmp/9yb3n1324169216.png",intern=TRUE))
character(0)
> try(system("convert tmp/10ffp01324169217.ps tmp/10ffp01324169217.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.251 0.584 3.873