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(3030.29
+ ,25.64
+ ,2803.47
+ ,27.97
+ ,2767.63
+ ,27.62
+ ,2882.6
+ ,23.31
+ ,2863.36
+ ,29.07
+ ,2897.06
+ ,29.58
+ ,3012.61
+ ,28.63
+ ,3142.95
+ ,29.92
+ ,3032.93
+ ,32.68
+ ,3045.78
+ ,31.54
+ ,3110.52
+ ,32.43
+ ,3013.24
+ ,26.54
+ ,2987.1
+ ,25.85
+ ,2995.55
+ ,27.6
+ ,2833.18
+ ,25.71
+ ,2848.96
+ ,25.38
+ ,2794.83
+ ,28.57
+ ,2845.26
+ ,27.64
+ ,2915.03
+ ,25.36
+ ,2892.63
+ ,25.9
+ ,2604.42
+ ,26.29
+ ,2641.65
+ ,21.74
+ ,2659.81
+ ,19.2
+ ,2638.53
+ ,19.32
+ ,2720.25
+ ,19.82
+ ,2745.88
+ ,20.36
+ ,2735.7
+ ,24.31
+ ,2811.7
+ ,25.97
+ ,2799.43
+ ,25.61
+ ,2555.28
+ ,24.67
+ ,2304.98
+ ,25.59
+ ,2214.95
+ ,26.09
+ ,2065.81
+ ,28.37
+ ,1940.49
+ ,27.34
+ ,2042
+ ,24.46
+ ,1995.37
+ ,27.46
+ ,1946.81
+ ,30.23
+ ,1765.9
+ ,32.33
+ ,1635.25
+ ,29.87
+ ,1833.42
+ ,24.87
+ ,1910.43
+ ,25.48
+ ,1959.67
+ ,27.28
+ ,1969.6
+ ,28.24
+ ,2061.41
+ ,29.58
+ ,2093.48
+ ,26.95
+ ,2120.88
+ ,29.08
+ ,2174.56
+ ,28.76
+ ,2196.72
+ ,29.59
+ ,2350.44
+ ,30.7
+ ,2440.25
+ ,30.52
+ ,2408.64
+ ,32.67
+ ,2472.81
+ ,33.19
+ ,2407.6
+ ,37.13
+ ,2454.62
+ ,35.54
+ ,2448.05
+ ,37.75
+ ,2497.84
+ ,41.84
+ ,2645.64
+ ,42.94
+ ,2756.76
+ ,49.14
+ ,2849.27
+ ,44.61
+ ,2921.44
+ ,40.22
+ ,2981.85
+ ,44.23
+ ,3080.58
+ ,45.85
+ ,3106.22
+ ,53.38
+ ,3119.31
+ ,53.26
+ ,3061.26
+ ,51.8
+ ,3097.31
+ ,55.3
+ ,3161.69
+ ,57.81
+ ,3257.16
+ ,63.96
+ ,3277.01
+ ,63.77
+ ,3295.32
+ ,59.15
+ ,3363.99
+ ,56.12
+ ,3494.17
+ ,57.42
+ ,3667.03
+ ,63.52
+ ,3813.06
+ ,61.71
+ ,3917.96
+ ,63.01
+ ,3895.51
+ ,68.18
+ ,3801.06
+ ,72.03
+ ,3570.12
+ ,69.75
+ ,3701.61
+ ,74.41
+ ,3862.27
+ ,74.33
+ ,3970.1
+ ,64.24
+ ,4138.52
+ ,60.03
+ ,4199.75
+ ,59.44
+ ,4290.89
+ ,62.5
+ ,4443.91
+ ,55.04
+ ,4502.64
+ ,58.34
+ ,4356.98
+ ,61.92
+ ,4591.27
+ ,67.65
+ ,4696.96
+ ,67.68
+ ,4621.4
+ ,70.3
+ ,4562.84
+ ,75.26
+ ,4202.52
+ ,71.44
+ ,4296.49
+ ,76.36
+ ,4435.23
+ ,81.71
+ ,4105.18
+ ,92.6
+ ,4116.68
+ ,90.6
+ ,3844.49
+ ,92.23
+ ,3720.98
+ ,94.09
+ ,3674.4
+ ,102.79
+ ,3857.62
+ ,109.65
+ ,3801.06
+ ,124.05
+ ,3504.37
+ ,132.69
+ ,3032.6
+ ,135.81
+ ,3047.03
+ ,116.07
+ ,2962.34
+ ,101.42
+ ,2197.82
+ ,75.73
+ ,2014.45
+ ,55.48
+ ,1862.83
+ ,43.8
+ ,1905.41
+ ,45.29)
+ ,dim=c(2
+ ,109)
+ ,dimnames=list(c('Aandelenkoers'
+ ,'Olieprijs')
+ ,1:109))
> y <- array(NA,dim=c(2,109),dimnames=list(c('Aandelenkoers','Olieprijs'),1:109))
> 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 = '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
Aandelenkoers Olieprijs
1 3030.29 25.64
2 2803.47 27.97
3 2767.63 27.62
4 2882.60 23.31
5 2863.36 29.07
6 2897.06 29.58
7 3012.61 28.63
8 3142.95 29.92
9 3032.93 32.68
10 3045.78 31.54
11 3110.52 32.43
12 3013.24 26.54
13 2987.10 25.85
14 2995.55 27.60
15 2833.18 25.71
16 2848.96 25.38
17 2794.83 28.57
18 2845.26 27.64
19 2915.03 25.36
20 2892.63 25.90
21 2604.42 26.29
22 2641.65 21.74
23 2659.81 19.20
24 2638.53 19.32
25 2720.25 19.82
26 2745.88 20.36
27 2735.70 24.31
28 2811.70 25.97
29 2799.43 25.61
30 2555.28 24.67
31 2304.98 25.59
32 2214.95 26.09
33 2065.81 28.37
34 1940.49 27.34
35 2042.00 24.46
36 1995.37 27.46
37 1946.81 30.23
38 1765.90 32.33
39 1635.25 29.87
40 1833.42 24.87
41 1910.43 25.48
42 1959.67 27.28
43 1969.60 28.24
44 2061.41 29.58
45 2093.48 26.95
46 2120.88 29.08
47 2174.56 28.76
48 2196.72 29.59
49 2350.44 30.70
50 2440.25 30.52
51 2408.64 32.67
52 2472.81 33.19
53 2407.60 37.13
54 2454.62 35.54
55 2448.05 37.75
56 2497.84 41.84
57 2645.64 42.94
58 2756.76 49.14
59 2849.27 44.61
60 2921.44 40.22
61 2981.85 44.23
62 3080.58 45.85
63 3106.22 53.38
64 3119.31 53.26
65 3061.26 51.80
66 3097.31 55.30
67 3161.69 57.81
68 3257.16 63.96
69 3277.01 63.77
70 3295.32 59.15
71 3363.99 56.12
72 3494.17 57.42
73 3667.03 63.52
74 3813.06 61.71
75 3917.96 63.01
76 3895.51 68.18
77 3801.06 72.03
78 3570.12 69.75
79 3701.61 74.41
80 3862.27 74.33
81 3970.10 64.24
82 4138.52 60.03
83 4199.75 59.44
84 4290.89 62.50
85 4443.91 55.04
86 4502.64 58.34
87 4356.98 61.92
88 4591.27 67.65
89 4696.96 67.68
90 4621.40 70.30
91 4562.84 75.26
92 4202.52 71.44
93 4296.49 76.36
94 4435.23 81.71
95 4105.18 92.60
96 4116.68 90.60
97 3844.49 92.23
98 3720.98 94.09
99 3674.40 102.79
100 3857.62 109.65
101 3801.06 124.05
102 3504.37 132.69
103 3032.60 135.81
104 3047.03 116.07
105 2962.34 101.42
106 2197.82 75.73
107 2014.45 55.48
108 1862.83 43.80
109 1905.41 45.29
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Olieprijs
2162.31 17.81
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1548.32 -409.59 92.17 340.43 1329.35
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2162.315 122.062 17.715 < 2e-16 ***
Olieprijs 17.809 2.203 8.084 1.03e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 613 on 107 degrees of freedom
Multiple R-squared: 0.3792, Adjusted R-squared: 0.3734
F-statistic: 65.36 on 1 and 107 DF, p-value: 1.031e-12
> 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,] 6.348664e-03 1.269733e-02 0.993651336
[2,] 1.099444e-03 2.198888e-03 0.998900556
[3,] 4.074059e-04 8.148118e-04 0.999592594
[4,] 3.966874e-04 7.933747e-04 0.999603313
[5,] 7.899895e-05 1.579979e-04 0.999921001
[6,] 1.560003e-05 3.120007e-05 0.999984400
[7,] 3.479349e-06 6.958697e-06 0.999996521
[8,] 8.435221e-07 1.687044e-06 0.999999156
[9,] 1.725634e-07 3.451268e-07 0.999999827
[10,] 3.037038e-08 6.074076e-08 0.999999970
[11,] 6.614329e-09 1.322866e-08 0.999999993
[12,] 1.172426e-09 2.344853e-09 0.999999999
[13,] 6.046933e-10 1.209387e-09 0.999999999
[14,] 1.338241e-10 2.676482e-10 1.000000000
[15,] 2.207907e-11 4.415813e-11 1.000000000
[16,] 3.404375e-12 6.808749e-12 1.000000000
[17,] 1.715277e-11 3.430555e-11 1.000000000
[18,] 4.904227e-12 9.808454e-12 1.000000000
[19,] 8.542862e-13 1.708572e-12 1.000000000
[20,] 1.488327e-13 2.976654e-13 1.000000000
[21,] 2.631685e-14 5.263370e-14 1.000000000
[22,] 4.650569e-15 9.301137e-15 1.000000000
[23,] 9.730939e-16 1.946188e-15 1.000000000
[24,] 1.716522e-16 3.433045e-16 1.000000000
[25,] 2.994158e-17 5.988317e-17 1.000000000
[26,] 7.349690e-17 1.469938e-16 1.000000000
[27,] 2.893286e-14 5.786571e-14 1.000000000
[28,] 3.730494e-12 7.460988e-12 1.000000000
[29,] 9.090589e-10 1.818118e-09 0.999999999
[30,] 5.023447e-08 1.004689e-07 0.999999950
[31,] 1.940177e-07 3.880354e-07 0.999999806
[32,] 1.022205e-06 2.044410e-06 0.999998978
[33,] 5.648563e-06 1.129713e-05 0.999994351
[34,] 4.300295e-05 8.600589e-05 0.999956997
[35,] 2.650157e-04 5.300315e-04 0.999734984
[36,] 5.516496e-04 1.103299e-03 0.999448350
[37,] 8.220862e-04 1.644172e-03 0.999177914
[38,] 1.042626e-03 2.085252e-03 0.998957374
[39,] 1.262020e-03 2.524039e-03 0.998737980
[40,] 1.260536e-03 2.521072e-03 0.998739464
[41,] 1.199869e-03 2.399739e-03 0.998800131
[42,] 1.094303e-03 2.188606e-03 0.998905697
[43,] 9.331784e-04 1.866357e-03 0.999066822
[44,] 7.812381e-04 1.562476e-03 0.999218762
[45,] 5.617073e-04 1.123415e-03 0.999438293
[46,] 3.826451e-04 7.652902e-04 0.999617355
[47,] 2.714343e-04 5.428686e-04 0.999728566
[48,] 1.894551e-04 3.789102e-04 0.999810545
[49,] 1.448963e-04 2.897926e-04 0.999855104
[50,] 1.096453e-04 2.192905e-04 0.999890355
[51,] 8.840080e-05 1.768016e-04 0.999911599
[52,] 7.562424e-05 1.512485e-04 0.999924376
[53,] 6.427981e-05 1.285596e-04 0.999935720
[54,] 5.712745e-05 1.142549e-04 0.999942873
[55,] 4.756535e-05 9.513070e-05 0.999952435
[56,] 3.917292e-05 7.834584e-05 0.999960827
[57,] 3.250838e-05 6.501675e-05 0.999967492
[58,] 2.714167e-05 5.428334e-05 0.999972858
[59,] 2.052873e-05 4.105745e-05 0.999979471
[60,] 1.488425e-05 2.976850e-05 0.999985116
[61,] 1.073171e-05 2.146343e-05 0.999989268
[62,] 7.521768e-06 1.504354e-05 0.999992478
[63,] 5.095395e-06 1.019079e-05 0.999994905
[64,] 3.203684e-06 6.407368e-06 0.999996796
[65,] 1.986163e-06 3.972326e-06 0.999998014
[66,] 1.272968e-06 2.545936e-06 0.999998727
[67,] 8.540127e-07 1.708025e-06 0.999999146
[68,] 5.843541e-07 1.168708e-06 0.999999416
[69,] 3.820734e-07 7.641469e-07 0.999999618
[70,] 3.053953e-07 6.107906e-07 0.999999695
[71,] 2.568889e-07 5.137777e-07 0.999999743
[72,] 1.571673e-07 3.143346e-07 0.999999843
[73,] 7.625254e-08 1.525051e-07 0.999999924
[74,] 3.569242e-08 7.138485e-08 0.999999964
[75,] 1.580480e-08 3.160960e-08 0.999999984
[76,] 7.183290e-09 1.436658e-08 0.999999993
[77,] 4.959021e-09 9.918042e-09 0.999999995
[78,] 6.442657e-09 1.288531e-08 0.999999994
[79,] 9.697975e-09 1.939595e-08 0.999999990
[80,] 1.491888e-08 2.983775e-08 0.999999985
[81,] 7.131543e-08 1.426309e-07 0.999999929
[82,] 2.980838e-07 5.961677e-07 0.999999702
[83,] 5.527211e-07 1.105442e-06 0.999999447
[84,] 1.884028e-06 3.768056e-06 0.999998116
[85,] 1.224854e-05 2.449708e-05 0.999987751
[86,] 6.613699e-05 1.322740e-04 0.999933863
[87,] 3.101204e-04 6.202409e-04 0.999689880
[88,] 8.152572e-04 1.630514e-03 0.999184743
[89,] 3.379317e-03 6.758634e-03 0.996620683
[90,] 2.632720e-02 5.265440e-02 0.973672802
[91,] 6.521545e-02 1.304309e-01 0.934784548
[92,] 2.045285e-01 4.090571e-01 0.795471456
[93,] 3.849291e-01 7.698581e-01 0.615070928
[94,] 5.906364e-01 8.187273e-01 0.409363640
[95,] 7.341195e-01 5.317609e-01 0.265880464
[96,] 9.361892e-01 1.276217e-01 0.063810838
[97,] 9.914682e-01 1.706369e-02 0.008531843
[98,] 9.929581e-01 1.408387e-02 0.007041937
[99,] 9.959771e-01 8.045794e-03 0.004022897
[100,] 9.823810e-01 3.523804e-02 0.017619021
> postscript(file="/var/www/html/rcomp/tmp/1y3r61291909817.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/www/html/rcomp/tmp/2y3r61291909817.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/www/html/rcomp/tmp/39uqr1291909817.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/www/html/rcomp/tmp/49uqr1291909817.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/www/html/rcomp/tmp/59uqr1291909817.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 = 109
Frequency = 1
1 2 3 4 5 6
411.359604 143.045257 113.438314 305.163950 183.345652 207.963199
7 8 9 10 11 12
340.431494 447.798230 288.626129 321.778084 370.668312 378.281745
13 14 15 16 17 18
364.429770 341.714488 213.002992 234.659874 123.720018 190.712139
19 20 21 22 23 24
301.086049 269.069333 -26.086072 92.173659 155.567839 132.150791
25 26 27 28 29 30
204.966425 220.979710 140.455217 186.892722 181.033865 -46.375926
31 32 33 34 35 36
-313.059960 -411.994326 -601.738235 -708.715241 -555.916092 -655.972289
37 38 39 40 41 42
-753.862477 -972.170815 -1059.011334 -771.797673 -705.650999 -688.466717
43 44 45 46 47 48
-695.633100 -627.686801 -548.779836 -559.312435 -499.933641 -492.554889
49 50 51 52 53 54
-358.602581 -265.587010 -335.485784 -280.576325 -415.952729 -340.616845
55 56 57 58 59 60
-386.544143 -409.591858 -281.381464 -280.675603 -107.492046 42.858288
61 62 63 64 65 66
31.855272 101.735126 -6.724628 8.502420 -23.546831 -49.827394
67 68 69 70 71 72
-30.147311 -44.201014 -20.967355 79.618987 202.249446 309.278094
73 74 75 76 77 78
373.504828 551.768633 633.517281 518.996136 355.982517 165.646426
79 80 81 82 83 84
214.147734 376.232433 663.752541 907.147303 978.884455 1015.529735
85 86 87 88 89 90
1301.402877 1301.364061 1091.948799 1224.194764 1329.350502 1207.131623
91 92 93 94 95 96
1060.240312 767.949669 774.300706 817.763989 293.776895 340.894360
97 98 99 100 101 102
39.676126 -116.958116 -318.474086 -257.421989 -570.427732 -1020.985179
103 104 105 106 107 108
-1548.318423 -1182.344050 -1006.136123 -1313.149792 -1135.892965 -1079.506973
109
-1063.461984
> postscript(file="/var/www/html/rcomp/tmp/61m8u1291909817.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 = 109
Frequency = 1
lag(myerror, k = 1) myerror
0 411.359604 NA
1 143.045257 411.359604
2 113.438314 143.045257
3 305.163950 113.438314
4 183.345652 305.163950
5 207.963199 183.345652
6 340.431494 207.963199
7 447.798230 340.431494
8 288.626129 447.798230
9 321.778084 288.626129
10 370.668312 321.778084
11 378.281745 370.668312
12 364.429770 378.281745
13 341.714488 364.429770
14 213.002992 341.714488
15 234.659874 213.002992
16 123.720018 234.659874
17 190.712139 123.720018
18 301.086049 190.712139
19 269.069333 301.086049
20 -26.086072 269.069333
21 92.173659 -26.086072
22 155.567839 92.173659
23 132.150791 155.567839
24 204.966425 132.150791
25 220.979710 204.966425
26 140.455217 220.979710
27 186.892722 140.455217
28 181.033865 186.892722
29 -46.375926 181.033865
30 -313.059960 -46.375926
31 -411.994326 -313.059960
32 -601.738235 -411.994326
33 -708.715241 -601.738235
34 -555.916092 -708.715241
35 -655.972289 -555.916092
36 -753.862477 -655.972289
37 -972.170815 -753.862477
38 -1059.011334 -972.170815
39 -771.797673 -1059.011334
40 -705.650999 -771.797673
41 -688.466717 -705.650999
42 -695.633100 -688.466717
43 -627.686801 -695.633100
44 -548.779836 -627.686801
45 -559.312435 -548.779836
46 -499.933641 -559.312435
47 -492.554889 -499.933641
48 -358.602581 -492.554889
49 -265.587010 -358.602581
50 -335.485784 -265.587010
51 -280.576325 -335.485784
52 -415.952729 -280.576325
53 -340.616845 -415.952729
54 -386.544143 -340.616845
55 -409.591858 -386.544143
56 -281.381464 -409.591858
57 -280.675603 -281.381464
58 -107.492046 -280.675603
59 42.858288 -107.492046
60 31.855272 42.858288
61 101.735126 31.855272
62 -6.724628 101.735126
63 8.502420 -6.724628
64 -23.546831 8.502420
65 -49.827394 -23.546831
66 -30.147311 -49.827394
67 -44.201014 -30.147311
68 -20.967355 -44.201014
69 79.618987 -20.967355
70 202.249446 79.618987
71 309.278094 202.249446
72 373.504828 309.278094
73 551.768633 373.504828
74 633.517281 551.768633
75 518.996136 633.517281
76 355.982517 518.996136
77 165.646426 355.982517
78 214.147734 165.646426
79 376.232433 214.147734
80 663.752541 376.232433
81 907.147303 663.752541
82 978.884455 907.147303
83 1015.529735 978.884455
84 1301.402877 1015.529735
85 1301.364061 1301.402877
86 1091.948799 1301.364061
87 1224.194764 1091.948799
88 1329.350502 1224.194764
89 1207.131623 1329.350502
90 1060.240312 1207.131623
91 767.949669 1060.240312
92 774.300706 767.949669
93 817.763989 774.300706
94 293.776895 817.763989
95 340.894360 293.776895
96 39.676126 340.894360
97 -116.958116 39.676126
98 -318.474086 -116.958116
99 -257.421989 -318.474086
100 -570.427732 -257.421989
101 -1020.985179 -570.427732
102 -1548.318423 -1020.985179
103 -1182.344050 -1548.318423
104 -1006.136123 -1182.344050
105 -1313.149792 -1006.136123
106 -1135.892965 -1313.149792
107 -1079.506973 -1135.892965
108 -1063.461984 -1079.506973
109 NA -1063.461984
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 143.045257 411.359604
[2,] 113.438314 143.045257
[3,] 305.163950 113.438314
[4,] 183.345652 305.163950
[5,] 207.963199 183.345652
[6,] 340.431494 207.963199
[7,] 447.798230 340.431494
[8,] 288.626129 447.798230
[9,] 321.778084 288.626129
[10,] 370.668312 321.778084
[11,] 378.281745 370.668312
[12,] 364.429770 378.281745
[13,] 341.714488 364.429770
[14,] 213.002992 341.714488
[15,] 234.659874 213.002992
[16,] 123.720018 234.659874
[17,] 190.712139 123.720018
[18,] 301.086049 190.712139
[19,] 269.069333 301.086049
[20,] -26.086072 269.069333
[21,] 92.173659 -26.086072
[22,] 155.567839 92.173659
[23,] 132.150791 155.567839
[24,] 204.966425 132.150791
[25,] 220.979710 204.966425
[26,] 140.455217 220.979710
[27,] 186.892722 140.455217
[28,] 181.033865 186.892722
[29,] -46.375926 181.033865
[30,] -313.059960 -46.375926
[31,] -411.994326 -313.059960
[32,] -601.738235 -411.994326
[33,] -708.715241 -601.738235
[34,] -555.916092 -708.715241
[35,] -655.972289 -555.916092
[36,] -753.862477 -655.972289
[37,] -972.170815 -753.862477
[38,] -1059.011334 -972.170815
[39,] -771.797673 -1059.011334
[40,] -705.650999 -771.797673
[41,] -688.466717 -705.650999
[42,] -695.633100 -688.466717
[43,] -627.686801 -695.633100
[44,] -548.779836 -627.686801
[45,] -559.312435 -548.779836
[46,] -499.933641 -559.312435
[47,] -492.554889 -499.933641
[48,] -358.602581 -492.554889
[49,] -265.587010 -358.602581
[50,] -335.485784 -265.587010
[51,] -280.576325 -335.485784
[52,] -415.952729 -280.576325
[53,] -340.616845 -415.952729
[54,] -386.544143 -340.616845
[55,] -409.591858 -386.544143
[56,] -281.381464 -409.591858
[57,] -280.675603 -281.381464
[58,] -107.492046 -280.675603
[59,] 42.858288 -107.492046
[60,] 31.855272 42.858288
[61,] 101.735126 31.855272
[62,] -6.724628 101.735126
[63,] 8.502420 -6.724628
[64,] -23.546831 8.502420
[65,] -49.827394 -23.546831
[66,] -30.147311 -49.827394
[67,] -44.201014 -30.147311
[68,] -20.967355 -44.201014
[69,] 79.618987 -20.967355
[70,] 202.249446 79.618987
[71,] 309.278094 202.249446
[72,] 373.504828 309.278094
[73,] 551.768633 373.504828
[74,] 633.517281 551.768633
[75,] 518.996136 633.517281
[76,] 355.982517 518.996136
[77,] 165.646426 355.982517
[78,] 214.147734 165.646426
[79,] 376.232433 214.147734
[80,] 663.752541 376.232433
[81,] 907.147303 663.752541
[82,] 978.884455 907.147303
[83,] 1015.529735 978.884455
[84,] 1301.402877 1015.529735
[85,] 1301.364061 1301.402877
[86,] 1091.948799 1301.364061
[87,] 1224.194764 1091.948799
[88,] 1329.350502 1224.194764
[89,] 1207.131623 1329.350502
[90,] 1060.240312 1207.131623
[91,] 767.949669 1060.240312
[92,] 774.300706 767.949669
[93,] 817.763989 774.300706
[94,] 293.776895 817.763989
[95,] 340.894360 293.776895
[96,] 39.676126 340.894360
[97,] -116.958116 39.676126
[98,] -318.474086 -116.958116
[99,] -257.421989 -318.474086
[100,] -570.427732 -257.421989
[101,] -1020.985179 -570.427732
[102,] -1548.318423 -1020.985179
[103,] -1182.344050 -1548.318423
[104,] -1006.136123 -1182.344050
[105,] -1313.149792 -1006.136123
[106,] -1135.892965 -1313.149792
[107,] -1079.506973 -1135.892965
[108,] -1063.461984 -1079.506973
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 143.045257 411.359604
2 113.438314 143.045257
3 305.163950 113.438314
4 183.345652 305.163950
5 207.963199 183.345652
6 340.431494 207.963199
7 447.798230 340.431494
8 288.626129 447.798230
9 321.778084 288.626129
10 370.668312 321.778084
11 378.281745 370.668312
12 364.429770 378.281745
13 341.714488 364.429770
14 213.002992 341.714488
15 234.659874 213.002992
16 123.720018 234.659874
17 190.712139 123.720018
18 301.086049 190.712139
19 269.069333 301.086049
20 -26.086072 269.069333
21 92.173659 -26.086072
22 155.567839 92.173659
23 132.150791 155.567839
24 204.966425 132.150791
25 220.979710 204.966425
26 140.455217 220.979710
27 186.892722 140.455217
28 181.033865 186.892722
29 -46.375926 181.033865
30 -313.059960 -46.375926
31 -411.994326 -313.059960
32 -601.738235 -411.994326
33 -708.715241 -601.738235
34 -555.916092 -708.715241
35 -655.972289 -555.916092
36 -753.862477 -655.972289
37 -972.170815 -753.862477
38 -1059.011334 -972.170815
39 -771.797673 -1059.011334
40 -705.650999 -771.797673
41 -688.466717 -705.650999
42 -695.633100 -688.466717
43 -627.686801 -695.633100
44 -548.779836 -627.686801
45 -559.312435 -548.779836
46 -499.933641 -559.312435
47 -492.554889 -499.933641
48 -358.602581 -492.554889
49 -265.587010 -358.602581
50 -335.485784 -265.587010
51 -280.576325 -335.485784
52 -415.952729 -280.576325
53 -340.616845 -415.952729
54 -386.544143 -340.616845
55 -409.591858 -386.544143
56 -281.381464 -409.591858
57 -280.675603 -281.381464
58 -107.492046 -280.675603
59 42.858288 -107.492046
60 31.855272 42.858288
61 101.735126 31.855272
62 -6.724628 101.735126
63 8.502420 -6.724628
64 -23.546831 8.502420
65 -49.827394 -23.546831
66 -30.147311 -49.827394
67 -44.201014 -30.147311
68 -20.967355 -44.201014
69 79.618987 -20.967355
70 202.249446 79.618987
71 309.278094 202.249446
72 373.504828 309.278094
73 551.768633 373.504828
74 633.517281 551.768633
75 518.996136 633.517281
76 355.982517 518.996136
77 165.646426 355.982517
78 214.147734 165.646426
79 376.232433 214.147734
80 663.752541 376.232433
81 907.147303 663.752541
82 978.884455 907.147303
83 1015.529735 978.884455
84 1301.402877 1015.529735
85 1301.364061 1301.402877
86 1091.948799 1301.364061
87 1224.194764 1091.948799
88 1329.350502 1224.194764
89 1207.131623 1329.350502
90 1060.240312 1207.131623
91 767.949669 1060.240312
92 774.300706 767.949669
93 817.763989 774.300706
94 293.776895 817.763989
95 340.894360 293.776895
96 39.676126 340.894360
97 -116.958116 39.676126
98 -318.474086 -116.958116
99 -257.421989 -318.474086
100 -570.427732 -257.421989
101 -1020.985179 -570.427732
102 -1548.318423 -1020.985179
103 -1182.344050 -1548.318423
104 -1006.136123 -1182.344050
105 -1313.149792 -1006.136123
106 -1135.892965 -1313.149792
107 -1079.506973 -1135.892965
108 -1063.461984 -1079.506973
> 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/7cv7f1291909817.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/www/html/rcomp/tmp/8cv7f1291909817.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/www/html/rcomp/tmp/9cv7f1291909817.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/www/html/rcomp/tmp/105mo01291909817.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/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/118n5n1291909817.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/12uolb1291909817.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/138xjk1291909817.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/14bgh81291909817.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/15wgyw1291909817.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/16ize21291909817.tab")
+ }
>
> try(system("convert tmp/1y3r61291909817.ps tmp/1y3r61291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/2y3r61291909817.ps tmp/2y3r61291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/39uqr1291909817.ps tmp/39uqr1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/49uqr1291909817.ps tmp/49uqr1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/59uqr1291909817.ps tmp/59uqr1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/61m8u1291909817.ps tmp/61m8u1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/7cv7f1291909817.ps tmp/7cv7f1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/8cv7f1291909817.ps tmp/8cv7f1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/9cv7f1291909817.ps tmp/9cv7f1291909817.png",intern=TRUE))
character(0)
> try(system("convert tmp/105mo01291909817.ps tmp/105mo01291909817.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.097 1.768 15.400