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(7.5,0,7.2,0,6.9,0,6.7,0,6.4,0,6.3,0,6.8,0,7.3,0,7.1,0,7.1,0,6.8,0,6.5,0,6.3,0,6.1,0,6.1,0,6.3,0,6.3,0,6.0,0,6.2,0,6.4,0,6.8,0,7.5,0,7.5,0,7.6,0,7.6,0,7.4,0,7.3,0,7.1,0,6.9,0,6.8,0,7.5,0,7.6,0,7.8,0,8.0,0,8.1,0,8.2,0,8.3,0,8.2,0,8.0,0,7.9,0,7.6,0,7.6,0,8.2,0,8.3,0,8.4,0,8.4,0,8.4,0,8.6,0,8.9,0,8.8,0,8.3,0,7.5,0,7.2,0,7.5,0,8.8,0,9.3,0,9.3,0,8.7,1,8.2,1,8.3,1,8.5,1,8.6,1,8.6,1,8.2,1,8.1,1,8.0,1,8.6,1,8.7,1,8.8,1,8.5,1,8.4,1,8.5,1,8.7,1,8.7,1,8.6,1,8.5,1,8.3,1,8.1,1,8.2,1,8.1,1,8.1,1,7.9,1,7.9,1,7.9,1,8.0,1,8.0,1,7.9,1,8.0,1,7.7,1,7.2,1,7.5,1,7.3,1,7.0,1,7.0,1,7.0,1,7.2,1,7.3,1,7.1,1,6.8,1,6.6,1,6.2,1,6.2,1,6.8,1,6.9,1),dim=c(2,104),dimnames=list(c('W','D'),1:104))
> y <- array(NA,dim=c(2,104),dimnames=list(c('W','D'),1:104))
> 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
W D M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 7.5 0 1 0 0 0 0 0 0 0 0 0 0 1
2 7.2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 1 0 1 0 0 0 0 0 0 0 0 0 98
99 6.8 1 0 0 1 0 0 0 0 0 0 0 0 99
100 6.6 1 0 0 0 1 0 0 0 0 0 0 0 100
101 6.2 1 0 0 0 0 1 0 0 0 0 0 0 101
102 6.2 1 0 0 0 0 0 1 0 0 0 0 0 102
103 6.8 1 0 0 0 0 0 0 1 0 0 0 0 103
104 6.9 1 0 0 0 0 0 0 0 1 0 0 0 104
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) D M1 M2 M3 M4
7.36408 -0.14992 0.09360 -0.02789 -0.21606 -0.41533
M5 M6 M7 M8 M9 M10
-0.65905 -0.78055 -0.24649 -0.11244 0.07492 0.05827
M11 t
-0.05211 0.01039
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.404156 -0.416194 0.004704 0.564045 1.466702
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.364085 0.318857 23.095 <2e-16 ***
D -0.149919 0.306007 -0.490 0.6254
M1 0.093604 0.378383 0.247 0.8052
M2 -0.027894 0.378274 -0.074 0.9414
M3 -0.216058 0.378233 -0.571 0.5693
M4 -0.415333 0.378260 -1.098 0.2751
M5 -0.659053 0.378355 -1.742 0.0849 .
M6 -0.780551 0.378518 -2.062 0.0421 *
M7 -0.246493 0.378749 -0.651 0.5168
M8 -0.112435 0.379048 -0.297 0.7674
M9 0.074920 0.389982 0.192 0.8481
M10 0.058273 0.389232 0.150 0.8813
M11 -0.052113 0.389132 -0.134 0.8938
t 0.010387 0.005074 2.047 0.0436 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.7782 on 90 degrees of freedom
Multiple R-squared: 0.2061, Adjusted R-squared: 0.09146
F-statistic: 1.798 on 13 and 90 DF, p-value: 0.0553
> 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.15377114 0.3075422798 0.8462288601
[2,] 0.08949549 0.1789909811 0.9105045094
[3,] 0.04541558 0.0908311679 0.9545844160
[4,] 0.02734100 0.0546820053 0.9726589974
[5,] 0.02025813 0.0405162533 0.9797418733
[6,] 0.05731934 0.1146386730 0.9426806635
[7,] 0.14103301 0.2820660249 0.8589669876
[8,] 0.32542748 0.6508549526 0.6745725237
[9,] 0.43188079 0.8637615890 0.5681192055
[10,] 0.51149655 0.9770069056 0.4885034528
[11,] 0.56987335 0.8602533090 0.4301266545
[12,] 0.58461316 0.8307736752 0.4153868376
[13,] 0.59528287 0.8094342516 0.4047171258
[14,] 0.63246252 0.7350749667 0.3675374833
[15,] 0.71574741 0.5685051706 0.2842525853
[16,] 0.77106282 0.4578743630 0.2289371815
[17,] 0.82558262 0.3488347655 0.1744173828
[18,] 0.81175293 0.3764941306 0.1882470653
[19,] 0.80257681 0.3948463850 0.1974231925
[20,] 0.81363499 0.3727300125 0.1863650063
[21,] 0.81528520 0.3694295949 0.1847147975
[22,] 0.83308823 0.3338235344 0.1669117672
[23,] 0.84526062 0.3094787568 0.1547393784
[24,] 0.84173261 0.3165347763 0.1582673882
[25,] 0.83893288 0.3221342405 0.1610671202
[26,] 0.83907560 0.3218488097 0.1609244048
[27,] 0.84948107 0.3010378594 0.1505189297
[28,] 0.85308728 0.2938254459 0.1469127230
[29,] 0.85039242 0.2992151603 0.1496075802
[30,] 0.81289796 0.3742040801 0.1871020400
[31,] 0.76583523 0.4683295391 0.2341647695
[32,] 0.71782715 0.5643457006 0.2821728503
[33,] 0.67358567 0.6528286530 0.3264143265
[34,] 0.63051579 0.7389684251 0.3694842126
[35,] 0.57512385 0.8497522948 0.4248761474
[36,] 0.70888771 0.5822245739 0.2911122869
[37,] 0.89694281 0.2061143845 0.1030571922
[38,] 0.95926966 0.0814606863 0.0407303432
[39,] 0.96069358 0.0786128403 0.0393064202
[40,] 0.95870526 0.0825894808 0.0412947404
[41,] 0.95072373 0.0985525362 0.0492762681
[42,] 0.93417384 0.1316523186 0.0658261593
[43,] 0.95005882 0.0998823670 0.0499411835
[44,] 0.96609090 0.0678182017 0.0339091009
[45,] 0.97846656 0.0430668808 0.0215334404
[46,] 0.98352676 0.0329464732 0.0164732366
[47,] 0.98484039 0.0303192206 0.0151596103
[48,] 0.99633771 0.0073245858 0.0036622929
[49,] 0.99907862 0.0018427693 0.0009213847
[50,] 0.99979537 0.0004092686 0.0002046343
[51,] 0.99987621 0.0002475719 0.0001237860
[52,] 0.99986932 0.0002613574 0.0001306787
[53,] 0.99971852 0.0005629648 0.0002814824
[54,] 0.99956773 0.0008645434 0.0004322717
[55,] 0.99948043 0.0010391452 0.0005195726
[56,] 0.99939558 0.0012088301 0.0006044151
[57,] 0.99910195 0.0017960992 0.0008980496
[58,] 0.99832068 0.0033586322 0.0016793161
[59,] 0.99656809 0.0068638156 0.0034319078
[60,] 0.99342477 0.0131504695 0.0065752347
[61,] 0.98732285 0.0253543004 0.0126771502
[62,] 0.97754205 0.0449159068 0.0224579534
[63,] 0.97270736 0.0545852730 0.0272926365
[64,] 0.97840247 0.0431950589 0.0215975294
[65,] 0.97046341 0.0590731819 0.0295365909
[66,] 0.95902589 0.0819482202 0.0409741101
[67,] 0.93542669 0.1291466104 0.0645733052
[68,] 0.90982765 0.1803446906 0.0901723453
[69,] 0.87529956 0.2494008721 0.1247004361
[70,] 0.79048415 0.4190317090 0.2095158545
[71,] 0.65287300 0.6942540060 0.3471270030
> postscript(file="/var/www/html/rcomp/tmp/1jr6z1227785587.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/2owx21227785587.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/3adr11227785587.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/4h7e81227785587.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/5if2a1227785587.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 = 104
Frequency = 1
1 2 3 4 5 6
0.031924808 -0.156964081 -0.279186303 -0.290297414 -0.356964081 -0.345852970
7 8 9 10 11 12
-0.390297414 -0.034741859 -0.432483578 -0.426223511 -0.626223511 -0.988723511
13 14 15 16 17 18
-1.292714112 -1.381603001 -1.203825224 -0.814936335 -0.581603001 -0.770491890
19 20 21 22 23 24
-1.114936335 -1.059380779 -0.857122499 -0.150862432 -0.050862432 -0.013362432
25 26 27 28 29 30
-0.117353033 -0.206241922 -0.128464144 -0.139575255 -0.106241922 -0.095130811
31 32 33 34 35 36
0.060424745 0.015980301 0.018238581 0.224498648 0.424498648 0.461998648
37 38 39 40 41 42
0.458008047 0.469119158 0.446896936 0.535785825 0.469119158 0.580230269
43 44 45 46 47 48
0.635785825 0.591341380 0.493599661 0.499859727 0.599859727 0.737359727
49 50 51 52 53 54
0.933369126 0.944480238 0.622258015 0.011146904 -0.055519762 0.355591349
55 56 57 58 59 60
1.111146904 1.466702460 1.268960740 0.825140273 0.425140273 0.462640273
61 62 63 64 65 66
0.558649672 0.769760783 0.947538560 0.736427449 0.869760783 0.880871894
67 68 69 70 71 72
0.936427449 0.891983005 0.794241285 0.500501352 0.500501352 0.538001352
73 74 75 76 77 78
0.634010751 0.745121862 0.822899640 0.911788529 0.945121862 0.856232973
79 80 81 82 83 84
0.411788529 0.167344085 -0.030397635 -0.224137568 -0.124137568 -0.186637568
85 86 87 88 89 90
-0.190628169 -0.079517058 -0.001739280 0.287149609 0.220482942 -0.168405947
91 92 93 94 95 96
-0.412850391 -0.757294836 -1.255036555 -1.248776489 -1.148776489 -1.011276489
97 98 99 100 101 102
-1.015267090 -1.104155978 -1.226378201 -1.237489312 -1.404155978 -1.293044867
103 104
-1.237489312 -1.281933756
> postscript(file="/var/www/html/rcomp/tmp/6vd2j1227785587.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 = 104
Frequency = 1
lag(myerror, k = 1) myerror
0 0.031924808 NA
1 -0.156964081 0.031924808
2 -0.279186303 -0.156964081
3 -0.290297414 -0.279186303
4 -0.356964081 -0.290297414
5 -0.345852970 -0.356964081
6 -0.390297414 -0.345852970
7 -0.034741859 -0.390297414
8 -0.432483578 -0.034741859
9 -0.426223511 -0.432483578
10 -0.626223511 -0.426223511
11 -0.988723511 -0.626223511
12 -1.292714112 -0.988723511
13 -1.381603001 -1.292714112
14 -1.203825224 -1.381603001
15 -0.814936335 -1.203825224
16 -0.581603001 -0.814936335
17 -0.770491890 -0.581603001
18 -1.114936335 -0.770491890
19 -1.059380779 -1.114936335
20 -0.857122499 -1.059380779
21 -0.150862432 -0.857122499
22 -0.050862432 -0.150862432
23 -0.013362432 -0.050862432
24 -0.117353033 -0.013362432
25 -0.206241922 -0.117353033
26 -0.128464144 -0.206241922
27 -0.139575255 -0.128464144
28 -0.106241922 -0.139575255
29 -0.095130811 -0.106241922
30 0.060424745 -0.095130811
31 0.015980301 0.060424745
32 0.018238581 0.015980301
33 0.224498648 0.018238581
34 0.424498648 0.224498648
35 0.461998648 0.424498648
36 0.458008047 0.461998648
37 0.469119158 0.458008047
38 0.446896936 0.469119158
39 0.535785825 0.446896936
40 0.469119158 0.535785825
41 0.580230269 0.469119158
42 0.635785825 0.580230269
43 0.591341380 0.635785825
44 0.493599661 0.591341380
45 0.499859727 0.493599661
46 0.599859727 0.499859727
47 0.737359727 0.599859727
48 0.933369126 0.737359727
49 0.944480238 0.933369126
50 0.622258015 0.944480238
51 0.011146904 0.622258015
52 -0.055519762 0.011146904
53 0.355591349 -0.055519762
54 1.111146904 0.355591349
55 1.466702460 1.111146904
56 1.268960740 1.466702460
57 0.825140273 1.268960740
58 0.425140273 0.825140273
59 0.462640273 0.425140273
60 0.558649672 0.462640273
61 0.769760783 0.558649672
62 0.947538560 0.769760783
63 0.736427449 0.947538560
64 0.869760783 0.736427449
65 0.880871894 0.869760783
66 0.936427449 0.880871894
67 0.891983005 0.936427449
68 0.794241285 0.891983005
69 0.500501352 0.794241285
70 0.500501352 0.500501352
71 0.538001352 0.500501352
72 0.634010751 0.538001352
73 0.745121862 0.634010751
74 0.822899640 0.745121862
75 0.911788529 0.822899640
76 0.945121862 0.911788529
77 0.856232973 0.945121862
78 0.411788529 0.856232973
79 0.167344085 0.411788529
80 -0.030397635 0.167344085
81 -0.224137568 -0.030397635
82 -0.124137568 -0.224137568
83 -0.186637568 -0.124137568
84 -0.190628169 -0.186637568
85 -0.079517058 -0.190628169
86 -0.001739280 -0.079517058
87 0.287149609 -0.001739280
88 0.220482942 0.287149609
89 -0.168405947 0.220482942
90 -0.412850391 -0.168405947
91 -0.757294836 -0.412850391
92 -1.255036555 -0.757294836
93 -1.248776489 -1.255036555
94 -1.148776489 -1.248776489
95 -1.011276489 -1.148776489
96 -1.015267090 -1.011276489
97 -1.104155978 -1.015267090
98 -1.226378201 -1.104155978
99 -1.237489312 -1.226378201
100 -1.404155978 -1.237489312
101 -1.293044867 -1.404155978
102 -1.237489312 -1.293044867
103 -1.281933756 -1.237489312
104 NA -1.281933756
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.156964081 0.031924808
[2,] -0.279186303 -0.156964081
[3,] -0.290297414 -0.279186303
[4,] -0.356964081 -0.290297414
[5,] -0.345852970 -0.356964081
[6,] -0.390297414 -0.345852970
[7,] -0.034741859 -0.390297414
[8,] -0.432483578 -0.034741859
[9,] -0.426223511 -0.432483578
[10,] -0.626223511 -0.426223511
[11,] -0.988723511 -0.626223511
[12,] -1.292714112 -0.988723511
[13,] -1.381603001 -1.292714112
[14,] -1.203825224 -1.381603001
[15,] -0.814936335 -1.203825224
[16,] -0.581603001 -0.814936335
[17,] -0.770491890 -0.581603001
[18,] -1.114936335 -0.770491890
[19,] -1.059380779 -1.114936335
[20,] -0.857122499 -1.059380779
[21,] -0.150862432 -0.857122499
[22,] -0.050862432 -0.150862432
[23,] -0.013362432 -0.050862432
[24,] -0.117353033 -0.013362432
[25,] -0.206241922 -0.117353033
[26,] -0.128464144 -0.206241922
[27,] -0.139575255 -0.128464144
[28,] -0.106241922 -0.139575255
[29,] -0.095130811 -0.106241922
[30,] 0.060424745 -0.095130811
[31,] 0.015980301 0.060424745
[32,] 0.018238581 0.015980301
[33,] 0.224498648 0.018238581
[34,] 0.424498648 0.224498648
[35,] 0.461998648 0.424498648
[36,] 0.458008047 0.461998648
[37,] 0.469119158 0.458008047
[38,] 0.446896936 0.469119158
[39,] 0.535785825 0.446896936
[40,] 0.469119158 0.535785825
[41,] 0.580230269 0.469119158
[42,] 0.635785825 0.580230269
[43,] 0.591341380 0.635785825
[44,] 0.493599661 0.591341380
[45,] 0.499859727 0.493599661
[46,] 0.599859727 0.499859727
[47,] 0.737359727 0.599859727
[48,] 0.933369126 0.737359727
[49,] 0.944480238 0.933369126
[50,] 0.622258015 0.944480238
[51,] 0.011146904 0.622258015
[52,] -0.055519762 0.011146904
[53,] 0.355591349 -0.055519762
[54,] 1.111146904 0.355591349
[55,] 1.466702460 1.111146904
[56,] 1.268960740 1.466702460
[57,] 0.825140273 1.268960740
[58,] 0.425140273 0.825140273
[59,] 0.462640273 0.425140273
[60,] 0.558649672 0.462640273
[61,] 0.769760783 0.558649672
[62,] 0.947538560 0.769760783
[63,] 0.736427449 0.947538560
[64,] 0.869760783 0.736427449
[65,] 0.880871894 0.869760783
[66,] 0.936427449 0.880871894
[67,] 0.891983005 0.936427449
[68,] 0.794241285 0.891983005
[69,] 0.500501352 0.794241285
[70,] 0.500501352 0.500501352
[71,] 0.538001352 0.500501352
[72,] 0.634010751 0.538001352
[73,] 0.745121862 0.634010751
[74,] 0.822899640 0.745121862
[75,] 0.911788529 0.822899640
[76,] 0.945121862 0.911788529
[77,] 0.856232973 0.945121862
[78,] 0.411788529 0.856232973
[79,] 0.167344085 0.411788529
[80,] -0.030397635 0.167344085
[81,] -0.224137568 -0.030397635
[82,] -0.124137568 -0.224137568
[83,] -0.186637568 -0.124137568
[84,] -0.190628169 -0.186637568
[85,] -0.079517058 -0.190628169
[86,] -0.001739280 -0.079517058
[87,] 0.287149609 -0.001739280
[88,] 0.220482942 0.287149609
[89,] -0.168405947 0.220482942
[90,] -0.412850391 -0.168405947
[91,] -0.757294836 -0.412850391
[92,] -1.255036555 -0.757294836
[93,] -1.248776489 -1.255036555
[94,] -1.148776489 -1.248776489
[95,] -1.011276489 -1.148776489
[96,] -1.015267090 -1.011276489
[97,] -1.104155978 -1.015267090
[98,] -1.226378201 -1.104155978
[99,] -1.237489312 -1.226378201
[100,] -1.404155978 -1.237489312
[101,] -1.293044867 -1.404155978
[102,] -1.237489312 -1.293044867
[103,] -1.281933756 -1.237489312
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.156964081 0.031924808
2 -0.279186303 -0.156964081
3 -0.290297414 -0.279186303
4 -0.356964081 -0.290297414
5 -0.345852970 -0.356964081
6 -0.390297414 -0.345852970
7 -0.034741859 -0.390297414
8 -0.432483578 -0.034741859
9 -0.426223511 -0.432483578
10 -0.626223511 -0.426223511
11 -0.988723511 -0.626223511
12 -1.292714112 -0.988723511
13 -1.381603001 -1.292714112
14 -1.203825224 -1.381603001
15 -0.814936335 -1.203825224
16 -0.581603001 -0.814936335
17 -0.770491890 -0.581603001
18 -1.114936335 -0.770491890
19 -1.059380779 -1.114936335
20 -0.857122499 -1.059380779
21 -0.150862432 -0.857122499
22 -0.050862432 -0.150862432
23 -0.013362432 -0.050862432
24 -0.117353033 -0.013362432
25 -0.206241922 -0.117353033
26 -0.128464144 -0.206241922
27 -0.139575255 -0.128464144
28 -0.106241922 -0.139575255
29 -0.095130811 -0.106241922
30 0.060424745 -0.095130811
31 0.015980301 0.060424745
32 0.018238581 0.015980301
33 0.224498648 0.018238581
34 0.424498648 0.224498648
35 0.461998648 0.424498648
36 0.458008047 0.461998648
37 0.469119158 0.458008047
38 0.446896936 0.469119158
39 0.535785825 0.446896936
40 0.469119158 0.535785825
41 0.580230269 0.469119158
42 0.635785825 0.580230269
43 0.591341380 0.635785825
44 0.493599661 0.591341380
45 0.499859727 0.493599661
46 0.599859727 0.499859727
47 0.737359727 0.599859727
48 0.933369126 0.737359727
49 0.944480238 0.933369126
50 0.622258015 0.944480238
51 0.011146904 0.622258015
52 -0.055519762 0.011146904
53 0.355591349 -0.055519762
54 1.111146904 0.355591349
55 1.466702460 1.111146904
56 1.268960740 1.466702460
57 0.825140273 1.268960740
58 0.425140273 0.825140273
59 0.462640273 0.425140273
60 0.558649672 0.462640273
61 0.769760783 0.558649672
62 0.947538560 0.769760783
63 0.736427449 0.947538560
64 0.869760783 0.736427449
65 0.880871894 0.869760783
66 0.936427449 0.880871894
67 0.891983005 0.936427449
68 0.794241285 0.891983005
69 0.500501352 0.794241285
70 0.500501352 0.500501352
71 0.538001352 0.500501352
72 0.634010751 0.538001352
73 0.745121862 0.634010751
74 0.822899640 0.745121862
75 0.911788529 0.822899640
76 0.945121862 0.911788529
77 0.856232973 0.945121862
78 0.411788529 0.856232973
79 0.167344085 0.411788529
80 -0.030397635 0.167344085
81 -0.224137568 -0.030397635
82 -0.124137568 -0.224137568
83 -0.186637568 -0.124137568
84 -0.190628169 -0.186637568
85 -0.079517058 -0.190628169
86 -0.001739280 -0.079517058
87 0.287149609 -0.001739280
88 0.220482942 0.287149609
89 -0.168405947 0.220482942
90 -0.412850391 -0.168405947
91 -0.757294836 -0.412850391
92 -1.255036555 -0.757294836
93 -1.248776489 -1.255036555
94 -1.148776489 -1.248776489
95 -1.011276489 -1.148776489
96 -1.015267090 -1.011276489
97 -1.104155978 -1.015267090
98 -1.226378201 -1.104155978
99 -1.237489312 -1.226378201
100 -1.404155978 -1.237489312
101 -1.293044867 -1.404155978
102 -1.237489312 -1.293044867
103 -1.281933756 -1.237489312
> 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/7u7pm1227785587.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/82ehf1227785587.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/9xunk1227785587.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/10etwd1227785587.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/11ba2n1227785587.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/12swn11227785587.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/13bvi31227785587.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/14s53q1227785587.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/15ahq51227785587.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/16ar6z1227785587.tab")
+ }
>
> system("convert tmp/1jr6z1227785587.ps tmp/1jr6z1227785587.png")
> system("convert tmp/2owx21227785587.ps tmp/2owx21227785587.png")
> system("convert tmp/3adr11227785587.ps tmp/3adr11227785587.png")
> system("convert tmp/4h7e81227785587.ps tmp/4h7e81227785587.png")
> system("convert tmp/5if2a1227785587.ps tmp/5if2a1227785587.png")
> system("convert tmp/6vd2j1227785587.ps tmp/6vd2j1227785587.png")
> system("convert tmp/7u7pm1227785587.ps tmp/7u7pm1227785587.png")
> system("convert tmp/82ehf1227785587.ps tmp/82ehf1227785587.png")
> system("convert tmp/9xunk1227785587.ps tmp/9xunk1227785587.png")
> system("convert tmp/10etwd1227785587.ps tmp/10etwd1227785587.png")
>
>
> proc.time()
user system elapsed
3.034 1.606 4.459