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(101.02,0,100.67,0,100.47,0,100.38,0,100.33,0,100.34,0,100.37,0,100.39,0,100.21,0,100.21,0,100.22,0,100.28,0,100.25,0,100.25,0,100.21,0,100.16,0,100.18,0,100.1,1,99.96,1,99.88,1,99.88,1,99.86,1,99.84,1,99.8,1,99.82,1,99.81,1,99.92,1,100.03,1,99.99,1,100.02,1,100.01,1,100.13,1,100.33,1,100.13,1,99.96,1,100.05,1,99.83,1,99.8,1,100.01,1,100.1,1,100.13,1,100.16,1,100.41,1,101.34,1,101.65,1,101.85,1,102.07,1,102.12,1,102.14,1,102.21,1,102.28,1,102.19,1,102.33,1,102.54,1,102.44,1,102.78,1,102.9,1,103.08,1,102.77,1,102.65,1,102.71,1,103.29,1,102.86,1,103.45,1,103.72,1,103.65,1,103.83,1,104.45,1,105.14,1,105.07,1,105.31,1,105.19,1,105.3,1,105.02,1,105.17,1,105.28,1,105.45,1,105.38,1,105.8,1,105.96,1,105.08,1,105.11,1,105.61,1,105.5,1),dim=c(2,84),dimnames=list(c('Suiker','Dummy'),1:84))
> y <- array(NA,dim=c(2,84),dimnames=list(c('Suiker','Dummy'),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'
> #'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
Suiker Dummy M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 101.02 0 1 0 0 0 0 0 0 0 0 0 0 1
2 100.67 0 0 1 0 0 0 0 0 0 0 0 0 2
3 100.47 0 0 0 1 0 0 0 0 0 0 0 0 3
4 100.38 0 0 0 0 1 0 0 0 0 0 0 0 4
5 100.33 0 0 0 0 0 1 0 0 0 0 0 0 5
6 100.34 0 0 0 0 0 0 1 0 0 0 0 0 6
7 100.37 0 0 0 0 0 0 0 1 0 0 0 0 7
8 100.39 0 0 0 0 0 0 0 0 1 0 0 0 8
9 100.21 0 0 0 0 0 0 0 0 0 1 0 0 9
10 100.21 0 0 0 0 0 0 0 0 0 0 1 0 10
11 100.22 0 0 0 0 0 0 0 0 0 0 0 1 11
12 100.28 0 0 0 0 0 0 0 0 0 0 0 0 12
13 100.25 0 1 0 0 0 0 0 0 0 0 0 0 13
14 100.25 0 0 1 0 0 0 0 0 0 0 0 0 14
15 100.21 0 0 0 1 0 0 0 0 0 0 0 0 15
16 100.16 0 0 0 0 1 0 0 0 0 0 0 0 16
17 100.18 0 0 0 0 0 1 0 0 0 0 0 0 17
18 100.10 1 0 0 0 0 0 1 0 0 0 0 0 18
19 99.96 1 0 0 0 0 0 0 1 0 0 0 0 19
20 99.88 1 0 0 0 0 0 0 0 1 0 0 0 20
21 99.88 1 0 0 0 0 0 0 0 0 1 0 0 21
22 99.86 1 0 0 0 0 0 0 0 0 0 1 0 22
23 99.84 1 0 0 0 0 0 0 0 0 0 0 1 23
24 99.80 1 0 0 0 0 0 0 0 0 0 0 0 24
25 99.82 1 1 0 0 0 0 0 0 0 0 0 0 25
26 99.81 1 0 1 0 0 0 0 0 0 0 0 0 26
27 99.92 1 0 0 1 0 0 0 0 0 0 0 0 27
28 100.03 1 0 0 0 1 0 0 0 0 0 0 0 28
29 99.99 1 0 0 0 0 1 0 0 0 0 0 0 29
30 100.02 1 0 0 0 0 0 1 0 0 0 0 0 30
31 100.01 1 0 0 0 0 0 0 1 0 0 0 0 31
32 100.13 1 0 0 0 0 0 0 0 1 0 0 0 32
33 100.33 1 0 0 0 0 0 0 0 0 1 0 0 33
34 100.13 1 0 0 0 0 0 0 0 0 0 1 0 34
35 99.96 1 0 0 0 0 0 0 0 0 0 0 1 35
36 100.05 1 0 0 0 0 0 0 0 0 0 0 0 36
37 99.83 1 1 0 0 0 0 0 0 0 0 0 0 37
38 99.80 1 0 1 0 0 0 0 0 0 0 0 0 38
39 100.01 1 0 0 1 0 0 0 0 0 0 0 0 39
40 100.10 1 0 0 0 1 0 0 0 0 0 0 0 40
41 100.13 1 0 0 0 0 1 0 0 0 0 0 0 41
42 100.16 1 0 0 0 0 0 1 0 0 0 0 0 42
43 100.41 1 0 0 0 0 0 0 1 0 0 0 0 43
44 101.34 1 0 0 0 0 0 0 0 1 0 0 0 44
45 101.65 1 0 0 0 0 0 0 0 0 1 0 0 45
46 101.85 1 0 0 0 0 0 0 0 0 0 1 0 46
47 102.07 1 0 0 0 0 0 0 0 0 0 0 1 47
48 102.12 1 0 0 0 0 0 0 0 0 0 0 0 48
49 102.14 1 1 0 0 0 0 0 0 0 0 0 0 49
50 102.21 1 0 1 0 0 0 0 0 0 0 0 0 50
51 102.28 1 0 0 1 0 0 0 0 0 0 0 0 51
52 102.19 1 0 0 0 1 0 0 0 0 0 0 0 52
53 102.33 1 0 0 0 0 1 0 0 0 0 0 0 53
54 102.54 1 0 0 0 0 0 1 0 0 0 0 0 54
55 102.44 1 0 0 0 0 0 0 1 0 0 0 0 55
56 102.78 1 0 0 0 0 0 0 0 1 0 0 0 56
57 102.90 1 0 0 0 0 0 0 0 0 1 0 0 57
58 103.08 1 0 0 0 0 0 0 0 0 0 1 0 58
59 102.77 1 0 0 0 0 0 0 0 0 0 0 1 59
60 102.65 1 0 0 0 0 0 0 0 0 0 0 0 60
61 102.71 1 1 0 0 0 0 0 0 0 0 0 0 61
62 103.29 1 0 1 0 0 0 0 0 0 0 0 0 62
63 102.86 1 0 0 1 0 0 0 0 0 0 0 0 63
64 103.45 1 0 0 0 1 0 0 0 0 0 0 0 64
65 103.72 1 0 0 0 0 1 0 0 0 0 0 0 65
66 103.65 1 0 0 0 0 0 1 0 0 0 0 0 66
67 103.83 1 0 0 0 0 0 0 1 0 0 0 0 67
68 104.45 1 0 0 0 0 0 0 0 1 0 0 0 68
69 105.14 1 0 0 0 0 0 0 0 0 1 0 0 69
70 105.07 1 0 0 0 0 0 0 0 0 0 1 0 70
71 105.31 1 0 0 0 0 0 0 0 0 0 0 1 71
72 105.19 1 0 0 0 0 0 0 0 0 0 0 0 72
73 105.30 1 1 0 0 0 0 0 0 0 0 0 0 73
74 105.02 1 0 1 0 0 0 0 0 0 0 0 0 74
75 105.17 1 0 0 1 0 0 0 0 0 0 0 0 75
76 105.28 1 0 0 0 1 0 0 0 0 0 0 0 76
77 105.45 1 0 0 0 0 1 0 0 0 0 0 0 77
78 105.38 1 0 0 0 0 0 1 0 0 0 0 0 78
79 105.80 1 0 0 0 0 0 0 1 0 0 0 0 79
80 105.96 1 0 0 0 0 0 0 0 1 0 0 0 80
81 105.08 1 0 0 0 0 0 0 0 0 1 0 0 81
82 105.11 1 0 0 0 0 0 0 0 0 0 1 0 82
83 105.61 1 0 0 0 0 0 0 0 0 0 0 1 83
84 105.50 1 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) Dummy M1 M2 M3 M4
99.35610 -2.49431 0.14586 0.03865 -0.08428 -0.09292
M5 M6 M7 M8 M9 M10
-0.12013 0.14041 0.12606 0.32313 0.25592 0.16871
M11 t
0.13150 0.10435
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.22510 -0.42075 -0.00419 0.42845 1.41369
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 99.356097 0.283309 350.699 < 2e-16 ***
Dummy -2.494313 0.239469 -10.416 7.14e-16 ***
M1 0.145858 0.336383 0.434 0.666
M2 0.038646 0.336175 0.115 0.909
M3 -0.084280 0.336013 -0.251 0.803
M4 -0.092921 0.335897 -0.277 0.783
M5 -0.120133 0.335827 -0.358 0.722
M6 0.140414 0.335731 0.418 0.677
M7 0.126060 0.335476 0.376 0.708
M8 0.323133 0.335267 0.964 0.338
M9 0.255921 0.335105 0.764 0.448
M10 0.168710 0.334988 0.504 0.616
M11 0.131498 0.334919 0.393 0.696
t 0.104355 0.003947 26.440 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.6265 on 70 degrees of freedom
Multiple R-squared: 0.9226, Adjusted R-squared: 0.9082
F-statistic: 64.17 on 13 and 70 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,] 4.739463e-02 9.478926e-02 0.9526054
[2,] 1.573572e-02 3.147145e-02 0.9842643
[3,] 5.752186e-03 1.150437e-02 0.9942478
[4,] 2.084929e-03 4.169858e-03 0.9979151
[5,] 6.138618e-04 1.227724e-03 0.9993861
[6,] 1.741581e-04 3.483162e-04 0.9998258
[7,] 4.732981e-05 9.465963e-05 0.9999527
[8,] 1.549691e-05 3.099382e-05 0.9999845
[9,] 1.190542e-05 2.381085e-05 0.9999881
[10,] 3.555908e-06 7.111815e-06 0.9999964
[11,] 2.488616e-06 4.977233e-06 0.9999975
[12,] 6.364517e-06 1.272903e-05 0.9999936
[13,] 6.966196e-06 1.393239e-05 0.9999930
[14,] 8.902625e-06 1.780525e-05 0.9999911
[15,] 9.555909e-06 1.911182e-05 0.9999904
[16,] 1.560629e-05 3.121258e-05 0.9999844
[17,] 1.204992e-04 2.409984e-04 0.9998795
[18,] 1.147163e-04 2.294326e-04 0.9998853
[19,] 5.712757e-05 1.142551e-04 0.9999429
[20,] 3.208227e-05 6.416454e-05 0.9999679
[21,] 2.196649e-05 4.393299e-05 0.9999780
[22,] 1.406249e-05 2.812499e-05 0.9999859
[23,] 7.476395e-06 1.495279e-05 0.9999925
[24,] 5.655369e-06 1.131074e-05 0.9999943
[25,] 6.532460e-06 1.306492e-05 0.9999935
[26,] 6.880090e-06 1.376018e-05 0.9999931
[27,] 1.917682e-05 3.835365e-05 0.9999808
[28,] 3.223316e-03 6.446631e-03 0.9967767
[29,] 4.420732e-02 8.841465e-02 0.9557927
[30,] 1.807085e-01 3.614170e-01 0.8192915
[31,] 3.980896e-01 7.961792e-01 0.6019104
[32,] 5.668455e-01 8.663090e-01 0.4331545
[33,] 6.093474e-01 7.813051e-01 0.3906526
[34,] 6.410887e-01 7.178227e-01 0.3589113
[35,] 6.699361e-01 6.601279e-01 0.3300639
[36,] 6.443423e-01 7.113153e-01 0.3556577
[37,] 6.208307e-01 7.583385e-01 0.3791693
[38,] 5.764898e-01 8.470204e-01 0.4235102
[39,] 5.096136e-01 9.807728e-01 0.4903864
[40,] 4.455106e-01 8.910213e-01 0.5544894
[41,] 3.748610e-01 7.497220e-01 0.6251390
[42,] 3.173680e-01 6.347360e-01 0.6826320
[43,] 2.672148e-01 5.344297e-01 0.7327852
[44,] 2.284453e-01 4.568907e-01 0.7715547
[45,] 2.824005e-01 5.648009e-01 0.7175995
[46,] 2.345655e-01 4.691310e-01 0.7654345
[47,] 2.788654e-01 5.577308e-01 0.7211346
[48,] 2.688560e-01 5.377119e-01 0.7311440
[49,] 2.645973e-01 5.291946e-01 0.7354027
[50,] 2.684346e-01 5.368693e-01 0.7315654
[51,] 5.021870e-01 9.956260e-01 0.4978130
> postscript(file="/var/www/html/freestat/rcomp/tmp/13pm01229364992.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/freestat/rcomp/tmp/26c361229364992.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/freestat/rcomp/tmp/3bh6d1229364992.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/freestat/rcomp/tmp/41kjs1229364992.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/freestat/rcomp/tmp/54clj1229364992.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 = 84
Frequency = 1
1 2 3 4 5 6
1.413690683 1.066547826 0.885119255 0.699404969 0.572262112 0.217360248
7 8 9 10 11 12
0.157360248 -0.124068323 -0.341211180 -0.358354037 -0.415496894 -0.328354037
13 14 15 16 17 18
-0.608566460 -0.605709317 -0.627137888 -0.772852174 -0.829995031 1.219416149
19 20 21 22 23 24
0.989416149 0.607987578 0.570844720 0.533701863 0.446559006 0.433701863
25 26 27 28 29 30
0.203489441 0.196346584 0.324918012 0.339203727 0.222060870 -0.112840994
31 32 33 34 35 36
-0.212840994 -0.394269565 -0.231412422 -0.448555280 -0.685698137 -0.568555280
37 38 39 40 41 42
-1.038767702 -1.065910559 -0.837339130 -0.843053416 -0.890196273 -1.225098137
43 44 45 46 47 48
-1.065098137 -0.436526708 -0.163669565 0.019187578 0.172044720 0.249187578
49 50 51 52 53 54
0.018975155 0.091832298 0.180403727 -0.005310559 0.057546584 -0.097355280
55 56 57 58 59 60
-0.287355280 -0.248783851 -0.165926708 -0.003069565 -0.380212422 -0.473069565
61 62 63 64 65 66
-0.663281988 -0.080424845 -0.491853416 0.002432298 0.195289441 -0.239612422
67 68 69 70 71 72
-0.149612422 0.168959006 0.821816149 0.734673292 0.907530435 0.814673292
73 74 75 76 77 78
0.674460870 0.397318012 0.565889441 0.580175155 0.673032298 0.238130435
79 80 81 82 83 84
0.568130435 0.426701863 -0.490440994 -0.477583851 -0.044726708 -0.127583851
> postscript(file="/var/www/html/freestat/rcomp/tmp/648va1229364992.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 = 84
Frequency = 1
lag(myerror, k = 1) myerror
0 1.413690683 NA
1 1.066547826 1.413690683
2 0.885119255 1.066547826
3 0.699404969 0.885119255
4 0.572262112 0.699404969
5 0.217360248 0.572262112
6 0.157360248 0.217360248
7 -0.124068323 0.157360248
8 -0.341211180 -0.124068323
9 -0.358354037 -0.341211180
10 -0.415496894 -0.358354037
11 -0.328354037 -0.415496894
12 -0.608566460 -0.328354037
13 -0.605709317 -0.608566460
14 -0.627137888 -0.605709317
15 -0.772852174 -0.627137888
16 -0.829995031 -0.772852174
17 1.219416149 -0.829995031
18 0.989416149 1.219416149
19 0.607987578 0.989416149
20 0.570844720 0.607987578
21 0.533701863 0.570844720
22 0.446559006 0.533701863
23 0.433701863 0.446559006
24 0.203489441 0.433701863
25 0.196346584 0.203489441
26 0.324918012 0.196346584
27 0.339203727 0.324918012
28 0.222060870 0.339203727
29 -0.112840994 0.222060870
30 -0.212840994 -0.112840994
31 -0.394269565 -0.212840994
32 -0.231412422 -0.394269565
33 -0.448555280 -0.231412422
34 -0.685698137 -0.448555280
35 -0.568555280 -0.685698137
36 -1.038767702 -0.568555280
37 -1.065910559 -1.038767702
38 -0.837339130 -1.065910559
39 -0.843053416 -0.837339130
40 -0.890196273 -0.843053416
41 -1.225098137 -0.890196273
42 -1.065098137 -1.225098137
43 -0.436526708 -1.065098137
44 -0.163669565 -0.436526708
45 0.019187578 -0.163669565
46 0.172044720 0.019187578
47 0.249187578 0.172044720
48 0.018975155 0.249187578
49 0.091832298 0.018975155
50 0.180403727 0.091832298
51 -0.005310559 0.180403727
52 0.057546584 -0.005310559
53 -0.097355280 0.057546584
54 -0.287355280 -0.097355280
55 -0.248783851 -0.287355280
56 -0.165926708 -0.248783851
57 -0.003069565 -0.165926708
58 -0.380212422 -0.003069565
59 -0.473069565 -0.380212422
60 -0.663281988 -0.473069565
61 -0.080424845 -0.663281988
62 -0.491853416 -0.080424845
63 0.002432298 -0.491853416
64 0.195289441 0.002432298
65 -0.239612422 0.195289441
66 -0.149612422 -0.239612422
67 0.168959006 -0.149612422
68 0.821816149 0.168959006
69 0.734673292 0.821816149
70 0.907530435 0.734673292
71 0.814673292 0.907530435
72 0.674460870 0.814673292
73 0.397318012 0.674460870
74 0.565889441 0.397318012
75 0.580175155 0.565889441
76 0.673032298 0.580175155
77 0.238130435 0.673032298
78 0.568130435 0.238130435
79 0.426701863 0.568130435
80 -0.490440994 0.426701863
81 -0.477583851 -0.490440994
82 -0.044726708 -0.477583851
83 -0.127583851 -0.044726708
84 NA -0.127583851
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.066547826 1.413690683
[2,] 0.885119255 1.066547826
[3,] 0.699404969 0.885119255
[4,] 0.572262112 0.699404969
[5,] 0.217360248 0.572262112
[6,] 0.157360248 0.217360248
[7,] -0.124068323 0.157360248
[8,] -0.341211180 -0.124068323
[9,] -0.358354037 -0.341211180
[10,] -0.415496894 -0.358354037
[11,] -0.328354037 -0.415496894
[12,] -0.608566460 -0.328354037
[13,] -0.605709317 -0.608566460
[14,] -0.627137888 -0.605709317
[15,] -0.772852174 -0.627137888
[16,] -0.829995031 -0.772852174
[17,] 1.219416149 -0.829995031
[18,] 0.989416149 1.219416149
[19,] 0.607987578 0.989416149
[20,] 0.570844720 0.607987578
[21,] 0.533701863 0.570844720
[22,] 0.446559006 0.533701863
[23,] 0.433701863 0.446559006
[24,] 0.203489441 0.433701863
[25,] 0.196346584 0.203489441
[26,] 0.324918012 0.196346584
[27,] 0.339203727 0.324918012
[28,] 0.222060870 0.339203727
[29,] -0.112840994 0.222060870
[30,] -0.212840994 -0.112840994
[31,] -0.394269565 -0.212840994
[32,] -0.231412422 -0.394269565
[33,] -0.448555280 -0.231412422
[34,] -0.685698137 -0.448555280
[35,] -0.568555280 -0.685698137
[36,] -1.038767702 -0.568555280
[37,] -1.065910559 -1.038767702
[38,] -0.837339130 -1.065910559
[39,] -0.843053416 -0.837339130
[40,] -0.890196273 -0.843053416
[41,] -1.225098137 -0.890196273
[42,] -1.065098137 -1.225098137
[43,] -0.436526708 -1.065098137
[44,] -0.163669565 -0.436526708
[45,] 0.019187578 -0.163669565
[46,] 0.172044720 0.019187578
[47,] 0.249187578 0.172044720
[48,] 0.018975155 0.249187578
[49,] 0.091832298 0.018975155
[50,] 0.180403727 0.091832298
[51,] -0.005310559 0.180403727
[52,] 0.057546584 -0.005310559
[53,] -0.097355280 0.057546584
[54,] -0.287355280 -0.097355280
[55,] -0.248783851 -0.287355280
[56,] -0.165926708 -0.248783851
[57,] -0.003069565 -0.165926708
[58,] -0.380212422 -0.003069565
[59,] -0.473069565 -0.380212422
[60,] -0.663281988 -0.473069565
[61,] -0.080424845 -0.663281988
[62,] -0.491853416 -0.080424845
[63,] 0.002432298 -0.491853416
[64,] 0.195289441 0.002432298
[65,] -0.239612422 0.195289441
[66,] -0.149612422 -0.239612422
[67,] 0.168959006 -0.149612422
[68,] 0.821816149 0.168959006
[69,] 0.734673292 0.821816149
[70,] 0.907530435 0.734673292
[71,] 0.814673292 0.907530435
[72,] 0.674460870 0.814673292
[73,] 0.397318012 0.674460870
[74,] 0.565889441 0.397318012
[75,] 0.580175155 0.565889441
[76,] 0.673032298 0.580175155
[77,] 0.238130435 0.673032298
[78,] 0.568130435 0.238130435
[79,] 0.426701863 0.568130435
[80,] -0.490440994 0.426701863
[81,] -0.477583851 -0.490440994
[82,] -0.044726708 -0.477583851
[83,] -0.127583851 -0.044726708
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.066547826 1.413690683
2 0.885119255 1.066547826
3 0.699404969 0.885119255
4 0.572262112 0.699404969
5 0.217360248 0.572262112
6 0.157360248 0.217360248
7 -0.124068323 0.157360248
8 -0.341211180 -0.124068323
9 -0.358354037 -0.341211180
10 -0.415496894 -0.358354037
11 -0.328354037 -0.415496894
12 -0.608566460 -0.328354037
13 -0.605709317 -0.608566460
14 -0.627137888 -0.605709317
15 -0.772852174 -0.627137888
16 -0.829995031 -0.772852174
17 1.219416149 -0.829995031
18 0.989416149 1.219416149
19 0.607987578 0.989416149
20 0.570844720 0.607987578
21 0.533701863 0.570844720
22 0.446559006 0.533701863
23 0.433701863 0.446559006
24 0.203489441 0.433701863
25 0.196346584 0.203489441
26 0.324918012 0.196346584
27 0.339203727 0.324918012
28 0.222060870 0.339203727
29 -0.112840994 0.222060870
30 -0.212840994 -0.112840994
31 -0.394269565 -0.212840994
32 -0.231412422 -0.394269565
33 -0.448555280 -0.231412422
34 -0.685698137 -0.448555280
35 -0.568555280 -0.685698137
36 -1.038767702 -0.568555280
37 -1.065910559 -1.038767702
38 -0.837339130 -1.065910559
39 -0.843053416 -0.837339130
40 -0.890196273 -0.843053416
41 -1.225098137 -0.890196273
42 -1.065098137 -1.225098137
43 -0.436526708 -1.065098137
44 -0.163669565 -0.436526708
45 0.019187578 -0.163669565
46 0.172044720 0.019187578
47 0.249187578 0.172044720
48 0.018975155 0.249187578
49 0.091832298 0.018975155
50 0.180403727 0.091832298
51 -0.005310559 0.180403727
52 0.057546584 -0.005310559
53 -0.097355280 0.057546584
54 -0.287355280 -0.097355280
55 -0.248783851 -0.287355280
56 -0.165926708 -0.248783851
57 -0.003069565 -0.165926708
58 -0.380212422 -0.003069565
59 -0.473069565 -0.380212422
60 -0.663281988 -0.473069565
61 -0.080424845 -0.663281988
62 -0.491853416 -0.080424845
63 0.002432298 -0.491853416
64 0.195289441 0.002432298
65 -0.239612422 0.195289441
66 -0.149612422 -0.239612422
67 0.168959006 -0.149612422
68 0.821816149 0.168959006
69 0.734673292 0.821816149
70 0.907530435 0.734673292
71 0.814673292 0.907530435
72 0.674460870 0.814673292
73 0.397318012 0.674460870
74 0.565889441 0.397318012
75 0.580175155 0.565889441
76 0.673032298 0.580175155
77 0.238130435 0.673032298
78 0.568130435 0.238130435
79 0.426701863 0.568130435
80 -0.490440994 0.426701863
81 -0.477583851 -0.490440994
82 -0.044726708 -0.477583851
83 -0.127583851 -0.044726708
> 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/freestat/rcomp/tmp/7nlrg1229364992.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/freestat/rcomp/tmp/841nb1229364992.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/freestat/rcomp/tmp/9dghx1229364992.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/freestat/rcomp/tmp/10282k1229364992.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11kz5o1229364992.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/freestat/rcomp/tmp/12yym91229364992.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/freestat/rcomp/tmp/135q501229364992.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/freestat/rcomp/tmp/14eo4d1229364992.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/freestat/rcomp/tmp/157i7x1229364992.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/freestat/rcomp/tmp/1643391229364992.tab")
+ }
>
> system("convert tmp/13pm01229364992.ps tmp/13pm01229364992.png")
> system("convert tmp/26c361229364992.ps tmp/26c361229364992.png")
> system("convert tmp/3bh6d1229364992.ps tmp/3bh6d1229364992.png")
> system("convert tmp/41kjs1229364992.ps tmp/41kjs1229364992.png")
> system("convert tmp/54clj1229364992.ps tmp/54clj1229364992.png")
> system("convert tmp/648va1229364992.ps tmp/648va1229364992.png")
> system("convert tmp/7nlrg1229364992.ps tmp/7nlrg1229364992.png")
> system("convert tmp/841nb1229364992.ps tmp/841nb1229364992.png")
> system("convert tmp/9dghx1229364992.ps tmp/9dghx1229364992.png")
> system("convert tmp/10282k1229364992.ps tmp/10282k1229364992.png")
>
>
> proc.time()
user system elapsed
4.105 2.563 5.007