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(6340.5
+ ,0
+ ,7901.5
+ ,0
+ ,8191.1
+ ,0
+ ,7181.7
+ ,0
+ ,7594.4
+ ,0
+ ,7384.7
+ ,0
+ ,7876.7
+ ,0
+ ,8463.4
+ ,0
+ ,8317.2
+ ,0
+ ,7778.7
+ ,0
+ ,8532.8
+ ,0
+ ,7272.2
+ ,0
+ ,6680.1
+ ,0
+ ,8427.6
+ ,0
+ ,8752.8
+ ,0
+ ,7952.7
+ ,0
+ ,8694.3
+ ,0
+ ,7787
+ ,0
+ ,8474.2
+ ,0
+ ,9154.7
+ ,0
+ ,8557.2
+ ,0
+ ,7951.1
+ ,0
+ ,9156.7
+ ,0
+ ,7865.7
+ ,0
+ ,7337.4
+ ,0
+ ,9131.7
+ ,0
+ ,8814.6
+ ,0
+ ,8598.8
+ ,0
+ ,8439.6
+ ,0
+ ,7451.8
+ ,0
+ ,8016.2
+ ,0
+ ,9544.1
+ ,0
+ ,8270.7
+ ,0
+ ,8102.2
+ ,0
+ ,9369
+ ,0
+ ,7657.7
+ ,0
+ ,7816.6
+ ,0
+ ,9391.3
+ ,0
+ ,9445.4
+ ,0
+ ,9533.1
+ ,0
+ ,10068.7
+ ,0
+ ,8955.5
+ ,0
+ ,10423.9
+ ,0
+ ,11617.2
+ ,0
+ ,9391.1
+ ,0
+ ,10872
+ ,0
+ ,10230.4
+ ,0
+ ,9221
+ ,0
+ ,9428.6
+ ,0
+ ,10934.5
+ ,0
+ ,10986
+ ,0
+ ,11724.6
+ ,0
+ ,11180.9
+ ,0
+ ,11163.2
+ ,0
+ ,11240.9
+ ,0
+ ,12107.1
+ ,0
+ ,10762.3
+ ,0
+ ,11340.4
+ ,0
+ ,11266.8
+ ,0
+ ,9542.7
+ ,0
+ ,9227.7
+ ,0
+ ,10571.9
+ ,0
+ ,10774.4
+ ,0
+ ,10392.8
+ ,0
+ ,9920.2
+ ,0
+ ,9884.9
+ ,1
+ ,10174.5
+ ,1
+ ,11395.4
+ ,1
+ ,10760.2
+ ,1
+ ,10570.1
+ ,1
+ ,10536
+ ,1
+ ,9902.6
+ ,1
+ ,8889
+ ,1
+ ,10837.3
+ ,1
+ ,11624.1
+ ,1
+ ,10509
+ ,1
+ ,10984.9
+ ,1
+ ,10649.1
+ ,1
+ ,10855.7
+ ,1
+ ,11677.4
+ ,1
+ ,10760.2
+ ,1
+ ,10046.2
+ ,1
+ ,10772.8
+ ,1
+ ,9987.7
+ ,1
+ ,8638.7
+ ,1
+ ,11063.7
+ ,1
+ ,11855.7
+ ,1
+ ,10684.5
+ ,1
+ ,11337.4
+ ,1
+ ,10478
+ ,1
+ ,11123.9
+ ,1
+ ,12909.3
+ ,1
+ ,11339.9
+ ,1
+ ,10462.2
+ ,1
+ ,12733.5
+ ,1
+ ,10519.2
+ ,1
+ ,10414.9
+ ,1
+ ,12476.8
+ ,1
+ ,12384.6
+ ,1
+ ,12266.7
+ ,1
+ ,12919.9
+ ,1
+ ,11497.3
+ ,1
+ ,12142
+ ,1
+ ,13919.4
+ ,1
+ ,12656.8
+ ,1
+ ,12034.1
+ ,1
+ ,13199.7
+ ,1
+ ,10881.3
+ ,1
+ ,11301.2
+ ,1
+ ,13643.9
+ ,1
+ ,12517
+ ,1
+ ,13981.1
+ ,1
+ ,14275.7
+ ,1
+ ,13435
+ ,1
+ ,13565.7
+ ,1
+ ,16216.3
+ ,1
+ ,12970
+ ,1
+ ,14079.9
+ ,1
+ ,14235
+ ,1
+ ,12213.4
+ ,1
+ ,12581
+ ,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 6340.5 0
2 7901.5 0
3 8191.1 0
4 7181.7 0
5 7594.4 0
6 7384.7 0
7 7876.7 0
8 8463.4 0
9 8317.2 0
10 7778.7 0
11 8532.8 0
12 7272.2 0
13 6680.1 0
14 8427.6 0
15 8752.8 0
16 7952.7 0
17 8694.3 0
18 7787.0 0
19 8474.2 0
20 9154.7 0
21 8557.2 0
22 7951.1 0
23 9156.7 0
24 7865.7 0
25 7337.4 0
26 9131.7 0
27 8814.6 0
28 8598.8 0
29 8439.6 0
30 7451.8 0
31 8016.2 0
32 9544.1 0
33 8270.7 0
34 8102.2 0
35 9369.0 0
36 7657.7 0
37 7816.6 0
38 9391.3 0
39 9445.4 0
40 9533.1 0
41 10068.7 0
42 8955.5 0
43 10423.9 0
44 11617.2 0
45 9391.1 0
46 10872.0 0
47 10230.4 0
48 9221.0 0
49 9428.6 0
50 10934.5 0
51 10986.0 0
52 11724.6 0
53 11180.9 0
54 11163.2 0
55 11240.9 0
56 12107.1 0
57 10762.3 0
58 11340.4 0
59 11266.8 0
60 9542.7 0
61 9227.7 0
62 10571.9 0
63 10774.4 0
64 10392.8 0
65 9920.2 0
66 9884.9 1
67 10174.5 1
68 11395.4 1
69 10760.2 1
70 10570.1 1
71 10536.0 1
72 9902.6 1
73 8889.0 1
74 10837.3 1
75 11624.1 1
76 10509.0 1
77 10984.9 1
78 10649.1 1
79 10855.7 1
80 11677.4 1
81 10760.2 1
82 10046.2 1
83 10772.8 1
84 9987.7 1
85 8638.7 1
86 11063.7 1
87 11855.7 1
88 10684.5 1
89 11337.4 1
90 10478.0 1
91 11123.9 1
92 12909.3 1
93 11339.9 1
94 10462.2 1
95 12733.5 1
96 10519.2 1
97 10414.9 1
98 12476.8 1
99 12384.6 1
100 12266.7 1
101 12919.9 1
102 11497.3 1
103 12142.0 1
104 13919.4 1
105 12656.8 1
106 12034.1 1
107 13199.7 1
108 10881.3 1
109 11301.2 1
110 13643.9 1
111 12517.0 1
112 13981.1 1
113 14275.7 1
114 13435.0 1
115 13565.7 1
116 16216.3 1
117 12970.0 1
118 14079.9 1
119 14235.0 1
120 12213.4 1
121 12581.0 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x
9116 2594
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-3071.5 -1140.1 -301.6 1023.3 4506.1
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9116.2 178.2 51.146 <2e-16 ***
x 2594.0 262.0 9.901 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1437 on 119 degrees of freedom
Multiple R-squared: 0.4517, Adjusted R-squared: 0.4471
F-statistic: 98.02 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,] 2.074475e-01 0.4148949659 0.7925525
[2,] 9.772643e-02 0.1954528578 0.9022736
[3,] 4.942326e-02 0.0988465187 0.9505767
[4,] 4.386486e-02 0.0877297134 0.9561351
[5,] 2.845907e-02 0.0569181334 0.9715409
[6,] 1.305744e-02 0.0261148702 0.9869426
[7,] 1.014340e-02 0.0202867948 0.9898566
[8,] 5.964757e-03 0.0119295137 0.9940352
[9,] 7.587662e-03 0.0151753231 0.9924123
[10,] 5.656854e-03 0.0113137081 0.9943431
[11,] 5.833734e-03 0.0116674688 0.9941663
[12,] 3.068063e-03 0.0061361255 0.9969319
[13,] 2.666371e-03 0.0053327423 0.9973336
[14,] 1.407875e-03 0.0028157506 0.9985921
[15,] 9.342977e-04 0.0018685954 0.9990657
[16,] 1.425341e-03 0.0028506815 0.9985747
[17,] 9.436937e-04 0.0018873874 0.9990563
[18,] 5.145905e-04 0.0010291810 0.9994854
[19,] 6.575249e-04 0.0013150497 0.9993425
[20,] 3.820609e-04 0.0007641218 0.9996179
[21,] 3.333166e-04 0.0006666333 0.9996667
[22,] 3.980953e-04 0.0007961907 0.9996019
[23,] 3.115050e-04 0.0006230100 0.9996885
[24,] 2.053627e-04 0.0004107254 0.9997946
[25,] 1.256071e-04 0.0002512143 0.9998744
[26,] 1.168914e-04 0.0002337828 0.9998831
[27,] 7.473411e-05 0.0001494682 0.9999253
[28,] 1.529600e-04 0.0003059200 0.9998470
[29,] 9.957697e-05 0.0001991539 0.9999004
[30,] 6.813038e-05 0.0001362608 0.9999319
[31,] 9.571257e-05 0.0001914251 0.9999043
[32,] 9.511670e-05 0.0001902334 0.9999049
[33,] 8.809622e-05 0.0001761924 0.9999119
[34,] 1.274872e-04 0.0002549744 0.9998725
[35,] 1.808611e-04 0.0003617221 0.9998191
[36,] 2.613424e-04 0.0005226849 0.9997387
[37,] 6.588389e-04 0.0013176778 0.9993412
[38,] 5.791055e-04 0.0011582110 0.9994209
[39,] 1.786703e-03 0.0035734068 0.9982133
[40,] 1.856695e-02 0.0371339096 0.9814330
[41,] 1.725769e-02 0.0345153784 0.9827423
[42,] 3.465431e-02 0.0693086253 0.9653457
[43,] 4.054070e-02 0.0810814072 0.9594593
[44,] 3.646870e-02 0.0729373982 0.9635313
[45,] 3.365110e-02 0.0673021940 0.9663489
[46,] 5.362774e-02 0.1072554897 0.9463723
[47,] 7.822082e-02 0.1564416443 0.9217792
[48,] 1.512805e-01 0.3025610031 0.8487195
[49,] 1.927489e-01 0.3854978832 0.8072511
[50,] 2.308022e-01 0.4616044491 0.7691978
[51,] 2.713467e-01 0.5426934299 0.7286533
[52,] 3.993092e-01 0.7986183724 0.6006908
[53,] 3.979188e-01 0.7958375494 0.6020812
[54,] 4.370044e-01 0.8740088632 0.5629956
[55,] 4.681687e-01 0.9363373849 0.5318313
[56,] 4.237086e-01 0.8474171812 0.5762914
[57,] 3.866699e-01 0.7733398535 0.6133301
[58,] 3.659370e-01 0.7318740894 0.6340630
[59,] 3.542403e-01 0.7084805095 0.6457597
[60,] 3.265513e-01 0.6531025652 0.6734487
[61,] 2.874006e-01 0.5748011612 0.7125994
[62,] 2.789486e-01 0.5578971822 0.7210514
[63,] 2.624574e-01 0.5249147873 0.7375426
[64,] 2.341532e-01 0.4683064218 0.7658468
[65,] 2.057593e-01 0.4115185115 0.7942407
[66,] 1.833067e-01 0.3666133555 0.8166933
[67,] 1.637971e-01 0.3275941419 0.8362029
[68,] 1.664558e-01 0.3329115333 0.8335442
[69,] 2.411404e-01 0.4822807124 0.7588596
[70,] 2.177372e-01 0.4354744779 0.7822628
[71,] 1.933899e-01 0.3867798499 0.8066101
[72,] 1.802538e-01 0.3605075443 0.8197462
[73,] 1.586562e-01 0.3173123734 0.8413438
[74,] 1.453299e-01 0.2906598765 0.8546701
[75,] 1.294607e-01 0.2589214890 0.8705393
[76,] 1.104005e-01 0.2208010132 0.8895995
[77,] 9.943344e-02 0.1988668825 0.9005666
[78,] 1.107256e-01 0.2214511195 0.8892744
[79,] 1.020798e-01 0.2041595082 0.8979202
[80,] 1.223330e-01 0.2446660953 0.8776670
[81,] 3.056157e-01 0.6112313615 0.6943843
[82,] 2.941914e-01 0.5883827391 0.7058086
[83,] 2.668768e-01 0.5337536926 0.7331232
[84,] 2.804882e-01 0.5609764851 0.7195118
[85,] 2.639793e-01 0.5279585873 0.7360207
[86,] 3.065312e-01 0.6130624393 0.6934688
[87,] 3.080335e-01 0.6160670387 0.6919665
[88,] 2.974535e-01 0.5949070953 0.7025465
[89,] 2.880253e-01 0.5760506388 0.7119747
[90,] 3.639369e-01 0.7278737571 0.6360631
[91,] 3.360859e-01 0.6721717243 0.6639141
[92,] 4.310943e-01 0.8621885649 0.5689057
[93,] 5.830779e-01 0.8338441568 0.4169221
[94,] 5.465235e-01 0.9069529555 0.4534765
[95,] 5.092740e-01 0.9814520689 0.4907260
[96,] 4.746423e-01 0.9492845163 0.5253577
[97,] 4.313424e-01 0.8626848684 0.5686576
[98,] 4.578511e-01 0.9157021112 0.5421489
[99,] 4.334886e-01 0.8669771557 0.5665114
[100,] 4.292910e-01 0.8585819934 0.5707090
[101,] 3.762464e-01 0.7524928116 0.6237536
[102,] 3.577925e-01 0.7155850118 0.6422075
[103,] 3.020925e-01 0.6041849571 0.6979075
[104,] 4.802231e-01 0.9604461713 0.5197769
[105,] 6.601277e-01 0.6797445082 0.3398723
[106,] 5.881090e-01 0.8237820793 0.4118910
[107,] 5.754182e-01 0.8491635269 0.4245818
[108,] 4.941352e-01 0.9882704261 0.5058648
[109,] 4.255268e-01 0.8510536221 0.5744732
[110,] 3.204492e-01 0.6408983727 0.6795508
[111,] 2.187206e-01 0.4374412642 0.7812794
[112,] 6.575537e-01 0.6848925795 0.3424463
> postscript(file="/var/www/html/rcomp/tmp/1fmf71229180489.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/2ty1t1229180489.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/3ydb71229180489.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/4l1iw1229180489.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/5hk4r1229180489.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
-2775.71538 -1214.71538 -925.11538 -1934.51538 -1521.81538 -1731.51538
7 8 9 10 11 12
-1239.51538 -652.81538 -799.01538 -1337.51538 -583.41538 -1844.01538
13 14 15 16 17 18
-2436.11538 -688.61538 -363.41538 -1163.51538 -421.91538 -1329.21538
19 20 21 22 23 24
-642.01538 38.48462 -559.01538 -1165.11538 40.48462 -1250.51538
25 26 27 28 29 30
-1778.81538 15.48462 -301.61538 -517.41538 -676.61538 -1664.41538
31 32 33 34 35 36
-1100.01538 427.88462 -845.51538 -1014.01538 252.78462 -1458.51538
37 38 39 40 41 42
-1299.61538 275.08462 329.18462 416.88462 952.48462 -160.71538
43 44 45 46 47 48
1307.68462 2500.98462 274.88462 1755.78462 1114.18462 104.78462
49 50 51 52 53 54
312.38462 1818.28462 1869.78462 2608.38462 2064.68462 2046.98462
55 56 57 58 59 60
2124.68462 2990.88462 1646.08462 2224.18462 2150.58462 426.48462
61 62 63 64 65 66
111.48462 1455.68462 1658.18462 1276.58462 803.98462 -1825.31071
67 68 69 70 71 72
-1535.71071 -314.81071 -950.01071 -1140.11071 -1174.21071 -1807.61071
73 74 75 76 77 78
-2821.21071 -872.91071 -86.11071 -1201.21071 -725.31071 -1061.11071
79 80 81 82 83 84
-854.51071 -32.81071 -950.01071 -1664.01071 -937.41071 -1722.51071
85 86 87 88 89 90
-3071.51071 -646.51071 145.48929 -1025.71071 -372.81071 -1232.21071
91 92 93 94 95 96
-586.31071 1199.08929 -370.31071 -1248.01071 1023.28929 -1191.01071
97 98 99 100 101 102
-1295.31071 766.58929 674.38929 556.48929 1209.68929 -212.91071
103 104 105 106 107 108
431.78929 2209.18929 946.58929 323.88929 1489.48929 -828.91071
109 110 111 112 113 114
-409.01071 1933.68929 806.78929 2270.88929 2565.48929 1724.78929
115 116 117 118 119 120
1855.48929 4506.08929 1259.78929 2369.68929 2524.78929 503.18929
121
870.78929
> postscript(file="/var/www/html/rcomp/tmp/6q0fy1229180489.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 -2775.71538 NA
1 -1214.71538 -2775.71538
2 -925.11538 -1214.71538
3 -1934.51538 -925.11538
4 -1521.81538 -1934.51538
5 -1731.51538 -1521.81538
6 -1239.51538 -1731.51538
7 -652.81538 -1239.51538
8 -799.01538 -652.81538
9 -1337.51538 -799.01538
10 -583.41538 -1337.51538
11 -1844.01538 -583.41538
12 -2436.11538 -1844.01538
13 -688.61538 -2436.11538
14 -363.41538 -688.61538
15 -1163.51538 -363.41538
16 -421.91538 -1163.51538
17 -1329.21538 -421.91538
18 -642.01538 -1329.21538
19 38.48462 -642.01538
20 -559.01538 38.48462
21 -1165.11538 -559.01538
22 40.48462 -1165.11538
23 -1250.51538 40.48462
24 -1778.81538 -1250.51538
25 15.48462 -1778.81538
26 -301.61538 15.48462
27 -517.41538 -301.61538
28 -676.61538 -517.41538
29 -1664.41538 -676.61538
30 -1100.01538 -1664.41538
31 427.88462 -1100.01538
32 -845.51538 427.88462
33 -1014.01538 -845.51538
34 252.78462 -1014.01538
35 -1458.51538 252.78462
36 -1299.61538 -1458.51538
37 275.08462 -1299.61538
38 329.18462 275.08462
39 416.88462 329.18462
40 952.48462 416.88462
41 -160.71538 952.48462
42 1307.68462 -160.71538
43 2500.98462 1307.68462
44 274.88462 2500.98462
45 1755.78462 274.88462
46 1114.18462 1755.78462
47 104.78462 1114.18462
48 312.38462 104.78462
49 1818.28462 312.38462
50 1869.78462 1818.28462
51 2608.38462 1869.78462
52 2064.68462 2608.38462
53 2046.98462 2064.68462
54 2124.68462 2046.98462
55 2990.88462 2124.68462
56 1646.08462 2990.88462
57 2224.18462 1646.08462
58 2150.58462 2224.18462
59 426.48462 2150.58462
60 111.48462 426.48462
61 1455.68462 111.48462
62 1658.18462 1455.68462
63 1276.58462 1658.18462
64 803.98462 1276.58462
65 -1825.31071 803.98462
66 -1535.71071 -1825.31071
67 -314.81071 -1535.71071
68 -950.01071 -314.81071
69 -1140.11071 -950.01071
70 -1174.21071 -1140.11071
71 -1807.61071 -1174.21071
72 -2821.21071 -1807.61071
73 -872.91071 -2821.21071
74 -86.11071 -872.91071
75 -1201.21071 -86.11071
76 -725.31071 -1201.21071
77 -1061.11071 -725.31071
78 -854.51071 -1061.11071
79 -32.81071 -854.51071
80 -950.01071 -32.81071
81 -1664.01071 -950.01071
82 -937.41071 -1664.01071
83 -1722.51071 -937.41071
84 -3071.51071 -1722.51071
85 -646.51071 -3071.51071
86 145.48929 -646.51071
87 -1025.71071 145.48929
88 -372.81071 -1025.71071
89 -1232.21071 -372.81071
90 -586.31071 -1232.21071
91 1199.08929 -586.31071
92 -370.31071 1199.08929
93 -1248.01071 -370.31071
94 1023.28929 -1248.01071
95 -1191.01071 1023.28929
96 -1295.31071 -1191.01071
97 766.58929 -1295.31071
98 674.38929 766.58929
99 556.48929 674.38929
100 1209.68929 556.48929
101 -212.91071 1209.68929
102 431.78929 -212.91071
103 2209.18929 431.78929
104 946.58929 2209.18929
105 323.88929 946.58929
106 1489.48929 323.88929
107 -828.91071 1489.48929
108 -409.01071 -828.91071
109 1933.68929 -409.01071
110 806.78929 1933.68929
111 2270.88929 806.78929
112 2565.48929 2270.88929
113 1724.78929 2565.48929
114 1855.48929 1724.78929
115 4506.08929 1855.48929
116 1259.78929 4506.08929
117 2369.68929 1259.78929
118 2524.78929 2369.68929
119 503.18929 2524.78929
120 870.78929 503.18929
121 NA 870.78929
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1214.71538 -2775.71538
[2,] -925.11538 -1214.71538
[3,] -1934.51538 -925.11538
[4,] -1521.81538 -1934.51538
[5,] -1731.51538 -1521.81538
[6,] -1239.51538 -1731.51538
[7,] -652.81538 -1239.51538
[8,] -799.01538 -652.81538
[9,] -1337.51538 -799.01538
[10,] -583.41538 -1337.51538
[11,] -1844.01538 -583.41538
[12,] -2436.11538 -1844.01538
[13,] -688.61538 -2436.11538
[14,] -363.41538 -688.61538
[15,] -1163.51538 -363.41538
[16,] -421.91538 -1163.51538
[17,] -1329.21538 -421.91538
[18,] -642.01538 -1329.21538
[19,] 38.48462 -642.01538
[20,] -559.01538 38.48462
[21,] -1165.11538 -559.01538
[22,] 40.48462 -1165.11538
[23,] -1250.51538 40.48462
[24,] -1778.81538 -1250.51538
[25,] 15.48462 -1778.81538
[26,] -301.61538 15.48462
[27,] -517.41538 -301.61538
[28,] -676.61538 -517.41538
[29,] -1664.41538 -676.61538
[30,] -1100.01538 -1664.41538
[31,] 427.88462 -1100.01538
[32,] -845.51538 427.88462
[33,] -1014.01538 -845.51538
[34,] 252.78462 -1014.01538
[35,] -1458.51538 252.78462
[36,] -1299.61538 -1458.51538
[37,] 275.08462 -1299.61538
[38,] 329.18462 275.08462
[39,] 416.88462 329.18462
[40,] 952.48462 416.88462
[41,] -160.71538 952.48462
[42,] 1307.68462 -160.71538
[43,] 2500.98462 1307.68462
[44,] 274.88462 2500.98462
[45,] 1755.78462 274.88462
[46,] 1114.18462 1755.78462
[47,] 104.78462 1114.18462
[48,] 312.38462 104.78462
[49,] 1818.28462 312.38462
[50,] 1869.78462 1818.28462
[51,] 2608.38462 1869.78462
[52,] 2064.68462 2608.38462
[53,] 2046.98462 2064.68462
[54,] 2124.68462 2046.98462
[55,] 2990.88462 2124.68462
[56,] 1646.08462 2990.88462
[57,] 2224.18462 1646.08462
[58,] 2150.58462 2224.18462
[59,] 426.48462 2150.58462
[60,] 111.48462 426.48462
[61,] 1455.68462 111.48462
[62,] 1658.18462 1455.68462
[63,] 1276.58462 1658.18462
[64,] 803.98462 1276.58462
[65,] -1825.31071 803.98462
[66,] -1535.71071 -1825.31071
[67,] -314.81071 -1535.71071
[68,] -950.01071 -314.81071
[69,] -1140.11071 -950.01071
[70,] -1174.21071 -1140.11071
[71,] -1807.61071 -1174.21071
[72,] -2821.21071 -1807.61071
[73,] -872.91071 -2821.21071
[74,] -86.11071 -872.91071
[75,] -1201.21071 -86.11071
[76,] -725.31071 -1201.21071
[77,] -1061.11071 -725.31071
[78,] -854.51071 -1061.11071
[79,] -32.81071 -854.51071
[80,] -950.01071 -32.81071
[81,] -1664.01071 -950.01071
[82,] -937.41071 -1664.01071
[83,] -1722.51071 -937.41071
[84,] -3071.51071 -1722.51071
[85,] -646.51071 -3071.51071
[86,] 145.48929 -646.51071
[87,] -1025.71071 145.48929
[88,] -372.81071 -1025.71071
[89,] -1232.21071 -372.81071
[90,] -586.31071 -1232.21071
[91,] 1199.08929 -586.31071
[92,] -370.31071 1199.08929
[93,] -1248.01071 -370.31071
[94,] 1023.28929 -1248.01071
[95,] -1191.01071 1023.28929
[96,] -1295.31071 -1191.01071
[97,] 766.58929 -1295.31071
[98,] 674.38929 766.58929
[99,] 556.48929 674.38929
[100,] 1209.68929 556.48929
[101,] -212.91071 1209.68929
[102,] 431.78929 -212.91071
[103,] 2209.18929 431.78929
[104,] 946.58929 2209.18929
[105,] 323.88929 946.58929
[106,] 1489.48929 323.88929
[107,] -828.91071 1489.48929
[108,] -409.01071 -828.91071
[109,] 1933.68929 -409.01071
[110,] 806.78929 1933.68929
[111,] 2270.88929 806.78929
[112,] 2565.48929 2270.88929
[113,] 1724.78929 2565.48929
[114,] 1855.48929 1724.78929
[115,] 4506.08929 1855.48929
[116,] 1259.78929 4506.08929
[117,] 2369.68929 1259.78929
[118,] 2524.78929 2369.68929
[119,] 503.18929 2524.78929
[120,] 870.78929 503.18929
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1214.71538 -2775.71538
2 -925.11538 -1214.71538
3 -1934.51538 -925.11538
4 -1521.81538 -1934.51538
5 -1731.51538 -1521.81538
6 -1239.51538 -1731.51538
7 -652.81538 -1239.51538
8 -799.01538 -652.81538
9 -1337.51538 -799.01538
10 -583.41538 -1337.51538
11 -1844.01538 -583.41538
12 -2436.11538 -1844.01538
13 -688.61538 -2436.11538
14 -363.41538 -688.61538
15 -1163.51538 -363.41538
16 -421.91538 -1163.51538
17 -1329.21538 -421.91538
18 -642.01538 -1329.21538
19 38.48462 -642.01538
20 -559.01538 38.48462
21 -1165.11538 -559.01538
22 40.48462 -1165.11538
23 -1250.51538 40.48462
24 -1778.81538 -1250.51538
25 15.48462 -1778.81538
26 -301.61538 15.48462
27 -517.41538 -301.61538
28 -676.61538 -517.41538
29 -1664.41538 -676.61538
30 -1100.01538 -1664.41538
31 427.88462 -1100.01538
32 -845.51538 427.88462
33 -1014.01538 -845.51538
34 252.78462 -1014.01538
35 -1458.51538 252.78462
36 -1299.61538 -1458.51538
37 275.08462 -1299.61538
38 329.18462 275.08462
39 416.88462 329.18462
40 952.48462 416.88462
41 -160.71538 952.48462
42 1307.68462 -160.71538
43 2500.98462 1307.68462
44 274.88462 2500.98462
45 1755.78462 274.88462
46 1114.18462 1755.78462
47 104.78462 1114.18462
48 312.38462 104.78462
49 1818.28462 312.38462
50 1869.78462 1818.28462
51 2608.38462 1869.78462
52 2064.68462 2608.38462
53 2046.98462 2064.68462
54 2124.68462 2046.98462
55 2990.88462 2124.68462
56 1646.08462 2990.88462
57 2224.18462 1646.08462
58 2150.58462 2224.18462
59 426.48462 2150.58462
60 111.48462 426.48462
61 1455.68462 111.48462
62 1658.18462 1455.68462
63 1276.58462 1658.18462
64 803.98462 1276.58462
65 -1825.31071 803.98462
66 -1535.71071 -1825.31071
67 -314.81071 -1535.71071
68 -950.01071 -314.81071
69 -1140.11071 -950.01071
70 -1174.21071 -1140.11071
71 -1807.61071 -1174.21071
72 -2821.21071 -1807.61071
73 -872.91071 -2821.21071
74 -86.11071 -872.91071
75 -1201.21071 -86.11071
76 -725.31071 -1201.21071
77 -1061.11071 -725.31071
78 -854.51071 -1061.11071
79 -32.81071 -854.51071
80 -950.01071 -32.81071
81 -1664.01071 -950.01071
82 -937.41071 -1664.01071
83 -1722.51071 -937.41071
84 -3071.51071 -1722.51071
85 -646.51071 -3071.51071
86 145.48929 -646.51071
87 -1025.71071 145.48929
88 -372.81071 -1025.71071
89 -1232.21071 -372.81071
90 -586.31071 -1232.21071
91 1199.08929 -586.31071
92 -370.31071 1199.08929
93 -1248.01071 -370.31071
94 1023.28929 -1248.01071
95 -1191.01071 1023.28929
96 -1295.31071 -1191.01071
97 766.58929 -1295.31071
98 674.38929 766.58929
99 556.48929 674.38929
100 1209.68929 556.48929
101 -212.91071 1209.68929
102 431.78929 -212.91071
103 2209.18929 431.78929
104 946.58929 2209.18929
105 323.88929 946.58929
106 1489.48929 323.88929
107 -828.91071 1489.48929
108 -409.01071 -828.91071
109 1933.68929 -409.01071
110 806.78929 1933.68929
111 2270.88929 806.78929
112 2565.48929 2270.88929
113 1724.78929 2565.48929
114 1855.48929 1724.78929
115 4506.08929 1855.48929
116 1259.78929 4506.08929
117 2369.68929 1259.78929
118 2524.78929 2369.68929
119 503.18929 2524.78929
120 870.78929 503.18929
> 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/7u3xq1229180489.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/8jnzh1229180489.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/9i4f61229180489.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/10h6p61229180489.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/118mul1229180490.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/12i6l51229180490.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/13x5xm1229180490.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/14czgy1229180490.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/15y2an1229180490.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/16vjzq1229180490.tab")
+ }
>
> system("convert tmp/1fmf71229180489.ps tmp/1fmf71229180489.png")
> system("convert tmp/2ty1t1229180489.ps tmp/2ty1t1229180489.png")
> system("convert tmp/3ydb71229180489.ps tmp/3ydb71229180489.png")
> system("convert tmp/4l1iw1229180489.ps tmp/4l1iw1229180489.png")
> system("convert tmp/5hk4r1229180489.ps tmp/5hk4r1229180489.png")
> system("convert tmp/6q0fy1229180489.ps tmp/6q0fy1229180489.png")
> system("convert tmp/7u3xq1229180489.ps tmp/7u3xq1229180489.png")
> system("convert tmp/8jnzh1229180489.ps tmp/8jnzh1229180489.png")
> system("convert tmp/9i4f61229180489.ps tmp/9i4f61229180489.png")
> system("convert tmp/10h6p61229180489.ps tmp/10h6p61229180489.png")
>
>
> proc.time()
user system elapsed
3.200 1.683 3.690