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(100.5
+ ,98.60
+ ,96.33
+ ,106.29
+ ,96.90
+ ,96.33
+ ,101.09
+ ,95.10
+ ,95.05
+ ,104.53
+ ,97.00
+ ,96.84
+ ,122.74
+ ,112.70
+ ,96.92
+ ,109.84
+ ,102.90
+ ,97.44
+ ,101.99
+ ,97.40
+ ,97.78
+ ,125.12
+ ,111.40
+ ,97.69
+ ,103.5
+ ,87.40
+ ,96.67
+ ,102.8
+ ,96.80
+ ,98.29
+ ,118.72
+ ,114.10
+ ,98.20
+ ,119.01
+ ,110.30
+ ,98.71
+ ,118.61
+ ,103.90
+ ,98.54
+ ,120.43
+ ,101.60
+ ,98.20
+ ,111.83
+ ,94.60
+ ,100.80
+ ,116.79
+ ,95.90
+ ,101.33
+ ,131.71
+ ,104.70
+ ,101.88
+ ,120.57
+ ,102.80
+ ,101.85
+ ,117.83
+ ,98.10
+ ,102.04
+ ,130.8
+ ,113.90
+ ,102.22
+ ,107.46
+ ,80.90
+ ,102.63
+ ,112.09
+ ,95.70
+ ,102.65
+ ,129.47
+ ,113.20
+ ,102.54
+ ,119.72
+ ,105.90
+ ,102.37
+ ,134.81
+ ,108.80
+ ,102.68
+ ,135.8
+ ,102.30
+ ,102.76
+ ,129.27
+ ,99.00
+ ,102.82
+ ,126.94
+ ,100.70
+ ,103.31
+ ,153.45
+ ,115.50
+ ,103.23
+ ,121.86
+ ,100.70
+ ,103.60
+ ,133.47
+ ,109.90
+ ,103.95
+ ,135.34
+ ,114.60
+ ,103.93
+ ,117.1
+ ,85.40
+ ,104.25
+ ,120.65
+ ,100.50
+ ,104.38
+ ,132.49
+ ,114.80
+ ,104.36
+ ,137.6
+ ,116.50
+ ,104.32
+ ,138.69
+ ,112.90
+ ,104.58
+ ,125.53
+ ,102.00
+ ,104.68
+ ,133.09
+ ,106.00
+ ,104.92
+ ,129.08
+ ,105.30
+ ,105.46
+ ,145.94
+ ,118.80
+ ,105.23
+ ,129.07
+ ,106.10
+ ,105.58
+ ,139.69
+ ,109.30
+ ,105.34
+ ,142.09
+ ,117.20
+ ,105.28
+ ,137.29
+ ,92.50
+ ,105.70
+ ,127.03
+ ,104.20
+ ,105.67
+ ,137.25
+ ,112.50
+ ,105.71
+ ,156.87
+ ,122.40
+ ,106.19
+ ,150.89
+ ,113.30
+ ,106.93
+ ,139.14
+ ,100.00
+ ,107.44
+ ,158.3
+ ,110.70
+ ,107.85
+ ,149
+ ,112.80
+ ,108.71
+ ,158.36
+ ,109.80
+ ,109.32
+ ,168.06
+ ,117.30
+ ,109.49
+ ,153.38
+ ,109.10
+ ,110.20
+ ,173.86
+ ,115.90
+ ,110.62
+ ,162.47
+ ,96.00
+ ,111.22
+ ,145.17
+ ,99.80
+ ,110.88
+ ,168.89
+ ,116.80
+ ,111.15
+ ,166.64
+ ,115.70
+ ,111.29
+ ,140.07
+ ,99.40
+ ,111.09
+ ,128.84
+ ,94.30
+ ,111.24
+ ,123.41
+ ,91.00
+ ,111.45
+ ,120.3
+ ,93.20
+ ,111.75
+ ,129.67
+ ,103.10
+ ,111.07
+ ,118.1
+ ,94.10
+ ,111.17
+ ,113.91
+ ,91.80
+ ,110.96
+ ,131.09
+ ,102.70
+ ,110.50
+ ,119.15
+ ,82.60
+ ,110.48
+ ,122.3
+ ,89.10
+ ,110.66)
+ ,dim=c(3
+ ,70)
+ ,dimnames=list(c('Invoer'
+ ,'TIP'
+ ,'CONS')
+ ,1:70))
> y <- array(NA,dim=c(3,70),dimnames=list(c('Invoer','TIP','CONS'),1:70))
> 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
Invoer TIP CONS M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 100.50 98.6 96.33 1 0 0 0 0 0 0 0 0 0 0
2 106.29 96.9 96.33 0 1 0 0 0 0 0 0 0 0 0
3 101.09 95.1 95.05 0 0 1 0 0 0 0 0 0 0 0
4 104.53 97.0 96.84 0 0 0 1 0 0 0 0 0 0 0
5 122.74 112.7 96.92 0 0 0 0 1 0 0 0 0 0 0
6 109.84 102.9 97.44 0 0 0 0 0 1 0 0 0 0 0
7 101.99 97.4 97.78 0 0 0 0 0 0 1 0 0 0 0
8 125.12 111.4 97.69 0 0 0 0 0 0 0 1 0 0 0
9 103.50 87.4 96.67 0 0 0 0 0 0 0 0 1 0 0
10 102.80 96.8 98.29 0 0 0 0 0 0 0 0 0 1 0
11 118.72 114.1 98.20 0 0 0 0 0 0 0 0 0 0 1
12 119.01 110.3 98.71 0 0 0 0 0 0 0 0 0 0 0
13 118.61 103.9 98.54 1 0 0 0 0 0 0 0 0 0 0
14 120.43 101.6 98.20 0 1 0 0 0 0 0 0 0 0 0
15 111.83 94.6 100.80 0 0 1 0 0 0 0 0 0 0 0
16 116.79 95.9 101.33 0 0 0 1 0 0 0 0 0 0 0
17 131.71 104.7 101.88 0 0 0 0 1 0 0 0 0 0 0
18 120.57 102.8 101.85 0 0 0 0 0 1 0 0 0 0 0
19 117.83 98.1 102.04 0 0 0 0 0 0 1 0 0 0 0
20 130.80 113.9 102.22 0 0 0 0 0 0 0 1 0 0 0
21 107.46 80.9 102.63 0 0 0 0 0 0 0 0 1 0 0
22 112.09 95.7 102.65 0 0 0 0 0 0 0 0 0 1 0
23 129.47 113.2 102.54 0 0 0 0 0 0 0 0 0 0 1
24 119.72 105.9 102.37 0 0 0 0 0 0 0 0 0 0 0
25 134.81 108.8 102.68 1 0 0 0 0 0 0 0 0 0 0
26 135.80 102.3 102.76 0 1 0 0 0 0 0 0 0 0 0
27 129.27 99.0 102.82 0 0 1 0 0 0 0 0 0 0 0
28 126.94 100.7 103.31 0 0 0 1 0 0 0 0 0 0 0
29 153.45 115.5 103.23 0 0 0 0 1 0 0 0 0 0 0
30 121.86 100.7 103.60 0 0 0 0 0 1 0 0 0 0 0
31 133.47 109.9 103.95 0 0 0 0 0 0 1 0 0 0 0
32 135.34 114.6 103.93 0 0 0 0 0 0 0 1 0 0 0
33 117.10 85.4 104.25 0 0 0 0 0 0 0 0 1 0 0
34 120.65 100.5 104.38 0 0 0 0 0 0 0 0 0 1 0
35 132.49 114.8 104.36 0 0 0 0 0 0 0 0 0 0 1
36 137.60 116.5 104.32 0 0 0 0 0 0 0 0 0 0 0
37 138.69 112.9 104.58 1 0 0 0 0 0 0 0 0 0 0
38 125.53 102.0 104.68 0 1 0 0 0 0 0 0 0 0 0
39 133.09 106.0 104.92 0 0 1 0 0 0 0 0 0 0 0
40 129.08 105.3 105.46 0 0 0 1 0 0 0 0 0 0 0
41 145.94 118.8 105.23 0 0 0 0 1 0 0 0 0 0 0
42 129.07 106.1 105.58 0 0 0 0 0 1 0 0 0 0 0
43 139.69 109.3 105.34 0 0 0 0 0 0 1 0 0 0 0
44 142.09 117.2 105.28 0 0 0 0 0 0 0 1 0 0 0
45 137.29 92.5 105.70 0 0 0 0 0 0 0 0 1 0 0
46 127.03 104.2 105.67 0 0 0 0 0 0 0 0 0 1 0
47 137.25 112.5 105.71 0 0 0 0 0 0 0 0 0 0 1
48 156.87 122.4 106.19 0 0 0 0 0 0 0 0 0 0 0
49 150.89 113.3 106.93 1 0 0 0 0 0 0 0 0 0 0
50 139.14 100.0 107.44 0 1 0 0 0 0 0 0 0 0 0
51 158.30 110.7 107.85 0 0 1 0 0 0 0 0 0 0 0
52 149.00 112.8 108.71 0 0 0 1 0 0 0 0 0 0 0
53 158.36 109.8 109.32 0 0 0 0 1 0 0 0 0 0 0
54 168.06 117.3 109.49 0 0 0 0 0 1 0 0 0 0 0
55 153.38 109.1 110.20 0 0 0 0 0 0 1 0 0 0 0
56 173.86 115.9 110.62 0 0 0 0 0 0 0 1 0 0 0
57 162.47 96.0 111.22 0 0 0 0 0 0 0 0 1 0 0
58 145.17 99.8 110.88 0 0 0 0 0 0 0 0 0 1 0
59 168.89 116.8 111.15 0 0 0 0 0 0 0 0 0 0 1
60 166.64 115.7 111.29 0 0 0 0 0 0 0 0 0 0 0
61 140.07 99.4 111.09 1 0 0 0 0 0 0 0 0 0 0
62 128.84 94.3 111.24 0 1 0 0 0 0 0 0 0 0 0
63 123.41 91.0 111.45 0 0 1 0 0 0 0 0 0 0 0
64 120.30 93.2 111.75 0 0 0 1 0 0 0 0 0 0 0
65 129.67 103.1 111.07 0 0 0 0 1 0 0 0 0 0 0
66 118.10 94.1 111.17 0 0 0 0 0 1 0 0 0 0 0
67 113.91 91.8 110.96 0 0 0 0 0 0 1 0 0 0 0
68 131.09 102.7 110.50 0 0 0 0 0 0 0 1 0 0 0
69 119.15 82.6 110.48 0 0 0 0 0 0 0 0 1 0 0
70 122.30 89.1 110.66 0 0 0 0 0 0 0 0 0 1 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) TIP CONS M1 M2 M3
-302.163 1.840 2.220 8.065 15.493 15.039
M4 M5 M6 M7 M8 M9
9.039 6.514 6.050 6.968 1.558 32.340
M10 M11
10.139 -2.416
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-10.8807 -4.8007 0.1078 3.8097 15.7177
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -302.1631 22.0313 -13.715 < 2e-16 ***
TIP 1.8396 0.1350 13.624 < 2e-16 ***
CONS 2.2196 0.1607 13.814 < 2e-16 ***
M1 8.0650 3.9740 2.029 0.047175 *
M2 15.4928 4.3015 3.602 0.000672 ***
M3 15.0387 4.3088 3.490 0.000948 ***
M4 9.0392 4.2267 2.139 0.036844 *
M5 6.5143 3.8509 1.692 0.096278 .
M6 6.0504 4.0644 1.489 0.142195
M7 6.9685 4.1329 1.686 0.097339 .
M8 1.5579 3.8303 0.407 0.685758
M9 32.3396 5.2606 6.148 8.74e-08 ***
M10 10.1388 4.4313 2.288 0.025937 *
M11 -2.4163 3.9937 -0.605 0.547598
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.314 on 56 degrees of freedom
Multiple R-squared: 0.8967, Adjusted R-squared: 0.8727
F-statistic: 37.39 on 13 and 56 DF, p-value: < 2.2e-16
> 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.163983913 0.327967826 0.8360161
[2,] 0.076702493 0.153404985 0.9232975
[3,] 0.037320201 0.074640402 0.9626798
[4,] 0.086911481 0.173822961 0.9130885
[5,] 0.053271456 0.106542912 0.9467285
[6,] 0.025706210 0.051412421 0.9742938
[7,] 0.011649769 0.023299539 0.9883502
[8,] 0.006047761 0.012095522 0.9939522
[9,] 0.002778683 0.005557366 0.9972213
[10,] 0.002129583 0.004259165 0.9978704
[11,] 0.002010490 0.004020980 0.9979895
[12,] 0.002576137 0.005152274 0.9974239
[13,] 0.006231138 0.012462275 0.9937689
[14,] 0.008191337 0.016382675 0.9918087
[15,] 0.009015409 0.018030817 0.9909846
[16,] 0.009745122 0.019490243 0.9902549
[17,] 0.008752526 0.017505053 0.9912475
[18,] 0.005523451 0.011046902 0.9944765
[19,] 0.003960836 0.007921671 0.9960392
[20,] 0.002348552 0.004697105 0.9976514
[21,] 0.002245280 0.004490560 0.9977547
[22,] 0.009479986 0.018959972 0.9905200
[23,] 0.008103746 0.016207492 0.9918963
[24,] 0.012393314 0.024786628 0.9876067
[25,] 0.023108438 0.046216876 0.9768916
[26,] 0.016185172 0.032370344 0.9838148
[27,] 0.014369018 0.028738035 0.9856310
[28,] 0.012171874 0.024343747 0.9878281
[29,] 0.029839137 0.059678275 0.9701609
[30,] 0.031627097 0.063254194 0.9683729
[31,] 0.019511823 0.039023647 0.9804882
[32,] 0.019431729 0.038863458 0.9805683
[33,] 0.022158883 0.044317766 0.9778411
[34,] 0.022850910 0.045701820 0.9771491
[35,] 0.015991860 0.031983720 0.9840081
[36,] 0.030300639 0.060601277 0.9696994
[37,] 0.424628224 0.849256449 0.5753718
> postscript(file="/var/www/html/rcomp/tmp/1oqgi1261150602.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/23sqx1261150602.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/38sy91261150602.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/4ik6h1261150602.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/5rtie1261150602.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 = 70
Frequency = 1
1 2 3 4 5
-0.605561016 0.884028688 2.290514073 4.261637385 -4.062840238
6 7 8 9 10
0.374928766 0.970019049 3.955932205 -2.031246571 -1.418559052
11 12 13 14 15
-4.568810061 -0.836671704 2.849114102 2.227146718 1.187339495
16 17 18 19 20
8.578981991 8.614539085 1.500240972 6.066595072 -5.018084417
21 22 23 24 25
0.657078253 0.217339811 -1.796439086 -0.156325127 0.845710044
26 27 28 29 30
6.187828304 6.049391582 5.503978303 7.490288206 2.769025685
31 32 33 34 35
-4.240263007 -5.561405682 -1.576970836 -3.892751847 -5.759565471
36 37 38 39 40
-6.104444029 -7.033998819 -7.792014815 -7.669099233 -5.590444716
41 42 43 44 45
-10.529702068 -4.349740554 -0.001811346 -6.590901701 2.333349202
46 47 48 49 50
-7.182633654 0.234999342 -1.838851100 -0.786013607 3.370964869
51 52 53 54 55
2.391191787 -6.681332998 9.368375373 5.357867674 3.268619629
56 57 58 59 60
15.717662852 8.822276688 7.487258334 11.889815276 8.936291959
61 62 63 64 65
4.730749296 -4.877953764 -4.249337704 -6.072819965 -10.880660358
66 67 68 69 70
-5.652322543 -6.063159397 -2.503203257 -8.204486735 4.789346409
> postscript(file="/var/www/html/rcomp/tmp/69b2o1261150602.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 = 70
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.605561016 NA
1 0.884028688 -0.605561016
2 2.290514073 0.884028688
3 4.261637385 2.290514073
4 -4.062840238 4.261637385
5 0.374928766 -4.062840238
6 0.970019049 0.374928766
7 3.955932205 0.970019049
8 -2.031246571 3.955932205
9 -1.418559052 -2.031246571
10 -4.568810061 -1.418559052
11 -0.836671704 -4.568810061
12 2.849114102 -0.836671704
13 2.227146718 2.849114102
14 1.187339495 2.227146718
15 8.578981991 1.187339495
16 8.614539085 8.578981991
17 1.500240972 8.614539085
18 6.066595072 1.500240972
19 -5.018084417 6.066595072
20 0.657078253 -5.018084417
21 0.217339811 0.657078253
22 -1.796439086 0.217339811
23 -0.156325127 -1.796439086
24 0.845710044 -0.156325127
25 6.187828304 0.845710044
26 6.049391582 6.187828304
27 5.503978303 6.049391582
28 7.490288206 5.503978303
29 2.769025685 7.490288206
30 -4.240263007 2.769025685
31 -5.561405682 -4.240263007
32 -1.576970836 -5.561405682
33 -3.892751847 -1.576970836
34 -5.759565471 -3.892751847
35 -6.104444029 -5.759565471
36 -7.033998819 -6.104444029
37 -7.792014815 -7.033998819
38 -7.669099233 -7.792014815
39 -5.590444716 -7.669099233
40 -10.529702068 -5.590444716
41 -4.349740554 -10.529702068
42 -0.001811346 -4.349740554
43 -6.590901701 -0.001811346
44 2.333349202 -6.590901701
45 -7.182633654 2.333349202
46 0.234999342 -7.182633654
47 -1.838851100 0.234999342
48 -0.786013607 -1.838851100
49 3.370964869 -0.786013607
50 2.391191787 3.370964869
51 -6.681332998 2.391191787
52 9.368375373 -6.681332998
53 5.357867674 9.368375373
54 3.268619629 5.357867674
55 15.717662852 3.268619629
56 8.822276688 15.717662852
57 7.487258334 8.822276688
58 11.889815276 7.487258334
59 8.936291959 11.889815276
60 4.730749296 8.936291959
61 -4.877953764 4.730749296
62 -4.249337704 -4.877953764
63 -6.072819965 -4.249337704
64 -10.880660358 -6.072819965
65 -5.652322543 -10.880660358
66 -6.063159397 -5.652322543
67 -2.503203257 -6.063159397
68 -8.204486735 -2.503203257
69 4.789346409 -8.204486735
70 NA 4.789346409
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.884028688 -0.605561016
[2,] 2.290514073 0.884028688
[3,] 4.261637385 2.290514073
[4,] -4.062840238 4.261637385
[5,] 0.374928766 -4.062840238
[6,] 0.970019049 0.374928766
[7,] 3.955932205 0.970019049
[8,] -2.031246571 3.955932205
[9,] -1.418559052 -2.031246571
[10,] -4.568810061 -1.418559052
[11,] -0.836671704 -4.568810061
[12,] 2.849114102 -0.836671704
[13,] 2.227146718 2.849114102
[14,] 1.187339495 2.227146718
[15,] 8.578981991 1.187339495
[16,] 8.614539085 8.578981991
[17,] 1.500240972 8.614539085
[18,] 6.066595072 1.500240972
[19,] -5.018084417 6.066595072
[20,] 0.657078253 -5.018084417
[21,] 0.217339811 0.657078253
[22,] -1.796439086 0.217339811
[23,] -0.156325127 -1.796439086
[24,] 0.845710044 -0.156325127
[25,] 6.187828304 0.845710044
[26,] 6.049391582 6.187828304
[27,] 5.503978303 6.049391582
[28,] 7.490288206 5.503978303
[29,] 2.769025685 7.490288206
[30,] -4.240263007 2.769025685
[31,] -5.561405682 -4.240263007
[32,] -1.576970836 -5.561405682
[33,] -3.892751847 -1.576970836
[34,] -5.759565471 -3.892751847
[35,] -6.104444029 -5.759565471
[36,] -7.033998819 -6.104444029
[37,] -7.792014815 -7.033998819
[38,] -7.669099233 -7.792014815
[39,] -5.590444716 -7.669099233
[40,] -10.529702068 -5.590444716
[41,] -4.349740554 -10.529702068
[42,] -0.001811346 -4.349740554
[43,] -6.590901701 -0.001811346
[44,] 2.333349202 -6.590901701
[45,] -7.182633654 2.333349202
[46,] 0.234999342 -7.182633654
[47,] -1.838851100 0.234999342
[48,] -0.786013607 -1.838851100
[49,] 3.370964869 -0.786013607
[50,] 2.391191787 3.370964869
[51,] -6.681332998 2.391191787
[52,] 9.368375373 -6.681332998
[53,] 5.357867674 9.368375373
[54,] 3.268619629 5.357867674
[55,] 15.717662852 3.268619629
[56,] 8.822276688 15.717662852
[57,] 7.487258334 8.822276688
[58,] 11.889815276 7.487258334
[59,] 8.936291959 11.889815276
[60,] 4.730749296 8.936291959
[61,] -4.877953764 4.730749296
[62,] -4.249337704 -4.877953764
[63,] -6.072819965 -4.249337704
[64,] -10.880660358 -6.072819965
[65,] -5.652322543 -10.880660358
[66,] -6.063159397 -5.652322543
[67,] -2.503203257 -6.063159397
[68,] -8.204486735 -2.503203257
[69,] 4.789346409 -8.204486735
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.884028688 -0.605561016
2 2.290514073 0.884028688
3 4.261637385 2.290514073
4 -4.062840238 4.261637385
5 0.374928766 -4.062840238
6 0.970019049 0.374928766
7 3.955932205 0.970019049
8 -2.031246571 3.955932205
9 -1.418559052 -2.031246571
10 -4.568810061 -1.418559052
11 -0.836671704 -4.568810061
12 2.849114102 -0.836671704
13 2.227146718 2.849114102
14 1.187339495 2.227146718
15 8.578981991 1.187339495
16 8.614539085 8.578981991
17 1.500240972 8.614539085
18 6.066595072 1.500240972
19 -5.018084417 6.066595072
20 0.657078253 -5.018084417
21 0.217339811 0.657078253
22 -1.796439086 0.217339811
23 -0.156325127 -1.796439086
24 0.845710044 -0.156325127
25 6.187828304 0.845710044
26 6.049391582 6.187828304
27 5.503978303 6.049391582
28 7.490288206 5.503978303
29 2.769025685 7.490288206
30 -4.240263007 2.769025685
31 -5.561405682 -4.240263007
32 -1.576970836 -5.561405682
33 -3.892751847 -1.576970836
34 -5.759565471 -3.892751847
35 -6.104444029 -5.759565471
36 -7.033998819 -6.104444029
37 -7.792014815 -7.033998819
38 -7.669099233 -7.792014815
39 -5.590444716 -7.669099233
40 -10.529702068 -5.590444716
41 -4.349740554 -10.529702068
42 -0.001811346 -4.349740554
43 -6.590901701 -0.001811346
44 2.333349202 -6.590901701
45 -7.182633654 2.333349202
46 0.234999342 -7.182633654
47 -1.838851100 0.234999342
48 -0.786013607 -1.838851100
49 3.370964869 -0.786013607
50 2.391191787 3.370964869
51 -6.681332998 2.391191787
52 9.368375373 -6.681332998
53 5.357867674 9.368375373
54 3.268619629 5.357867674
55 15.717662852 3.268619629
56 8.822276688 15.717662852
57 7.487258334 8.822276688
58 11.889815276 7.487258334
59 8.936291959 11.889815276
60 4.730749296 8.936291959
61 -4.877953764 4.730749296
62 -4.249337704 -4.877953764
63 -6.072819965 -4.249337704
64 -10.880660358 -6.072819965
65 -5.652322543 -10.880660358
66 -6.063159397 -5.652322543
67 -2.503203257 -6.063159397
68 -8.204486735 -2.503203257
69 4.789346409 -8.204486735
> 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/78lj31261150602.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/88hdg1261150602.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/9vtgx1261150602.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/10594f1261150602.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/11s3db1261150602.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/12ufh41261150603.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/13ibs01261150603.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/140vch1261150603.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/15hmxl1261150603.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/16obh41261150603.tab")
+ }
>
> try(system("convert tmp/1oqgi1261150602.ps tmp/1oqgi1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/23sqx1261150602.ps tmp/23sqx1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/38sy91261150602.ps tmp/38sy91261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ik6h1261150602.ps tmp/4ik6h1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/5rtie1261150602.ps tmp/5rtie1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/69b2o1261150602.ps tmp/69b2o1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/78lj31261150602.ps tmp/78lj31261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/88hdg1261150602.ps tmp/88hdg1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/9vtgx1261150602.ps tmp/9vtgx1261150602.png",intern=TRUE))
character(0)
> try(system("convert tmp/10594f1261150602.ps tmp/10594f1261150602.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.595 1.595 7.933