R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(54.3,55.9,63.9,64,60.7,67.8,70.5,76.6,76.2,71.8,67.8,69.7,76.7,74.2,75.8,84.3,84.9,84.4,89.4,88.5,76.5,71.4,72.1,75.8,66.6,71.7,75.4,80.9,80.7,85,91.5,87.7,95.3,102.4,114.2,111.7,113.7,118.8,129,136.4,155,166,168.7,145.5,127.3,91.5,69,54,56.3,54.2,59.3,63.4,73.3,86.7,81.3,89.6,85.3,92.4,96.8,93.6,97.6,94.2,99.9,106.4,96,94.9,94.8,95.9,96.2,103.1,106.9,114.2,118.2,123.9,137.1,146.2,136.4,133.2,135.9,127.1,128.5,126.6,132.6,130.9),dim=c(1,84),dimnames=list(c('Grondstoffen'),1:84))
> y <- array(NA,dim=c(1,84),dimnames=list(c('Grondstoffen'),1:84))
> 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 = 'Include Monthly Dummies'
> par1 = '1'
> par3 <- '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, 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
Grondstoffen M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 54.3 1 0 0 0 0 0 0 0 0 0 0 1
2 55.9 0 1 0 0 0 0 0 0 0 0 0 2
3 63.9 0 0 1 0 0 0 0 0 0 0 0 3
4 64.0 0 0 0 1 0 0 0 0 0 0 0 4
5 60.7 0 0 0 0 1 0 0 0 0 0 0 5
6 67.8 0 0 0 0 0 1 0 0 0 0 0 6
7 70.5 0 0 0 0 0 0 1 0 0 0 0 7
8 76.6 0 0 0 0 0 0 0 1 0 0 0 8
9 76.2 0 0 0 0 0 0 0 0 1 0 0 9
10 71.8 0 0 0 0 0 0 0 0 0 1 0 10
11 67.8 0 0 0 0 0 0 0 0 0 0 1 11
12 69.7 0 0 0 0 0 0 0 0 0 0 0 12
13 76.7 1 0 0 0 0 0 0 0 0 0 0 13
14 74.2 0 1 0 0 0 0 0 0 0 0 0 14
15 75.8 0 0 1 0 0 0 0 0 0 0 0 15
16 84.3 0 0 0 1 0 0 0 0 0 0 0 16
17 84.9 0 0 0 0 1 0 0 0 0 0 0 17
18 84.4 0 0 0 0 0 1 0 0 0 0 0 18
19 89.4 0 0 0 0 0 0 1 0 0 0 0 19
20 88.5 0 0 0 0 0 0 0 1 0 0 0 20
21 76.5 0 0 0 0 0 0 0 0 1 0 0 21
22 71.4 0 0 0 0 0 0 0 0 0 1 0 22
23 72.1 0 0 0 0 0 0 0 0 0 0 1 23
24 75.8 0 0 0 0 0 0 0 0 0 0 0 24
25 66.6 1 0 0 0 0 0 0 0 0 0 0 25
26 71.7 0 1 0 0 0 0 0 0 0 0 0 26
27 75.4 0 0 1 0 0 0 0 0 0 0 0 27
28 80.9 0 0 0 1 0 0 0 0 0 0 0 28
29 80.7 0 0 0 0 1 0 0 0 0 0 0 29
30 85.0 0 0 0 0 0 1 0 0 0 0 0 30
31 91.5 0 0 0 0 0 0 1 0 0 0 0 31
32 87.7 0 0 0 0 0 0 0 1 0 0 0 32
33 95.3 0 0 0 0 0 0 0 0 1 0 0 33
34 102.4 0 0 0 0 0 0 0 0 0 1 0 34
35 114.2 0 0 0 0 0 0 0 0 0 0 1 35
36 111.7 0 0 0 0 0 0 0 0 0 0 0 36
37 113.7 1 0 0 0 0 0 0 0 0 0 0 37
38 118.8 0 1 0 0 0 0 0 0 0 0 0 38
39 129.0 0 0 1 0 0 0 0 0 0 0 0 39
40 136.4 0 0 0 1 0 0 0 0 0 0 0 40
41 155.0 0 0 0 0 1 0 0 0 0 0 0 41
42 166.0 0 0 0 0 0 1 0 0 0 0 0 42
43 168.7 0 0 0 0 0 0 1 0 0 0 0 43
44 145.5 0 0 0 0 0 0 0 1 0 0 0 44
45 127.3 0 0 0 0 0 0 0 0 1 0 0 45
46 91.5 0 0 0 0 0 0 0 0 0 1 0 46
47 69.0 0 0 0 0 0 0 0 0 0 0 1 47
48 54.0 0 0 0 0 0 0 0 0 0 0 0 48
49 56.3 1 0 0 0 0 0 0 0 0 0 0 49
50 54.2 0 1 0 0 0 0 0 0 0 0 0 50
51 59.3 0 0 1 0 0 0 0 0 0 0 0 51
52 63.4 0 0 0 1 0 0 0 0 0 0 0 52
53 73.3 0 0 0 0 1 0 0 0 0 0 0 53
54 86.7 0 0 0 0 0 1 0 0 0 0 0 54
55 81.3 0 0 0 0 0 0 1 0 0 0 0 55
56 89.6 0 0 0 0 0 0 0 1 0 0 0 56
57 85.3 0 0 0 0 0 0 0 0 1 0 0 57
58 92.4 0 0 0 0 0 0 0 0 0 1 0 58
59 96.8 0 0 0 0 0 0 0 0 0 0 1 59
60 93.6 0 0 0 0 0 0 0 0 0 0 0 60
61 97.6 1 0 0 0 0 0 0 0 0 0 0 61
62 94.2 0 1 0 0 0 0 0 0 0 0 0 62
63 99.9 0 0 1 0 0 0 0 0 0 0 0 63
64 106.4 0 0 0 1 0 0 0 0 0 0 0 64
65 96.0 0 0 0 0 1 0 0 0 0 0 0 65
66 94.9 0 0 0 0 0 1 0 0 0 0 0 66
67 94.8 0 0 0 0 0 0 1 0 0 0 0 67
68 95.9 0 0 0 0 0 0 0 1 0 0 0 68
69 96.2 0 0 0 0 0 0 0 0 1 0 0 69
70 103.1 0 0 0 0 0 0 0 0 0 1 0 70
71 106.9 0 0 0 0 0 0 0 0 0 0 1 71
72 114.2 0 0 0 0 0 0 0 0 0 0 0 72
73 118.2 1 0 0 0 0 0 0 0 0 0 0 73
74 123.9 0 1 0 0 0 0 0 0 0 0 0 74
75 137.1 0 0 1 0 0 0 0 0 0 0 0 75
76 146.2 0 0 0 1 0 0 0 0 0 0 0 76
77 136.4 0 0 0 0 1 0 0 0 0 0 0 77
78 133.2 0 0 0 0 0 1 0 0 0 0 0 78
79 135.9 0 0 0 0 0 0 1 0 0 0 0 79
80 127.1 0 0 0 0 0 0 0 1 0 0 0 80
81 128.5 0 0 0 0 0 0 0 0 1 0 0 81
82 126.6 0 0 0 0 0 0 0 0 0 1 0 82
83 132.6 0 0 0 0 0 0 0 0 0 0 1 83
84 130.9 0 0 0 0 0 0 0 0 0 0 0 84
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) M1 M2 M3 M4 M5
60.777 -2.152 -1.463 4.655 9.873 9.976
M6 M7 M8 M9 M10 M11
13.737 15.083 11.386 7.061 2.665 2.025
t
0.668
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-41.988 -9.459 -3.002 7.544 64.114
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 60.7774 10.2256 5.944 9.48e-08 ***
M1 -2.1517 12.5785 -0.171 0.865
M2 -1.4625 12.5690 -0.116 0.908
M3 4.6551 12.5604 0.371 0.712
M4 9.8728 12.5528 0.787 0.434
M5 9.9762 12.5460 0.795 0.429
M6 13.7368 12.5401 1.095 0.277
M7 15.0830 12.5351 1.203 0.233
M8 11.3864 12.5311 0.909 0.367
M9 7.0612 12.5279 0.564 0.575
M10 2.6646 12.5256 0.213 0.832
M11 2.0252 12.5243 0.162 0.872
t 0.6680 0.1065 6.272 2.47e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 23.43 on 71 degrees of freedom
Multiple R-squared: 0.39, Adjusted R-squared: 0.2869
F-statistic: 3.783 on 12 and 71 DF, p-value: 0.0001902
> 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,] 2.502426e-03 5.004852e-03 9.974976e-01
[2,] 5.194195e-04 1.038839e-03 9.994806e-01
[3,] 6.580111e-05 1.316022e-04 9.999342e-01
[4,] 6.600711e-06 1.320142e-05 9.999934e-01
[5,] 2.199576e-06 4.399152e-06 9.999978e-01
[6,] 1.701833e-05 3.403665e-05 9.999830e-01
[7,] 2.107607e-05 4.215214e-05 9.999789e-01
[8,] 7.964807e-06 1.592961e-05 9.999920e-01
[9,] 2.252176e-06 4.504352e-06 9.999977e-01
[10,] 3.598655e-06 7.197310e-06 9.999964e-01
[11,] 1.303719e-06 2.607437e-06 9.999987e-01
[12,] 4.666531e-07 9.333063e-07 9.999995e-01
[13,] 1.375773e-07 2.751547e-07 9.999999e-01
[14,] 3.629270e-08 7.258539e-08 1.000000e+00
[15,] 8.931712e-09 1.786342e-08 1.000000e+00
[16,] 1.950394e-09 3.900788e-09 1.000000e+00
[17,] 5.549424e-10 1.109885e-09 1.000000e+00
[18,] 1.785586e-10 3.571172e-10 1.000000e+00
[19,] 4.515754e-10 9.031508e-10 1.000000e+00
[20,] 1.283991e-08 2.567983e-08 1.000000e+00
[21,] 2.963239e-08 5.926478e-08 1.000000e+00
[22,] 8.815709e-08 1.763142e-07 9.999999e-01
[23,] 2.627333e-07 5.254666e-07 9.999997e-01
[24,] 1.038326e-06 2.076652e-06 9.999990e-01
[25,] 3.633579e-06 7.267158e-06 9.999964e-01
[26,] 1.437238e-04 2.874476e-04 9.998563e-01
[27,] 6.099730e-03 1.219946e-02 9.939003e-01
[28,] 1.534105e-01 3.068210e-01 8.465895e-01
[29,] 6.109393e-01 7.781215e-01 3.890607e-01
[30,] 9.789984e-01 4.200316e-02 2.100158e-02
[31,] 9.978840e-01 4.232093e-03 2.116046e-03
[32,] 9.993908e-01 1.218355e-03 6.091777e-04
[33,] 9.998426e-01 3.148067e-04 1.574034e-04
[34,] 9.999428e-01 1.143625e-04 5.718124e-05
[35,] 9.999793e-01 4.141515e-05 2.070758e-05
[36,] 9.999947e-01 1.063898e-05 5.319490e-06
[37,] 9.999996e-01 8.915404e-07 4.457702e-07
[38,] 9.999993e-01 1.321056e-06 6.605282e-07
[39,] 9.999986e-01 2.811305e-06 1.405652e-06
[40,] 9.999967e-01 6.699922e-06 3.349961e-06
[41,] 9.999953e-01 9.325229e-06 4.662614e-06
[42,] 9.999903e-01 1.936048e-05 9.680241e-06
[43,] 9.999900e-01 2.002629e-05 1.001315e-05
[44,] 9.999948e-01 1.040867e-05 5.204334e-06
[45,] 9.999970e-01 5.995954e-06 2.997977e-06
[46,] 9.999941e-01 1.177438e-05 5.887189e-06
[47,] 9.999729e-01 5.428710e-05 2.714355e-05
[48,] 9.998917e-01 2.165454e-04 1.082727e-04
[49,] 9.996769e-01 6.462535e-04 3.231267e-04
[50,] 9.992219e-01 1.556300e-03 7.781499e-04
[51,] 9.979739e-01 4.052113e-03 2.026057e-03
[52,] 9.980634e-01 3.873122e-03 1.936561e-03
[53,] 9.919513e-01 1.609743e-02 8.048713e-03
> postscript(file="/var/fisher/rcomp/tmp/1aw091354122898.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/fisher/rcomp/tmp/2fwbf1354122898.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/fisher/rcomp/tmp/3qugt1354122898.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/fisher/rcomp/tmp/44lad1354122898.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/fisher/rcomp/tmp/5tstk1354122898.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 = 84
Frequency = 1
1 2 3 4 5 6
-4.9937500 -4.7508929 -3.5366071 -9.3223214 -13.3937500 -10.7223214
7 8 9 10 11 12
-10.0366071 -0.9080357 2.3491071 1.6776786 -2.3508929 0.9062500
13 14 15 16 17 18
9.3898810 5.5327381 0.3470238 2.9613095 2.7898810 -2.1386905
19 20 21 22 23 24
0.8470238 2.9755952 -5.3672619 -6.7386905 -6.0672619 -1.0101190
25 26 27 28 29 30
-8.7264881 -4.9836310 -8.0693452 -8.4550595 -9.4264881 -9.5550595
31 32 33 34 35 36
-5.0693452 -5.8407738 5.4163690 16.2449405 28.0163690 26.8735119
37 38 39 40 41 42
30.3571429 34.1000000 37.5142857 39.0285714 56.8571429 63.4285714
43 44 45 46 47 48
64.1142857 43.9428571 29.4000000 -2.6714286 -25.2000000 -38.8428571
49 50 51 52 53 54
-35.0592262 -38.5163690 -40.2020833 -41.9877976 -32.8592262 -23.8877976
55 56 57 58 59 60
-31.3020833 -19.9735119 -20.6163690 -9.7877976 -5.4163690 -7.2592262
61 62 63 64 65 66
-1.7755952 -6.5327381 -7.6184524 -7.0041667 -18.1755952 -23.7041667
67 68 69 70 71 72
-25.8184524 -21.6898810 -17.7327381 -7.1041667 -3.3327381 5.3244048
73 74 75 76 77 78
10.8080357 15.1508929 21.5651786 24.7794643 14.2080357 6.5794643
79 80 81 82 83 84
7.2651786 1.4937500 6.5508929 8.3794643 14.3508929 14.0080357
> postscript(file="/var/fisher/rcomp/tmp/6it7t1354122898.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 = 84
Frequency = 1
lag(myerror, k = 1) myerror
0 -4.9937500 NA
1 -4.7508929 -4.9937500
2 -3.5366071 -4.7508929
3 -9.3223214 -3.5366071
4 -13.3937500 -9.3223214
5 -10.7223214 -13.3937500
6 -10.0366071 -10.7223214
7 -0.9080357 -10.0366071
8 2.3491071 -0.9080357
9 1.6776786 2.3491071
10 -2.3508929 1.6776786
11 0.9062500 -2.3508929
12 9.3898810 0.9062500
13 5.5327381 9.3898810
14 0.3470238 5.5327381
15 2.9613095 0.3470238
16 2.7898810 2.9613095
17 -2.1386905 2.7898810
18 0.8470238 -2.1386905
19 2.9755952 0.8470238
20 -5.3672619 2.9755952
21 -6.7386905 -5.3672619
22 -6.0672619 -6.7386905
23 -1.0101190 -6.0672619
24 -8.7264881 -1.0101190
25 -4.9836310 -8.7264881
26 -8.0693452 -4.9836310
27 -8.4550595 -8.0693452
28 -9.4264881 -8.4550595
29 -9.5550595 -9.4264881
30 -5.0693452 -9.5550595
31 -5.8407738 -5.0693452
32 5.4163690 -5.8407738
33 16.2449405 5.4163690
34 28.0163690 16.2449405
35 26.8735119 28.0163690
36 30.3571429 26.8735119
37 34.1000000 30.3571429
38 37.5142857 34.1000000
39 39.0285714 37.5142857
40 56.8571429 39.0285714
41 63.4285714 56.8571429
42 64.1142857 63.4285714
43 43.9428571 64.1142857
44 29.4000000 43.9428571
45 -2.6714286 29.4000000
46 -25.2000000 -2.6714286
47 -38.8428571 -25.2000000
48 -35.0592262 -38.8428571
49 -38.5163690 -35.0592262
50 -40.2020833 -38.5163690
51 -41.9877976 -40.2020833
52 -32.8592262 -41.9877976
53 -23.8877976 -32.8592262
54 -31.3020833 -23.8877976
55 -19.9735119 -31.3020833
56 -20.6163690 -19.9735119
57 -9.7877976 -20.6163690
58 -5.4163690 -9.7877976
59 -7.2592262 -5.4163690
60 -1.7755952 -7.2592262
61 -6.5327381 -1.7755952
62 -7.6184524 -6.5327381
63 -7.0041667 -7.6184524
64 -18.1755952 -7.0041667
65 -23.7041667 -18.1755952
66 -25.8184524 -23.7041667
67 -21.6898810 -25.8184524
68 -17.7327381 -21.6898810
69 -7.1041667 -17.7327381
70 -3.3327381 -7.1041667
71 5.3244048 -3.3327381
72 10.8080357 5.3244048
73 15.1508929 10.8080357
74 21.5651786 15.1508929
75 24.7794643 21.5651786
76 14.2080357 24.7794643
77 6.5794643 14.2080357
78 7.2651786 6.5794643
79 1.4937500 7.2651786
80 6.5508929 1.4937500
81 8.3794643 6.5508929
82 14.3508929 8.3794643
83 14.0080357 14.3508929
84 NA 14.0080357
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.7508929 -4.9937500
[2,] -3.5366071 -4.7508929
[3,] -9.3223214 -3.5366071
[4,] -13.3937500 -9.3223214
[5,] -10.7223214 -13.3937500
[6,] -10.0366071 -10.7223214
[7,] -0.9080357 -10.0366071
[8,] 2.3491071 -0.9080357
[9,] 1.6776786 2.3491071
[10,] -2.3508929 1.6776786
[11,] 0.9062500 -2.3508929
[12,] 9.3898810 0.9062500
[13,] 5.5327381 9.3898810
[14,] 0.3470238 5.5327381
[15,] 2.9613095 0.3470238
[16,] 2.7898810 2.9613095
[17,] -2.1386905 2.7898810
[18,] 0.8470238 -2.1386905
[19,] 2.9755952 0.8470238
[20,] -5.3672619 2.9755952
[21,] -6.7386905 -5.3672619
[22,] -6.0672619 -6.7386905
[23,] -1.0101190 -6.0672619
[24,] -8.7264881 -1.0101190
[25,] -4.9836310 -8.7264881
[26,] -8.0693452 -4.9836310
[27,] -8.4550595 -8.0693452
[28,] -9.4264881 -8.4550595
[29,] -9.5550595 -9.4264881
[30,] -5.0693452 -9.5550595
[31,] -5.8407738 -5.0693452
[32,] 5.4163690 -5.8407738
[33,] 16.2449405 5.4163690
[34,] 28.0163690 16.2449405
[35,] 26.8735119 28.0163690
[36,] 30.3571429 26.8735119
[37,] 34.1000000 30.3571429
[38,] 37.5142857 34.1000000
[39,] 39.0285714 37.5142857
[40,] 56.8571429 39.0285714
[41,] 63.4285714 56.8571429
[42,] 64.1142857 63.4285714
[43,] 43.9428571 64.1142857
[44,] 29.4000000 43.9428571
[45,] -2.6714286 29.4000000
[46,] -25.2000000 -2.6714286
[47,] -38.8428571 -25.2000000
[48,] -35.0592262 -38.8428571
[49,] -38.5163690 -35.0592262
[50,] -40.2020833 -38.5163690
[51,] -41.9877976 -40.2020833
[52,] -32.8592262 -41.9877976
[53,] -23.8877976 -32.8592262
[54,] -31.3020833 -23.8877976
[55,] -19.9735119 -31.3020833
[56,] -20.6163690 -19.9735119
[57,] -9.7877976 -20.6163690
[58,] -5.4163690 -9.7877976
[59,] -7.2592262 -5.4163690
[60,] -1.7755952 -7.2592262
[61,] -6.5327381 -1.7755952
[62,] -7.6184524 -6.5327381
[63,] -7.0041667 -7.6184524
[64,] -18.1755952 -7.0041667
[65,] -23.7041667 -18.1755952
[66,] -25.8184524 -23.7041667
[67,] -21.6898810 -25.8184524
[68,] -17.7327381 -21.6898810
[69,] -7.1041667 -17.7327381
[70,] -3.3327381 -7.1041667
[71,] 5.3244048 -3.3327381
[72,] 10.8080357 5.3244048
[73,] 15.1508929 10.8080357
[74,] 21.5651786 15.1508929
[75,] 24.7794643 21.5651786
[76,] 14.2080357 24.7794643
[77,] 6.5794643 14.2080357
[78,] 7.2651786 6.5794643
[79,] 1.4937500 7.2651786
[80,] 6.5508929 1.4937500
[81,] 8.3794643 6.5508929
[82,] 14.3508929 8.3794643
[83,] 14.0080357 14.3508929
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.7508929 -4.9937500
2 -3.5366071 -4.7508929
3 -9.3223214 -3.5366071
4 -13.3937500 -9.3223214
5 -10.7223214 -13.3937500
6 -10.0366071 -10.7223214
7 -0.9080357 -10.0366071
8 2.3491071 -0.9080357
9 1.6776786 2.3491071
10 -2.3508929 1.6776786
11 0.9062500 -2.3508929
12 9.3898810 0.9062500
13 5.5327381 9.3898810
14 0.3470238 5.5327381
15 2.9613095 0.3470238
16 2.7898810 2.9613095
17 -2.1386905 2.7898810
18 0.8470238 -2.1386905
19 2.9755952 0.8470238
20 -5.3672619 2.9755952
21 -6.7386905 -5.3672619
22 -6.0672619 -6.7386905
23 -1.0101190 -6.0672619
24 -8.7264881 -1.0101190
25 -4.9836310 -8.7264881
26 -8.0693452 -4.9836310
27 -8.4550595 -8.0693452
28 -9.4264881 -8.4550595
29 -9.5550595 -9.4264881
30 -5.0693452 -9.5550595
31 -5.8407738 -5.0693452
32 5.4163690 -5.8407738
33 16.2449405 5.4163690
34 28.0163690 16.2449405
35 26.8735119 28.0163690
36 30.3571429 26.8735119
37 34.1000000 30.3571429
38 37.5142857 34.1000000
39 39.0285714 37.5142857
40 56.8571429 39.0285714
41 63.4285714 56.8571429
42 64.1142857 63.4285714
43 43.9428571 64.1142857
44 29.4000000 43.9428571
45 -2.6714286 29.4000000
46 -25.2000000 -2.6714286
47 -38.8428571 -25.2000000
48 -35.0592262 -38.8428571
49 -38.5163690 -35.0592262
50 -40.2020833 -38.5163690
51 -41.9877976 -40.2020833
52 -32.8592262 -41.9877976
53 -23.8877976 -32.8592262
54 -31.3020833 -23.8877976
55 -19.9735119 -31.3020833
56 -20.6163690 -19.9735119
57 -9.7877976 -20.6163690
58 -5.4163690 -9.7877976
59 -7.2592262 -5.4163690
60 -1.7755952 -7.2592262
61 -6.5327381 -1.7755952
62 -7.6184524 -6.5327381
63 -7.0041667 -7.6184524
64 -18.1755952 -7.0041667
65 -23.7041667 -18.1755952
66 -25.8184524 -23.7041667
67 -21.6898810 -25.8184524
68 -17.7327381 -21.6898810
69 -7.1041667 -17.7327381
70 -3.3327381 -7.1041667
71 5.3244048 -3.3327381
72 10.8080357 5.3244048
73 15.1508929 10.8080357
74 21.5651786 15.1508929
75 24.7794643 21.5651786
76 14.2080357 24.7794643
77 6.5794643 14.2080357
78 7.2651786 6.5794643
79 1.4937500 7.2651786
80 6.5508929 1.4937500
81 8.3794643 6.5508929
82 14.3508929 8.3794643
83 14.0080357 14.3508929
> 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/fisher/rcomp/tmp/78s2h1354122898.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/fisher/rcomp/tmp/8d8vm1354122899.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/fisher/rcomp/tmp/9nie31354122899.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/fisher/rcomp/tmp/10194f1354122899.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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/fisher/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/fisher/rcomp/tmp/11u8lc1354122899.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/fisher/rcomp/tmp/125q9b1354122899.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/fisher/rcomp/tmp/13pouk1354122899.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/fisher/rcomp/tmp/14gis51354122899.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/fisher/rcomp/tmp/156idq1354122899.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/fisher/rcomp/tmp/1635zr1354122899.tab")
+ }
>
> try(system("convert tmp/1aw091354122898.ps tmp/1aw091354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/2fwbf1354122898.ps tmp/2fwbf1354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/3qugt1354122898.ps tmp/3qugt1354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/44lad1354122898.ps tmp/44lad1354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/5tstk1354122898.ps tmp/5tstk1354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/6it7t1354122898.ps tmp/6it7t1354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/78s2h1354122898.ps tmp/78s2h1354122898.png",intern=TRUE))
character(0)
> try(system("convert tmp/8d8vm1354122899.ps tmp/8d8vm1354122899.png",intern=TRUE))
character(0)
> try(system("convert tmp/9nie31354122899.ps tmp/9nie31354122899.png",intern=TRUE))
character(0)
> try(system("convert tmp/10194f1354122899.ps tmp/10194f1354122899.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.838 1.581 8.413