R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(98.5,0,97.0,0,103.3,0,99.6,0,100.1,0,102.9,0,95.9,0,94.5,0,107.4,0,116.0,0,102.8,0,99.8,0,109.6,0,103.0,0,111.6,0,106.3,0,97.9,0,108.8,0,103.9,0,101.2,0,122.9,0,123.9,0,111.7,0,120.9,0,99.6,0,103.3,0,119.4,0,106.5,0,101.9,0,124.6,0,106.5,0,107.8,0,127.4,0,120.1,0,118.5,0,127.7,0,107.7,0,104.5,0,118.8,0,110.3,0,109.6,0,119.1,0,96.5,0,106.7,0,126.3,0,116.2,0,118.8,0,115.2,0,110.0,0,111.4,0,129.6,0,108.1,0,117.8,0,122.9,0,100.6,0,111.8,0,127.0,0,128.6,0,124.8,0,118.5,0,114.7,0,112.6,0,128.7,0,111.0,0,115.8,0,126.0,0,111.1,1,113.2,1,120.1,1,130.6,1,124.0,1,119.4,1,116.7,1,116.5,1,119.6,1,126.5,1,111.3,1,123.5,1,114.2,1,103.7,1,129.5,1),dim=c(2,81),dimnames=list(c('Y','X'),1:81))
> y <- array(NA,dim=c(2,81),dimnames=list(c('Y','X'),1:81))
> 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 = 'Do not include Seasonal 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 t
1 98.5 0 1
2 97.0 0 2
3 103.3 0 3
4 99.6 0 4
5 100.1 0 5
6 102.9 0 6
7 95.9 0 7
8 94.5 0 8
9 107.4 0 9
10 116.0 0 10
11 102.8 0 11
12 99.8 0 12
13 109.6 0 13
14 103.0 0 14
15 111.6 0 15
16 106.3 0 16
17 97.9 0 17
18 108.8 0 18
19 103.9 0 19
20 101.2 0 20
21 122.9 0 21
22 123.9 0 22
23 111.7 0 23
24 120.9 0 24
25 99.6 0 25
26 103.3 0 26
27 119.4 0 27
28 106.5 0 28
29 101.9 0 29
30 124.6 0 30
31 106.5 0 31
32 107.8 0 32
33 127.4 0 33
34 120.1 0 34
35 118.5 0 35
36 127.7 0 36
37 107.7 0 37
38 104.5 0 38
39 118.8 0 39
40 110.3 0 40
41 109.6 0 41
42 119.1 0 42
43 96.5 0 43
44 106.7 0 44
45 126.3 0 45
46 116.2 0 46
47 118.8 0 47
48 115.2 0 48
49 110.0 0 49
50 111.4 0 50
51 129.6 0 51
52 108.1 0 52
53 117.8 0 53
54 122.9 0 54
55 100.6 0 55
56 111.8 0 56
57 127.0 0 57
58 128.6 0 58
59 124.8 0 59
60 118.5 0 60
61 114.7 0 61
62 112.6 0 62
63 128.7 0 63
64 111.0 0 64
65 115.8 0 65
66 126.0 0 66
67 111.1 1 67
68 113.2 1 68
69 120.1 1 69
70 130.6 1 70
71 124.0 1 71
72 119.4 1 72
73 116.7 1 73
74 116.5 1 74
75 119.6 1 75
76 126.5 1 76
77 111.3 1 77
78 123.5 1 78
79 114.2 1 79
80 103.7 1 80
81 129.5 1 81
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X t
101.9318 -4.8560 0.2917
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-17.9740 -5.5183 -0.9325 5.4927 15.8428
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 101.93180 1.98663 51.309 < 2e-16 ***
X -4.85601 3.09841 -1.567 0.121
t 0.29168 0.05148 5.666 2.35e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 8.013 on 78 degrees of freedom
Multiple R-squared: 0.3463, Adjusted R-squared: 0.3295
F-statistic: 20.66 on 2 and 78 DF, p-value: 6.311e-08
> 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.03753730 0.07507461 0.9624627
[2,] 0.04738029 0.09476059 0.9526197
[3,] 0.03317251 0.06634503 0.9668275
[4,] 0.07227030 0.14454059 0.9277297
[5,] 0.22102124 0.44204247 0.7789788
[6,] 0.16182583 0.32365167 0.8381742
[7,] 0.14298166 0.28596331 0.8570183
[8,] 0.10123156 0.20246311 0.8987684
[9,] 0.07226865 0.14453729 0.9277314
[10,] 0.05230301 0.10460601 0.9476970
[11,] 0.03242905 0.06485811 0.9675709
[12,] 0.05623540 0.11247079 0.9437646
[13,] 0.03563541 0.07127083 0.9643646
[14,] 0.02555207 0.05110414 0.9744479
[15,] 0.02413312 0.04826624 0.9758669
[16,] 0.09154742 0.18309485 0.9084526
[17,] 0.16748710 0.33497420 0.8325129
[18,] 0.12409177 0.24818354 0.8759082
[19,] 0.12401925 0.24803850 0.8759807
[20,] 0.23784931 0.47569862 0.7621507
[21,] 0.26413722 0.52827443 0.7358628
[22,] 0.24474470 0.48948941 0.7552553
[23,] 0.23199071 0.46398143 0.7680093
[24,] 0.28941628 0.57883256 0.7105837
[25,] 0.34838458 0.69676916 0.6516154
[26,] 0.33998499 0.67996999 0.6600150
[27,] 0.31492051 0.62984101 0.6850795
[28,] 0.41732938 0.83465876 0.5826706
[29,] 0.38110515 0.76221030 0.6188949
[30,] 0.33361983 0.66723965 0.6663802
[31,] 0.43418225 0.86836450 0.5658178
[32,] 0.44564772 0.89129543 0.5543523
[33,] 0.50649052 0.98701896 0.4935095
[34,] 0.46171787 0.92343573 0.5382821
[35,] 0.42896677 0.85793354 0.5710332
[36,] 0.40225811 0.80451622 0.5977419
[37,] 0.35777289 0.71554577 0.6422271
[38,] 0.64952363 0.70095273 0.3504764
[39,] 0.67171547 0.65656906 0.3282845
[40,] 0.69941518 0.60116964 0.3005848
[41,] 0.63942537 0.72114926 0.3605746
[42,] 0.58141263 0.83717474 0.4185874
[43,] 0.51790998 0.96418004 0.4820900
[44,] 0.49983641 0.99967281 0.5001636
[45,] 0.47065705 0.94131409 0.5293430
[46,] 0.55056336 0.89887328 0.4494366
[47,] 0.57452012 0.85095977 0.4254799
[48,] 0.50528488 0.98943024 0.4947151
[49,] 0.45972326 0.91944652 0.5402767
[50,] 0.73315207 0.53369586 0.2668479
[51,] 0.74426503 0.51146995 0.2557350
[52,] 0.72423846 0.55152308 0.2757615
[53,] 0.73870039 0.52259922 0.2612996
[54,] 0.71020402 0.57959195 0.2897960
[55,] 0.64114766 0.71770468 0.3588523
[56,] 0.58609086 0.82781827 0.4139091
[57,] 0.56853610 0.86292780 0.4314639
[58,] 0.59469478 0.81061044 0.4053052
[59,] 0.60263631 0.79472739 0.3973637
[60,] 0.58002750 0.83994500 0.4199725
[61,] 0.49519008 0.99038016 0.5048099
[62,] 0.49536523 0.99073046 0.5046348
[63,] 0.50368247 0.99263505 0.4963175
[64,] 0.42707100 0.85414201 0.5729290
[65,] 0.44707709 0.89415418 0.5529229
[66,] 0.36833676 0.73667351 0.6316632
[67,] 0.26533696 0.53067392 0.7346630
[68,] 0.17745445 0.35490891 0.8225455
[69,] 0.10938602 0.21877205 0.8906140
[70,] 0.05490915 0.10981830 0.9450908
> postscript(file="/var/www/html/rcomp/tmp/11opx1229431548.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/2462v1229431548.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/3aq3g1229431548.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/45l9w1229431548.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/5vlrv1229431548.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 = 81
Frequency = 1
1 2 3 4 5 6
-3.7234780 -5.5151566 0.4931649 -3.4985136 -3.2901922 -0.7818707
7 8 9 10 11 12
-8.0735492 -9.7652278 2.8430937 11.1514152 -2.3402634 -5.6319419
13 14 15 16 17 18
3.8763796 -3.0152990 5.2930225 -0.2986560 -8.9903345 1.6179869
19 20 21 22 23 24
-3.5736916 -6.5653701 14.8429513 15.5512728 3.0595943 11.9679157
25 26 27 28 29 30
-9.6237628 -6.2154413 9.5928801 -3.5987984 -8.4904769 13.9178446
31 32 33 34 35 36
-4.4738340 -3.4655125 15.8428090 8.2511304 6.3594519 15.2677734
37 38 39 40 41 42
-5.0239052 -8.5155837 5.4927378 -3.2989408 -4.2906193 4.9177022
43 44 45 46 47 48
-17.9739763 -8.0656549 11.2426666 0.8509881 3.1593095 -0.7323690
49 50 51 52 53 54
-6.2240475 -5.1157261 12.7925954 -8.9990831 0.4092383 5.2175598
55 56 57 58 59 60
-17.3741187 -6.4657972 8.4425242 9.7508457 5.6591672 -0.9325114
61 62 63 64 65 66
-5.0241899 -7.4158684 8.3924530 -9.5992255 -5.0909040 4.8174174
67 68 69 70 71 72
-5.5182503 -3.7099288 2.8983927 13.1067141 6.2150356 1.3233571
73 74 75 76 77 78
-1.6683215 -2.1600000 0.6483215 7.2566429 -8.2350356 3.6732859
79 80 81
-5.9183927 -16.7100712 8.7982503
> postscript(file="/var/www/html/rcomp/tmp/67s041229431548.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 = 81
Frequency = 1
lag(myerror, k = 1) myerror
0 -3.7234780 NA
1 -5.5151566 -3.7234780
2 0.4931649 -5.5151566
3 -3.4985136 0.4931649
4 -3.2901922 -3.4985136
5 -0.7818707 -3.2901922
6 -8.0735492 -0.7818707
7 -9.7652278 -8.0735492
8 2.8430937 -9.7652278
9 11.1514152 2.8430937
10 -2.3402634 11.1514152
11 -5.6319419 -2.3402634
12 3.8763796 -5.6319419
13 -3.0152990 3.8763796
14 5.2930225 -3.0152990
15 -0.2986560 5.2930225
16 -8.9903345 -0.2986560
17 1.6179869 -8.9903345
18 -3.5736916 1.6179869
19 -6.5653701 -3.5736916
20 14.8429513 -6.5653701
21 15.5512728 14.8429513
22 3.0595943 15.5512728
23 11.9679157 3.0595943
24 -9.6237628 11.9679157
25 -6.2154413 -9.6237628
26 9.5928801 -6.2154413
27 -3.5987984 9.5928801
28 -8.4904769 -3.5987984
29 13.9178446 -8.4904769
30 -4.4738340 13.9178446
31 -3.4655125 -4.4738340
32 15.8428090 -3.4655125
33 8.2511304 15.8428090
34 6.3594519 8.2511304
35 15.2677734 6.3594519
36 -5.0239052 15.2677734
37 -8.5155837 -5.0239052
38 5.4927378 -8.5155837
39 -3.2989408 5.4927378
40 -4.2906193 -3.2989408
41 4.9177022 -4.2906193
42 -17.9739763 4.9177022
43 -8.0656549 -17.9739763
44 11.2426666 -8.0656549
45 0.8509881 11.2426666
46 3.1593095 0.8509881
47 -0.7323690 3.1593095
48 -6.2240475 -0.7323690
49 -5.1157261 -6.2240475
50 12.7925954 -5.1157261
51 -8.9990831 12.7925954
52 0.4092383 -8.9990831
53 5.2175598 0.4092383
54 -17.3741187 5.2175598
55 -6.4657972 -17.3741187
56 8.4425242 -6.4657972
57 9.7508457 8.4425242
58 5.6591672 9.7508457
59 -0.9325114 5.6591672
60 -5.0241899 -0.9325114
61 -7.4158684 -5.0241899
62 8.3924530 -7.4158684
63 -9.5992255 8.3924530
64 -5.0909040 -9.5992255
65 4.8174174 -5.0909040
66 -5.5182503 4.8174174
67 -3.7099288 -5.5182503
68 2.8983927 -3.7099288
69 13.1067141 2.8983927
70 6.2150356 13.1067141
71 1.3233571 6.2150356
72 -1.6683215 1.3233571
73 -2.1600000 -1.6683215
74 0.6483215 -2.1600000
75 7.2566429 0.6483215
76 -8.2350356 7.2566429
77 3.6732859 -8.2350356
78 -5.9183927 3.6732859
79 -16.7100712 -5.9183927
80 8.7982503 -16.7100712
81 NA 8.7982503
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -5.5151566 -3.7234780
[2,] 0.4931649 -5.5151566
[3,] -3.4985136 0.4931649
[4,] -3.2901922 -3.4985136
[5,] -0.7818707 -3.2901922
[6,] -8.0735492 -0.7818707
[7,] -9.7652278 -8.0735492
[8,] 2.8430937 -9.7652278
[9,] 11.1514152 2.8430937
[10,] -2.3402634 11.1514152
[11,] -5.6319419 -2.3402634
[12,] 3.8763796 -5.6319419
[13,] -3.0152990 3.8763796
[14,] 5.2930225 -3.0152990
[15,] -0.2986560 5.2930225
[16,] -8.9903345 -0.2986560
[17,] 1.6179869 -8.9903345
[18,] -3.5736916 1.6179869
[19,] -6.5653701 -3.5736916
[20,] 14.8429513 -6.5653701
[21,] 15.5512728 14.8429513
[22,] 3.0595943 15.5512728
[23,] 11.9679157 3.0595943
[24,] -9.6237628 11.9679157
[25,] -6.2154413 -9.6237628
[26,] 9.5928801 -6.2154413
[27,] -3.5987984 9.5928801
[28,] -8.4904769 -3.5987984
[29,] 13.9178446 -8.4904769
[30,] -4.4738340 13.9178446
[31,] -3.4655125 -4.4738340
[32,] 15.8428090 -3.4655125
[33,] 8.2511304 15.8428090
[34,] 6.3594519 8.2511304
[35,] 15.2677734 6.3594519
[36,] -5.0239052 15.2677734
[37,] -8.5155837 -5.0239052
[38,] 5.4927378 -8.5155837
[39,] -3.2989408 5.4927378
[40,] -4.2906193 -3.2989408
[41,] 4.9177022 -4.2906193
[42,] -17.9739763 4.9177022
[43,] -8.0656549 -17.9739763
[44,] 11.2426666 -8.0656549
[45,] 0.8509881 11.2426666
[46,] 3.1593095 0.8509881
[47,] -0.7323690 3.1593095
[48,] -6.2240475 -0.7323690
[49,] -5.1157261 -6.2240475
[50,] 12.7925954 -5.1157261
[51,] -8.9990831 12.7925954
[52,] 0.4092383 -8.9990831
[53,] 5.2175598 0.4092383
[54,] -17.3741187 5.2175598
[55,] -6.4657972 -17.3741187
[56,] 8.4425242 -6.4657972
[57,] 9.7508457 8.4425242
[58,] 5.6591672 9.7508457
[59,] -0.9325114 5.6591672
[60,] -5.0241899 -0.9325114
[61,] -7.4158684 -5.0241899
[62,] 8.3924530 -7.4158684
[63,] -9.5992255 8.3924530
[64,] -5.0909040 -9.5992255
[65,] 4.8174174 -5.0909040
[66,] -5.5182503 4.8174174
[67,] -3.7099288 -5.5182503
[68,] 2.8983927 -3.7099288
[69,] 13.1067141 2.8983927
[70,] 6.2150356 13.1067141
[71,] 1.3233571 6.2150356
[72,] -1.6683215 1.3233571
[73,] -2.1600000 -1.6683215
[74,] 0.6483215 -2.1600000
[75,] 7.2566429 0.6483215
[76,] -8.2350356 7.2566429
[77,] 3.6732859 -8.2350356
[78,] -5.9183927 3.6732859
[79,] -16.7100712 -5.9183927
[80,] 8.7982503 -16.7100712
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -5.5151566 -3.7234780
2 0.4931649 -5.5151566
3 -3.4985136 0.4931649
4 -3.2901922 -3.4985136
5 -0.7818707 -3.2901922
6 -8.0735492 -0.7818707
7 -9.7652278 -8.0735492
8 2.8430937 -9.7652278
9 11.1514152 2.8430937
10 -2.3402634 11.1514152
11 -5.6319419 -2.3402634
12 3.8763796 -5.6319419
13 -3.0152990 3.8763796
14 5.2930225 -3.0152990
15 -0.2986560 5.2930225
16 -8.9903345 -0.2986560
17 1.6179869 -8.9903345
18 -3.5736916 1.6179869
19 -6.5653701 -3.5736916
20 14.8429513 -6.5653701
21 15.5512728 14.8429513
22 3.0595943 15.5512728
23 11.9679157 3.0595943
24 -9.6237628 11.9679157
25 -6.2154413 -9.6237628
26 9.5928801 -6.2154413
27 -3.5987984 9.5928801
28 -8.4904769 -3.5987984
29 13.9178446 -8.4904769
30 -4.4738340 13.9178446
31 -3.4655125 -4.4738340
32 15.8428090 -3.4655125
33 8.2511304 15.8428090
34 6.3594519 8.2511304
35 15.2677734 6.3594519
36 -5.0239052 15.2677734
37 -8.5155837 -5.0239052
38 5.4927378 -8.5155837
39 -3.2989408 5.4927378
40 -4.2906193 -3.2989408
41 4.9177022 -4.2906193
42 -17.9739763 4.9177022
43 -8.0656549 -17.9739763
44 11.2426666 -8.0656549
45 0.8509881 11.2426666
46 3.1593095 0.8509881
47 -0.7323690 3.1593095
48 -6.2240475 -0.7323690
49 -5.1157261 -6.2240475
50 12.7925954 -5.1157261
51 -8.9990831 12.7925954
52 0.4092383 -8.9990831
53 5.2175598 0.4092383
54 -17.3741187 5.2175598
55 -6.4657972 -17.3741187
56 8.4425242 -6.4657972
57 9.7508457 8.4425242
58 5.6591672 9.7508457
59 -0.9325114 5.6591672
60 -5.0241899 -0.9325114
61 -7.4158684 -5.0241899
62 8.3924530 -7.4158684
63 -9.5992255 8.3924530
64 -5.0909040 -9.5992255
65 4.8174174 -5.0909040
66 -5.5182503 4.8174174
67 -3.7099288 -5.5182503
68 2.8983927 -3.7099288
69 13.1067141 2.8983927
70 6.2150356 13.1067141
71 1.3233571 6.2150356
72 -1.6683215 1.3233571
73 -2.1600000 -1.6683215
74 0.6483215 -2.1600000
75 7.2566429 0.6483215
76 -8.2350356 7.2566429
77 3.6732859 -8.2350356
78 -5.9183927 3.6732859
79 -16.7100712 -5.9183927
80 8.7982503 -16.7100712
> 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/712lf1229431548.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/8f1ca1229431548.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/9qlh01229431548.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/104pa11229431548.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/11hsoa1229431549.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/12ealw1229431549.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/134daj1229431549.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/1414bi1229431549.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/15wtfj1229431549.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/168ukt1229431549.tab")
+ }
>
> system("convert tmp/11opx1229431548.ps tmp/11opx1229431548.png")
> system("convert tmp/2462v1229431548.ps tmp/2462v1229431548.png")
> system("convert tmp/3aq3g1229431548.ps tmp/3aq3g1229431548.png")
> system("convert tmp/45l9w1229431548.ps tmp/45l9w1229431548.png")
> system("convert tmp/5vlrv1229431548.ps tmp/5vlrv1229431548.png")
> system("convert tmp/67s041229431548.ps tmp/67s041229431548.png")
> system("convert tmp/712lf1229431548.ps tmp/712lf1229431548.png")
> system("convert tmp/8f1ca1229431548.ps tmp/8f1ca1229431548.png")
> system("convert tmp/9qlh01229431548.ps tmp/9qlh01229431548.png")
> system("convert tmp/104pa11229431548.ps tmp/104pa11229431548.png")
>
>
> proc.time()
user system elapsed
2.674 1.558 3.191