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(6392.3
+ ,0
+ ,8686.4
+ ,0
+ ,9244.7
+ ,0
+ ,8182.7
+ ,0
+ ,7451.4
+ ,0
+ ,7988.8
+ ,0
+ ,8243.5
+ ,0
+ ,8843
+ ,0
+ ,9092.7
+ ,0
+ ,8246.7
+ ,0
+ ,9311.7
+ ,0
+ ,8341.2
+ ,0
+ ,7116.7
+ ,0
+ ,9635.7
+ ,0
+ ,9815.4
+ ,0
+ ,8611.3
+ ,0
+ ,8297.8
+ ,0
+ ,8715.1
+ ,0
+ ,8919.9
+ ,0
+ ,10085.8
+ ,0
+ ,9511.7
+ ,0
+ ,8991.3
+ ,0
+ ,10311.2
+ ,0
+ ,8895.4
+ ,0
+ ,7449.8
+ ,0
+ ,10084
+ ,0
+ ,9859.4
+ ,0
+ ,9100.1
+ ,0
+ ,8920.8
+ ,0
+ ,8502.7
+ ,0
+ ,8599.6
+ ,0
+ ,10394.4
+ ,0
+ ,9290.4
+ ,0
+ ,8742.2
+ ,0
+ ,10217.3
+ ,0
+ ,8639
+ ,0
+ ,8139.6
+ ,0
+ ,10779.1
+ ,0
+ ,10427.7
+ ,0
+ ,10349.1
+ ,0
+ ,10036.4
+ ,0
+ ,9492.1
+ ,0
+ ,10638.8
+ ,0
+ ,12054.5
+ ,0
+ ,10324.7
+ ,0
+ ,11817.3
+ ,0
+ ,11008.9
+ ,0
+ ,9996.6
+ ,0
+ ,9419.5
+ ,0
+ ,11958.8
+ ,0
+ ,12594.6
+ ,0
+ ,11890.6
+ ,0
+ ,10871.7
+ ,0
+ ,11835.7
+ ,0
+ ,11542.2
+ ,0
+ ,13093.7
+ ,0
+ ,11180.2
+ ,0
+ ,12035.7
+ ,0
+ ,12112
+ ,0
+ ,10875.2
+ ,0
+ ,9897.3
+ ,0
+ ,11672.1
+ ,1
+ ,12385.7
+ ,1
+ ,11405.6
+ ,1
+ ,9830.9
+ ,1
+ ,11025.1
+ ,1
+ ,10853.8
+ ,1
+ ,12252.6
+ ,1
+ ,11839.4
+ ,1
+ ,11669.1
+ ,1
+ ,11601.4
+ ,1
+ ,11178.4
+ ,1
+ ,9516.4
+ ,1
+ ,12102.8
+ ,1
+ ,12989
+ ,1
+ ,11610.2
+ ,1
+ ,10205.5
+ ,1
+ ,11356.2
+ ,1
+ ,11307.1
+ ,1
+ ,12648.6
+ ,1
+ ,11947.2
+ ,1
+ ,11714.1
+ ,1
+ ,12192.5
+ ,1
+ ,11268.8
+ ,1
+ ,9097.4
+ ,1
+ ,12639.8
+ ,1
+ ,13040.1
+ ,1
+ ,11687.3
+ ,1
+ ,11191.7
+ ,1
+ ,11391.9
+ ,1
+ ,11793.1
+ ,1
+ ,13933.2
+ ,1
+ ,12778.1
+ ,1
+ ,11810.3
+ ,1
+ ,13698.4
+ ,1
+ ,11956.6
+ ,1
+ ,10723.8
+ ,1
+ ,13938.9
+ ,1
+ ,13979.8
+ ,1
+ ,13807.4
+ ,1
+ ,12973.9
+ ,1
+ ,12509.8
+ ,1
+ ,12934.1
+ ,1
+ ,14908.3
+ ,1
+ ,13772.1
+ ,1
+ ,13012.6
+ ,1
+ ,14049.9
+ ,1
+ ,11816.5
+ ,1
+ ,11593.2
+ ,1
+ ,14466.2
+ ,1
+ ,13615.9
+ ,1
+ ,14733.9
+ ,1
+ ,13880.7
+ ,1
+ ,13527.5
+ ,1
+ ,13584
+ ,1
+ ,16170.2
+ ,1
+ ,13260.6
+ ,1
+ ,14741.9
+ ,1
+ ,15486.5
+ ,1
+ ,13154.5
+ ,1
+ ,12621.2
+ ,1)
+ ,dim=c(2
+ ,121)
+ ,dimnames=list(c('y'
+ ,'x')
+ ,1:121))
> y <- array(NA,dim=c(2,121),dimnames=list(c('y','x'),1:121))
> 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
y x
1 6392.3 0
2 8686.4 0
3 9244.7 0
4 8182.7 0
5 7451.4 0
6 7988.8 0
7 8243.5 0
8 8843.0 0
9 9092.7 0
10 8246.7 0
11 9311.7 0
12 8341.2 0
13 7116.7 0
14 9635.7 0
15 9815.4 0
16 8611.3 0
17 8297.8 0
18 8715.1 0
19 8919.9 0
20 10085.8 0
21 9511.7 0
22 8991.3 0
23 10311.2 0
24 8895.4 0
25 7449.8 0
26 10084.0 0
27 9859.4 0
28 9100.1 0
29 8920.8 0
30 8502.7 0
31 8599.6 0
32 10394.4 0
33 9290.4 0
34 8742.2 0
35 10217.3 0
36 8639.0 0
37 8139.6 0
38 10779.1 0
39 10427.7 0
40 10349.1 0
41 10036.4 0
42 9492.1 0
43 10638.8 0
44 12054.5 0
45 10324.7 0
46 11817.3 0
47 11008.9 0
48 9996.6 0
49 9419.5 0
50 11958.8 0
51 12594.6 0
52 11890.6 0
53 10871.7 0
54 11835.7 0
55 11542.2 0
56 13093.7 0
57 11180.2 0
58 12035.7 0
59 12112.0 0
60 10875.2 0
61 9897.3 0
62 11672.1 1
63 12385.7 1
64 11405.6 1
65 9830.9 1
66 11025.1 1
67 10853.8 1
68 12252.6 1
69 11839.4 1
70 11669.1 1
71 11601.4 1
72 11178.4 1
73 9516.4 1
74 12102.8 1
75 12989.0 1
76 11610.2 1
77 10205.5 1
78 11356.2 1
79 11307.1 1
80 12648.6 1
81 11947.2 1
82 11714.1 1
83 12192.5 1
84 11268.8 1
85 9097.4 1
86 12639.8 1
87 13040.1 1
88 11687.3 1
89 11191.7 1
90 11391.9 1
91 11793.1 1
92 13933.2 1
93 12778.1 1
94 11810.3 1
95 13698.4 1
96 11956.6 1
97 10723.8 1
98 13938.9 1
99 13979.8 1
100 13807.4 1
101 12973.9 1
102 12509.8 1
103 12934.1 1
104 14908.3 1
105 13772.1 1
106 13012.6 1
107 14049.9 1
108 11816.5 1
109 11593.2 1
110 14466.2 1
111 13615.9 1
112 14733.9 1
113 13880.7 1
114 13527.5 1
115 13584.0 1
116 16170.2 1
117 13260.6 1
118 14741.9 1
119 15486.5 1
120 13154.5 1
121 12621.2 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x
9723 2758
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3383.5 -1007.9 -211.3 1056.1 3689.3
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9723.0 185.1 52.52 <2e-16 ***
x 2757.9 262.9 10.49 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1446 on 119 degrees of freedom
Multiple R-squared: 0.4805, Adjusted R-squared: 0.4761
F-statistic: 110 on 1 and 119 DF, p-value: < 2.2e-16
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.517272432 0.96545514 0.4827276
[2,] 0.353139982 0.70627996 0.6468600
[3,] 0.228850193 0.45770039 0.7711498
[4,] 0.170199492 0.34039898 0.8298005
[5,] 0.138069645 0.27613929 0.8619304
[6,] 0.083763085 0.16752617 0.9162369
[7,] 0.075280756 0.15056151 0.9247192
[8,] 0.045012364 0.09002473 0.9549876
[9,] 0.054436430 0.10887286 0.9455636
[10,] 0.064963607 0.12992721 0.9350364
[11,] 0.078669199 0.15733840 0.9213308
[12,] 0.053122970 0.10624594 0.9468770
[13,] 0.036070896 0.07214179 0.9639291
[14,] 0.023840071 0.04768014 0.9761599
[15,] 0.016178994 0.03235799 0.9838210
[16,] 0.024600317 0.04920063 0.9753997
[17,] 0.020878446 0.04175689 0.9791216
[18,] 0.014249639 0.02849928 0.9857504
[19,] 0.021987551 0.04397510 0.9780124
[20,] 0.015070348 0.03014070 0.9849297
[21,] 0.020751052 0.04150210 0.9792489
[22,] 0.023914578 0.04782916 0.9760854
[23,] 0.022619363 0.04523873 0.9773806
[24,] 0.016537438 0.03307488 0.9834626
[25,] 0.012009530 0.02401906 0.9879905
[26,] 0.009513610 0.01902722 0.9904864
[27,] 0.007438769 0.01487754 0.9925612
[28,] 0.010561600 0.02112320 0.9894384
[29,] 0.008102113 0.01620423 0.9918979
[30,] 0.006491693 0.01298339 0.9935083
[31,] 0.007515437 0.01503087 0.9924846
[32,] 0.006558299 0.01311660 0.9934417
[33,] 0.007970568 0.01594114 0.9920294
[34,] 0.014241813 0.02848363 0.9857582
[35,] 0.017297740 0.03459548 0.9827023
[36,] 0.019229420 0.03845884 0.9807706
[37,] 0.018426808 0.03685362 0.9815732
[38,] 0.016331111 0.03266222 0.9836689
[39,] 0.020232666 0.04046533 0.9797673
[40,] 0.065217636 0.13043527 0.9347824
[41,] 0.063430195 0.12686039 0.9365698
[42,] 0.113259055 0.22651811 0.8867409
[43,] 0.124610892 0.24922178 0.8753891
[44,] 0.114785144 0.22957029 0.8852149
[45,] 0.113159963 0.22631993 0.8868400
[46,] 0.172141165 0.34428233 0.8278588
[47,] 0.298893536 0.59778707 0.7011065
[48,] 0.352606510 0.70521302 0.6473935
[49,] 0.340857531 0.68171506 0.6591425
[50,] 0.378280364 0.75656073 0.6217196
[51,] 0.389556777 0.77911355 0.6104432
[52,] 0.550715282 0.89856944 0.4492847
[53,] 0.531774386 0.93645123 0.4682256
[54,] 0.564392627 0.87121475 0.4356074
[55,] 0.608644671 0.78271066 0.3913553
[56,] 0.579265657 0.84146869 0.4207343
[57,] 0.527608516 0.94478297 0.4723915
[58,] 0.483386252 0.96677250 0.5166137
[59,] 0.434325721 0.86865144 0.5656743
[60,] 0.400792405 0.80158481 0.5992076
[61,] 0.477603477 0.95520695 0.5223965
[62,] 0.458438733 0.91687747 0.5415613
[63,] 0.450006225 0.90001245 0.5499938
[64,] 0.410792589 0.82158518 0.5892074
[65,] 0.370859653 0.74171931 0.6291403
[66,] 0.334976422 0.66995284 0.6650236
[67,] 0.302455518 0.60491104 0.6975445
[68,] 0.286239231 0.57247846 0.7137608
[69,] 0.420823844 0.84164769 0.5791762
[70,] 0.382986841 0.76597368 0.6170132
[71,] 0.358593271 0.71718654 0.6414067
[72,] 0.330459856 0.66091971 0.6695401
[73,] 0.406374690 0.81274938 0.5936253
[74,] 0.394502674 0.78900535 0.6054973
[75,] 0.388394065 0.77678813 0.6116059
[76,] 0.352616725 0.70523345 0.6473833
[77,] 0.321972233 0.64394447 0.6780278
[78,] 0.300810373 0.60162075 0.6991896
[79,] 0.268555271 0.53711054 0.7314447
[80,] 0.274461094 0.54892219 0.7255389
[81,] 0.618578720 0.76284256 0.3814213
[82,] 0.582613953 0.83477209 0.4173860
[83,] 0.546584555 0.90683089 0.4534154
[84,] 0.548166913 0.90366617 0.4518331
[85,] 0.605347354 0.78930529 0.3946526
[86,] 0.651904057 0.69619189 0.3480959
[87,] 0.668568641 0.66286272 0.3314314
[88,] 0.659764305 0.68047139 0.3402357
[89,] 0.622709731 0.75458054 0.3772903
[90,] 0.645097190 0.70980562 0.3549028
[91,] 0.613267135 0.77346573 0.3867329
[92,] 0.628373435 0.74325313 0.3716266
[93,] 0.831133545 0.33773291 0.1688665
[94,] 0.807736217 0.38452757 0.1922638
[95,] 0.780992618 0.43801476 0.2190074
[96,] 0.743228462 0.51354308 0.2567715
[97,] 0.703153150 0.59369370 0.2968468
[98,] 0.690895234 0.61820953 0.3091048
[99,] 0.652372865 0.69525427 0.3476271
[100,] 0.671802636 0.65639473 0.3281974
[101,] 0.609075731 0.78184854 0.3909243
[102,] 0.553586704 0.89282659 0.4464133
[103,] 0.488316268 0.97663254 0.5116837
[104,] 0.579788104 0.84042379 0.4202119
[105,] 0.776253215 0.44749357 0.2237468
[106,] 0.716661946 0.56667611 0.2833381
[107,] 0.638648545 0.72270291 0.3613515
[108,] 0.574336041 0.85132792 0.4256640
[109,] 0.464069216 0.92813843 0.5359308
[110,] 0.362166972 0.72433394 0.6378330
[111,] 0.261634859 0.52326972 0.7383651
[112,] 0.419245747 0.83849149 0.5807543
> postscript(file="/var/www/html/rcomp/tmp/1ika81229527061.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/2duo01229527061.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/3pw471229527061.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/4fyaw1229527061.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/5dkaz1229527061.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 = 121
Frequency = 1
1 2 3 4 5 6
-3330.71803 -1036.61803 -478.31803 -1540.31803 -2271.61803 -1734.21803
7 8 9 10 11 12
-1479.51803 -880.01803 -630.31803 -1476.31803 -411.31803 -1381.81803
13 14 15 16 17 18
-2606.31803 -87.31803 92.38197 -1111.71803 -1425.21803 -1007.91803
19 20 21 22 23 24
-803.11803 362.78197 -211.31803 -731.71803 588.18197 -827.61803
25 26 27 28 29 30
-2273.21803 360.98197 136.38197 -622.91803 -802.21803 -1220.31803
31 32 33 34 35 36
-1123.41803 671.38197 -432.61803 -980.81803 494.28197 -1084.01803
37 38 39 40 41 42
-1583.41803 1056.08197 704.68197 626.08197 313.38197 -230.91803
43 44 45 46 47 48
915.78197 2331.48197 601.68197 2094.28197 1285.88197 273.58197
49 50 51 52 53 54
-303.51803 2235.78197 2871.58197 2167.58197 1148.68197 2112.68197
55 56 57 58 59 60
1819.18197 3370.68197 1457.18197 2312.68197 2388.98197 1152.18197
61 62 63 64 65 66
174.28197 -808.79667 -95.19667 -1075.29667 -2649.99667 -1455.79667
67 68 69 70 71 72
-1627.09667 -228.29667 -641.49667 -811.79667 -879.49667 -1302.49667
73 74 75 76 77 78
-2964.49667 -378.09667 508.10333 -870.69667 -2275.39667 -1124.69667
79 80 81 82 83 84
-1173.79667 167.70333 -533.69667 -766.79667 -288.39667 -1212.09667
85 86 87 88 89 90
-3383.49667 158.90333 559.20333 -793.59667 -1289.19667 -1088.99667
91 92 93 94 95 96
-687.79667 1452.30333 297.20333 -670.59667 1217.50333 -524.29667
97 98 99 100 101 102
-1757.09667 1458.00333 1498.90333 1326.50333 493.00333 28.90333
103 104 105 106 107 108
453.20333 2427.40333 1291.20333 531.70333 1569.00333 -664.39667
109 110 111 112 113 114
-887.69667 1985.30333 1135.00333 2253.00333 1399.80333 1046.60333
115 116 117 118 119 120
1103.10333 3689.30333 779.70333 2261.00333 3005.60333 673.60333
121
140.30333
> postscript(file="/var/www/html/rcomp/tmp/6ekjx1229527061.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 = 121
Frequency = 1
lag(myerror, k = 1) myerror
0 -3330.71803 NA
1 -1036.61803 -3330.71803
2 -478.31803 -1036.61803
3 -1540.31803 -478.31803
4 -2271.61803 -1540.31803
5 -1734.21803 -2271.61803
6 -1479.51803 -1734.21803
7 -880.01803 -1479.51803
8 -630.31803 -880.01803
9 -1476.31803 -630.31803
10 -411.31803 -1476.31803
11 -1381.81803 -411.31803
12 -2606.31803 -1381.81803
13 -87.31803 -2606.31803
14 92.38197 -87.31803
15 -1111.71803 92.38197
16 -1425.21803 -1111.71803
17 -1007.91803 -1425.21803
18 -803.11803 -1007.91803
19 362.78197 -803.11803
20 -211.31803 362.78197
21 -731.71803 -211.31803
22 588.18197 -731.71803
23 -827.61803 588.18197
24 -2273.21803 -827.61803
25 360.98197 -2273.21803
26 136.38197 360.98197
27 -622.91803 136.38197
28 -802.21803 -622.91803
29 -1220.31803 -802.21803
30 -1123.41803 -1220.31803
31 671.38197 -1123.41803
32 -432.61803 671.38197
33 -980.81803 -432.61803
34 494.28197 -980.81803
35 -1084.01803 494.28197
36 -1583.41803 -1084.01803
37 1056.08197 -1583.41803
38 704.68197 1056.08197
39 626.08197 704.68197
40 313.38197 626.08197
41 -230.91803 313.38197
42 915.78197 -230.91803
43 2331.48197 915.78197
44 601.68197 2331.48197
45 2094.28197 601.68197
46 1285.88197 2094.28197
47 273.58197 1285.88197
48 -303.51803 273.58197
49 2235.78197 -303.51803
50 2871.58197 2235.78197
51 2167.58197 2871.58197
52 1148.68197 2167.58197
53 2112.68197 1148.68197
54 1819.18197 2112.68197
55 3370.68197 1819.18197
56 1457.18197 3370.68197
57 2312.68197 1457.18197
58 2388.98197 2312.68197
59 1152.18197 2388.98197
60 174.28197 1152.18197
61 -808.79667 174.28197
62 -95.19667 -808.79667
63 -1075.29667 -95.19667
64 -2649.99667 -1075.29667
65 -1455.79667 -2649.99667
66 -1627.09667 -1455.79667
67 -228.29667 -1627.09667
68 -641.49667 -228.29667
69 -811.79667 -641.49667
70 -879.49667 -811.79667
71 -1302.49667 -879.49667
72 -2964.49667 -1302.49667
73 -378.09667 -2964.49667
74 508.10333 -378.09667
75 -870.69667 508.10333
76 -2275.39667 -870.69667
77 -1124.69667 -2275.39667
78 -1173.79667 -1124.69667
79 167.70333 -1173.79667
80 -533.69667 167.70333
81 -766.79667 -533.69667
82 -288.39667 -766.79667
83 -1212.09667 -288.39667
84 -3383.49667 -1212.09667
85 158.90333 -3383.49667
86 559.20333 158.90333
87 -793.59667 559.20333
88 -1289.19667 -793.59667
89 -1088.99667 -1289.19667
90 -687.79667 -1088.99667
91 1452.30333 -687.79667
92 297.20333 1452.30333
93 -670.59667 297.20333
94 1217.50333 -670.59667
95 -524.29667 1217.50333
96 -1757.09667 -524.29667
97 1458.00333 -1757.09667
98 1498.90333 1458.00333
99 1326.50333 1498.90333
100 493.00333 1326.50333
101 28.90333 493.00333
102 453.20333 28.90333
103 2427.40333 453.20333
104 1291.20333 2427.40333
105 531.70333 1291.20333
106 1569.00333 531.70333
107 -664.39667 1569.00333
108 -887.69667 -664.39667
109 1985.30333 -887.69667
110 1135.00333 1985.30333
111 2253.00333 1135.00333
112 1399.80333 2253.00333
113 1046.60333 1399.80333
114 1103.10333 1046.60333
115 3689.30333 1103.10333
116 779.70333 3689.30333
117 2261.00333 779.70333
118 3005.60333 2261.00333
119 673.60333 3005.60333
120 140.30333 673.60333
121 NA 140.30333
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1036.61803 -3330.71803
[2,] -478.31803 -1036.61803
[3,] -1540.31803 -478.31803
[4,] -2271.61803 -1540.31803
[5,] -1734.21803 -2271.61803
[6,] -1479.51803 -1734.21803
[7,] -880.01803 -1479.51803
[8,] -630.31803 -880.01803
[9,] -1476.31803 -630.31803
[10,] -411.31803 -1476.31803
[11,] -1381.81803 -411.31803
[12,] -2606.31803 -1381.81803
[13,] -87.31803 -2606.31803
[14,] 92.38197 -87.31803
[15,] -1111.71803 92.38197
[16,] -1425.21803 -1111.71803
[17,] -1007.91803 -1425.21803
[18,] -803.11803 -1007.91803
[19,] 362.78197 -803.11803
[20,] -211.31803 362.78197
[21,] -731.71803 -211.31803
[22,] 588.18197 -731.71803
[23,] -827.61803 588.18197
[24,] -2273.21803 -827.61803
[25,] 360.98197 -2273.21803
[26,] 136.38197 360.98197
[27,] -622.91803 136.38197
[28,] -802.21803 -622.91803
[29,] -1220.31803 -802.21803
[30,] -1123.41803 -1220.31803
[31,] 671.38197 -1123.41803
[32,] -432.61803 671.38197
[33,] -980.81803 -432.61803
[34,] 494.28197 -980.81803
[35,] -1084.01803 494.28197
[36,] -1583.41803 -1084.01803
[37,] 1056.08197 -1583.41803
[38,] 704.68197 1056.08197
[39,] 626.08197 704.68197
[40,] 313.38197 626.08197
[41,] -230.91803 313.38197
[42,] 915.78197 -230.91803
[43,] 2331.48197 915.78197
[44,] 601.68197 2331.48197
[45,] 2094.28197 601.68197
[46,] 1285.88197 2094.28197
[47,] 273.58197 1285.88197
[48,] -303.51803 273.58197
[49,] 2235.78197 -303.51803
[50,] 2871.58197 2235.78197
[51,] 2167.58197 2871.58197
[52,] 1148.68197 2167.58197
[53,] 2112.68197 1148.68197
[54,] 1819.18197 2112.68197
[55,] 3370.68197 1819.18197
[56,] 1457.18197 3370.68197
[57,] 2312.68197 1457.18197
[58,] 2388.98197 2312.68197
[59,] 1152.18197 2388.98197
[60,] 174.28197 1152.18197
[61,] -808.79667 174.28197
[62,] -95.19667 -808.79667
[63,] -1075.29667 -95.19667
[64,] -2649.99667 -1075.29667
[65,] -1455.79667 -2649.99667
[66,] -1627.09667 -1455.79667
[67,] -228.29667 -1627.09667
[68,] -641.49667 -228.29667
[69,] -811.79667 -641.49667
[70,] -879.49667 -811.79667
[71,] -1302.49667 -879.49667
[72,] -2964.49667 -1302.49667
[73,] -378.09667 -2964.49667
[74,] 508.10333 -378.09667
[75,] -870.69667 508.10333
[76,] -2275.39667 -870.69667
[77,] -1124.69667 -2275.39667
[78,] -1173.79667 -1124.69667
[79,] 167.70333 -1173.79667
[80,] -533.69667 167.70333
[81,] -766.79667 -533.69667
[82,] -288.39667 -766.79667
[83,] -1212.09667 -288.39667
[84,] -3383.49667 -1212.09667
[85,] 158.90333 -3383.49667
[86,] 559.20333 158.90333
[87,] -793.59667 559.20333
[88,] -1289.19667 -793.59667
[89,] -1088.99667 -1289.19667
[90,] -687.79667 -1088.99667
[91,] 1452.30333 -687.79667
[92,] 297.20333 1452.30333
[93,] -670.59667 297.20333
[94,] 1217.50333 -670.59667
[95,] -524.29667 1217.50333
[96,] -1757.09667 -524.29667
[97,] 1458.00333 -1757.09667
[98,] 1498.90333 1458.00333
[99,] 1326.50333 1498.90333
[100,] 493.00333 1326.50333
[101,] 28.90333 493.00333
[102,] 453.20333 28.90333
[103,] 2427.40333 453.20333
[104,] 1291.20333 2427.40333
[105,] 531.70333 1291.20333
[106,] 1569.00333 531.70333
[107,] -664.39667 1569.00333
[108,] -887.69667 -664.39667
[109,] 1985.30333 -887.69667
[110,] 1135.00333 1985.30333
[111,] 2253.00333 1135.00333
[112,] 1399.80333 2253.00333
[113,] 1046.60333 1399.80333
[114,] 1103.10333 1046.60333
[115,] 3689.30333 1103.10333
[116,] 779.70333 3689.30333
[117,] 2261.00333 779.70333
[118,] 3005.60333 2261.00333
[119,] 673.60333 3005.60333
[120,] 140.30333 673.60333
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1036.61803 -3330.71803
2 -478.31803 -1036.61803
3 -1540.31803 -478.31803
4 -2271.61803 -1540.31803
5 -1734.21803 -2271.61803
6 -1479.51803 -1734.21803
7 -880.01803 -1479.51803
8 -630.31803 -880.01803
9 -1476.31803 -630.31803
10 -411.31803 -1476.31803
11 -1381.81803 -411.31803
12 -2606.31803 -1381.81803
13 -87.31803 -2606.31803
14 92.38197 -87.31803
15 -1111.71803 92.38197
16 -1425.21803 -1111.71803
17 -1007.91803 -1425.21803
18 -803.11803 -1007.91803
19 362.78197 -803.11803
20 -211.31803 362.78197
21 -731.71803 -211.31803
22 588.18197 -731.71803
23 -827.61803 588.18197
24 -2273.21803 -827.61803
25 360.98197 -2273.21803
26 136.38197 360.98197
27 -622.91803 136.38197
28 -802.21803 -622.91803
29 -1220.31803 -802.21803
30 -1123.41803 -1220.31803
31 671.38197 -1123.41803
32 -432.61803 671.38197
33 -980.81803 -432.61803
34 494.28197 -980.81803
35 -1084.01803 494.28197
36 -1583.41803 -1084.01803
37 1056.08197 -1583.41803
38 704.68197 1056.08197
39 626.08197 704.68197
40 313.38197 626.08197
41 -230.91803 313.38197
42 915.78197 -230.91803
43 2331.48197 915.78197
44 601.68197 2331.48197
45 2094.28197 601.68197
46 1285.88197 2094.28197
47 273.58197 1285.88197
48 -303.51803 273.58197
49 2235.78197 -303.51803
50 2871.58197 2235.78197
51 2167.58197 2871.58197
52 1148.68197 2167.58197
53 2112.68197 1148.68197
54 1819.18197 2112.68197
55 3370.68197 1819.18197
56 1457.18197 3370.68197
57 2312.68197 1457.18197
58 2388.98197 2312.68197
59 1152.18197 2388.98197
60 174.28197 1152.18197
61 -808.79667 174.28197
62 -95.19667 -808.79667
63 -1075.29667 -95.19667
64 -2649.99667 -1075.29667
65 -1455.79667 -2649.99667
66 -1627.09667 -1455.79667
67 -228.29667 -1627.09667
68 -641.49667 -228.29667
69 -811.79667 -641.49667
70 -879.49667 -811.79667
71 -1302.49667 -879.49667
72 -2964.49667 -1302.49667
73 -378.09667 -2964.49667
74 508.10333 -378.09667
75 -870.69667 508.10333
76 -2275.39667 -870.69667
77 -1124.69667 -2275.39667
78 -1173.79667 -1124.69667
79 167.70333 -1173.79667
80 -533.69667 167.70333
81 -766.79667 -533.69667
82 -288.39667 -766.79667
83 -1212.09667 -288.39667
84 -3383.49667 -1212.09667
85 158.90333 -3383.49667
86 559.20333 158.90333
87 -793.59667 559.20333
88 -1289.19667 -793.59667
89 -1088.99667 -1289.19667
90 -687.79667 -1088.99667
91 1452.30333 -687.79667
92 297.20333 1452.30333
93 -670.59667 297.20333
94 1217.50333 -670.59667
95 -524.29667 1217.50333
96 -1757.09667 -524.29667
97 1458.00333 -1757.09667
98 1498.90333 1458.00333
99 1326.50333 1498.90333
100 493.00333 1326.50333
101 28.90333 493.00333
102 453.20333 28.90333
103 2427.40333 453.20333
104 1291.20333 2427.40333
105 531.70333 1291.20333
106 1569.00333 531.70333
107 -664.39667 1569.00333
108 -887.69667 -664.39667
109 1985.30333 -887.69667
110 1135.00333 1985.30333
111 2253.00333 1135.00333
112 1399.80333 2253.00333
113 1046.60333 1399.80333
114 1103.10333 1046.60333
115 3689.30333 1103.10333
116 779.70333 3689.30333
117 2261.00333 779.70333
118 3005.60333 2261.00333
119 673.60333 3005.60333
120 140.30333 673.60333
> 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/7jqnj1229527061.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/8pj531229527061.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/93ap51229527061.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/1027841229527061.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/118tcb1229527061.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/12i5vb1229527061.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/13wge01229527061.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/149m3l1229527061.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/15jzyh1229527061.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/16gp3b1229527061.tab")
+ }
>
> system("convert tmp/1ika81229527061.ps tmp/1ika81229527061.png")
> system("convert tmp/2duo01229527061.ps tmp/2duo01229527061.png")
> system("convert tmp/3pw471229527061.ps tmp/3pw471229527061.png")
> system("convert tmp/4fyaw1229527061.ps tmp/4fyaw1229527061.png")
> system("convert tmp/5dkaz1229527061.ps tmp/5dkaz1229527061.png")
> system("convert tmp/6ekjx1229527061.ps tmp/6ekjx1229527061.png")
> system("convert tmp/7jqnj1229527061.ps tmp/7jqnj1229527061.png")
> system("convert tmp/8pj531229527061.ps tmp/8pj531229527061.png")
> system("convert tmp/93ap51229527061.ps tmp/93ap51229527061.png")
> system("convert tmp/1027841229527061.ps tmp/1027841229527061.png")
>
>
> proc.time()
user system elapsed
3.209 1.627 3.700