R version 2.11.1 (2010-05-31)
Copyright (C) 2010 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(12008,0,9169,0,8788,0,8417,0,8247,0,8197,0,8236,0,8253,0,7733,0,8366,0,8626,0,8863,0,10102,0,8463,0,9114,0,8563,0,8872,0,8301,0,8301,0,8278,0,7736,0,7973,0,8268,0,9476,0,11100,0,8962,0,9173,0,8738,0,8459,0,8078,0,8411,0,8291,0,7810,0,8616,0,8312,0,9692,0,9911,0,8915,0,9452,0,9112,0,8472,0,8230,0,8384,0,8625,0,8221,0,8649,0,8625,0,10443,0,10357,1,8586,1,8892,1,8329,1,8101,1,7922,1,8120,1,7838,1,7735,1,8406,1,8209,1,9451,1,10041,1,9411,1,10405,1,8467,1,8464,1,8102,1,7627,1,7513,1,7510,1,8291,1,8064,1,9383,1,9706,1,8579,1,9474,1,8318,1,8213,1,8059,1,9111,1,7708,1,7680,1,8014,1,8007,1,8718,1,9486,1,9113,1,9025,1,8476,1,7952,1,7759,1,7835,1,7600,1,7651,1,8319,1,8812,1,8630,1),dim=c(2,96),dimnames=list(c('Sterftes','Dummy1'),1:96))
> y <- array(NA,dim=c(2,96),dimnames=list(c('Sterftes','Dummy1'),1:96))
> 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 = '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
> 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
Sterftes Dummy1 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 12008 0 1 0 0 0 0 0 0 0 0 0 0
2 9169 0 0 1 0 0 0 0 0 0 0 0 0
3 8788 0 0 0 1 0 0 0 0 0 0 0 0
4 8417 0 0 0 0 1 0 0 0 0 0 0 0
5 8247 0 0 0 0 0 1 0 0 0 0 0 0
6 8197 0 0 0 0 0 0 1 0 0 0 0 0
7 8236 0 0 0 0 0 0 0 1 0 0 0 0
8 8253 0 0 0 0 0 0 0 0 1 0 0 0
9 7733 0 0 0 0 0 0 0 0 0 1 0 0
10 8366 0 0 0 0 0 0 0 0 0 0 1 0
11 8626 0 0 0 0 0 0 0 0 0 0 0 1
12 8863 0 0 0 0 0 0 0 0 0 0 0 0
13 10102 0 1 0 0 0 0 0 0 0 0 0 0
14 8463 0 0 1 0 0 0 0 0 0 0 0 0
15 9114 0 0 0 1 0 0 0 0 0 0 0 0
16 8563 0 0 0 0 1 0 0 0 0 0 0 0
17 8872 0 0 0 0 0 1 0 0 0 0 0 0
18 8301 0 0 0 0 0 0 1 0 0 0 0 0
19 8301 0 0 0 0 0 0 0 1 0 0 0 0
20 8278 0 0 0 0 0 0 0 0 1 0 0 0
21 7736 0 0 0 0 0 0 0 0 0 1 0 0
22 7973 0 0 0 0 0 0 0 0 0 0 1 0
23 8268 0 0 0 0 0 0 0 0 0 0 0 1
24 9476 0 0 0 0 0 0 0 0 0 0 0 0
25 11100 0 1 0 0 0 0 0 0 0 0 0 0
26 8962 0 0 1 0 0 0 0 0 0 0 0 0
27 9173 0 0 0 1 0 0 0 0 0 0 0 0
28 8738 0 0 0 0 1 0 0 0 0 0 0 0
29 8459 0 0 0 0 0 1 0 0 0 0 0 0
30 8078 0 0 0 0 0 0 1 0 0 0 0 0
31 8411 0 0 0 0 0 0 0 1 0 0 0 0
32 8291 0 0 0 0 0 0 0 0 1 0 0 0
33 7810 0 0 0 0 0 0 0 0 0 1 0 0
34 8616 0 0 0 0 0 0 0 0 0 0 1 0
35 8312 0 0 0 0 0 0 0 0 0 0 0 1
36 9692 0 0 0 0 0 0 0 0 0 0 0 0
37 9911 0 1 0 0 0 0 0 0 0 0 0 0
38 8915 0 0 1 0 0 0 0 0 0 0 0 0
39 9452 0 0 0 1 0 0 0 0 0 0 0 0
40 9112 0 0 0 0 1 0 0 0 0 0 0 0
41 8472 0 0 0 0 0 1 0 0 0 0 0 0
42 8230 0 0 0 0 0 0 1 0 0 0 0 0
43 8384 0 0 0 0 0 0 0 1 0 0 0 0
44 8625 0 0 0 0 0 0 0 0 1 0 0 0
45 8221 0 0 0 0 0 0 0 0 0 1 0 0
46 8649 0 0 0 0 0 0 0 0 0 0 1 0
47 8625 0 0 0 0 0 0 0 0 0 0 0 1
48 10443 0 0 0 0 0 0 0 0 0 0 0 0
49 10357 1 1 0 0 0 0 0 0 0 0 0 0
50 8586 1 0 1 0 0 0 0 0 0 0 0 0
51 8892 1 0 0 1 0 0 0 0 0 0 0 0
52 8329 1 0 0 0 1 0 0 0 0 0 0 0
53 8101 1 0 0 0 0 1 0 0 0 0 0 0
54 7922 1 0 0 0 0 0 1 0 0 0 0 0
55 8120 1 0 0 0 0 0 0 1 0 0 0 0
56 7838 1 0 0 0 0 0 0 0 1 0 0 0
57 7735 1 0 0 0 0 0 0 0 0 1 0 0
58 8406 1 0 0 0 0 0 0 0 0 0 1 0
59 8209 1 0 0 0 0 0 0 0 0 0 0 1
60 9451 1 0 0 0 0 0 0 0 0 0 0 0
61 10041 1 1 0 0 0 0 0 0 0 0 0 0
62 9411 1 0 1 0 0 0 0 0 0 0 0 0
63 10405 1 0 0 1 0 0 0 0 0 0 0 0
64 8467 1 0 0 0 1 0 0 0 0 0 0 0
65 8464 1 0 0 0 0 1 0 0 0 0 0 0
66 8102 1 0 0 0 0 0 1 0 0 0 0 0
67 7627 1 0 0 0 0 0 0 1 0 0 0 0
68 7513 1 0 0 0 0 0 0 0 1 0 0 0
69 7510 1 0 0 0 0 0 0 0 0 1 0 0
70 8291 1 0 0 0 0 0 0 0 0 0 1 0
71 8064 1 0 0 0 0 0 0 0 0 0 0 1
72 9383 1 0 0 0 0 0 0 0 0 0 0 0
73 9706 1 1 0 0 0 0 0 0 0 0 0 0
74 8579 1 0 1 0 0 0 0 0 0 0 0 0
75 9474 1 0 0 1 0 0 0 0 0 0 0 0
76 8318 1 0 0 0 1 0 0 0 0 0 0 0
77 8213 1 0 0 0 0 1 0 0 0 0 0 0
78 8059 1 0 0 0 0 0 1 0 0 0 0 0
79 9111 1 0 0 0 0 0 0 1 0 0 0 0
80 7708 1 0 0 0 0 0 0 0 1 0 0 0
81 7680 1 0 0 0 0 0 0 0 0 1 0 0
82 8014 1 0 0 0 0 0 0 0 0 0 1 0
83 8007 1 0 0 0 0 0 0 0 0 0 0 1
84 8718 1 0 0 0 0 0 0 0 0 0 0 0
85 9486 1 1 0 0 0 0 0 0 0 0 0 0
86 9113 1 0 1 0 0 0 0 0 0 0 0 0
87 9025 1 0 0 1 0 0 0 0 0 0 0 0
88 8476 1 0 0 0 1 0 0 0 0 0 0 0
89 7952 1 0 0 0 0 1 0 0 0 0 0 0
90 7759 1 0 0 0 0 0 1 0 0 0 0 0
91 7835 1 0 0 0 0 0 0 1 0 0 0 0
92 7600 1 0 0 0 0 0 0 0 1 0 0 0
93 7651 1 0 0 0 0 0 0 0 0 1 0 0
94 8319 1 0 0 0 0 0 0 0 0 0 1 0
95 8812 1 0 0 0 0 0 0 0 0 0 0 1
96 8630 1 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Dummy1 M1 M2 M3 M4
9473.27 -282.54 1006.88 -432.25 -41.62 -779.50
M5 M6 M7 M8 M9 M10
-984.50 -1251.00 -1078.87 -1318.75 -1572.50 -1002.75
M11
-966.62
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-711.6 -179.8 -21.5 128.7 1527.9
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9473.27 145.96 64.903 < 2e-16 ***
Dummy1 -282.54 80.96 -3.490 0.000777 ***
M1 1006.88 198.32 5.077 2.31e-06 ***
M2 -432.25 198.32 -2.180 0.032125 *
M3 -41.62 198.32 -0.210 0.834271
M4 -779.50 198.32 -3.930 0.000175 ***
M5 -984.50 198.32 -4.964 3.63e-06 ***
M6 -1251.00 198.32 -6.308 1.31e-08 ***
M7 -1078.87 198.32 -5.440 5.27e-07 ***
M8 -1318.75 198.32 -6.650 2.91e-09 ***
M9 -1572.50 198.32 -7.929 9.01e-12 ***
M10 -1002.75 198.32 -5.056 2.51e-06 ***
M11 -966.62 198.32 -4.874 5.18e-06 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 396.6 on 83 degrees of freedom
Multiple R-squared: 0.7858, Adjusted R-squared: 0.7549
F-statistic: 25.38 on 12 and 83 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.9982150 0.003570076 0.001785038
[2,] 0.9974064 0.005187216 0.002593608
[3,] 0.9938450 0.012310075 0.006155037
[4,] 0.9871835 0.025632949 0.012816475
[5,] 0.9756027 0.048794671 0.024397335
[6,] 0.9582542 0.083491532 0.041745766
[7,] 0.9514979 0.097004189 0.048502094
[8,] 0.9345649 0.130870226 0.065435113
[9,] 0.9285528 0.142894307 0.071447153
[10,] 0.9300073 0.139985311 0.069992655
[11,] 0.9016470 0.196705975 0.098352987
[12,] 0.8865496 0.226900783 0.113450391
[13,] 0.8520874 0.295825296 0.147912648
[14,] 0.8030999 0.393800279 0.196900140
[15,] 0.7555279 0.488944190 0.244472095
[16,] 0.6964069 0.607186141 0.303593071
[17,] 0.6279047 0.744190538 0.372095269
[18,] 0.5647360 0.870528087 0.435264044
[19,] 0.5398605 0.920278940 0.460139470
[20,] 0.4885107 0.977021497 0.511489252
[21,] 0.4806732 0.961346393 0.519326804
[22,] 0.7318160 0.536367903 0.268183952
[23,] 0.7023882 0.595223563 0.297611782
[24,] 0.7115048 0.576990322 0.288495161
[25,] 0.7036197 0.592760685 0.296380342
[26,] 0.6530005 0.693998911 0.346999456
[27,] 0.6060629 0.787874258 0.393937129
[28,] 0.5759736 0.848052769 0.424026385
[29,] 0.5417429 0.916514165 0.458257082
[30,] 0.5154938 0.969012390 0.484506195
[31,] 0.4934820 0.986963995 0.506518002
[32,] 0.5319619 0.936076122 0.468038061
[33,] 0.6593794 0.681241242 0.340620621
[34,] 0.6586599 0.682680270 0.341340135
[35,] 0.6313928 0.737214428 0.368607214
[36,] 0.6711698 0.657660309 0.328830154
[37,] 0.6088150 0.782370001 0.391185000
[38,] 0.5444103 0.911179481 0.455589740
[39,] 0.4765461 0.953092123 0.523453939
[40,] 0.4110363 0.822072673 0.588963664
[41,] 0.3604859 0.720971744 0.639514128
[42,] 0.3049270 0.609854059 0.695072970
[43,] 0.2647683 0.529536512 0.735231744
[44,] 0.2112963 0.422592528 0.788703736
[45,] 0.2066068 0.413213629 0.793393186
[46,] 0.2030408 0.406081678 0.796959161
[47,] 0.2715744 0.543148772 0.728425614
[48,] 0.7362472 0.527505510 0.263752755
[49,] 0.6701532 0.659693550 0.329846775
[50,] 0.6347097 0.730580622 0.365290311
[51,] 0.5674102 0.865179540 0.432589770
[52,] 0.7066332 0.586733594 0.293366797
[53,] 0.6637319 0.672536226 0.336268113
[54,] 0.5912257 0.817548665 0.408774332
[55,] 0.5088785 0.982243048 0.491121524
[56,] 0.4577732 0.915546413 0.542226794
[57,] 0.5314355 0.937129011 0.468564506
[58,] 0.4862583 0.972516547 0.513741726
[59,] 0.4642388 0.928477548 0.535761226
[60,] 0.4231123 0.846224572 0.576887714
[61,] 0.3250657 0.650131457 0.674934272
[62,] 0.2423851 0.484770262 0.757614869
[63,] 0.1720665 0.344133054 0.827933473
[64,] 0.6731696 0.653660749 0.326830374
[65,] 0.5107009 0.978598101 0.489299050
> postscript(file="/var/www/rcomp/tmp/1zx1x1290797650.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/rcomp/tmp/29o0i1290797650.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/rcomp/tmp/39o0i1290797650.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/rcomp/tmp/49o0i1290797650.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/rcomp/tmp/59o0i1290797650.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 = 96
Frequency = 1
1 2 3 4 5 6
1527.854167 127.979167 -643.645833 -276.770833 -241.770833 -25.270833
7 8 9 10 11 12
-158.395833 98.479167 -167.770833 -104.520833 119.354167 -610.270833
13 14 15 16 17 18
-378.145833 -578.020833 -317.645833 -130.770833 383.229167 78.729167
19 20 21 22 23 24
-93.395833 123.479167 -164.770833 -497.520833 -238.645833 2.729167
25 26 27 28 29 30
619.854167 -79.020833 -258.645833 44.229167 -29.770833 -144.270833
31 32 33 34 35 36
16.604167 136.479167 -90.770833 145.479167 -194.645833 218.729167
37 38 39 40 41 42
-569.145833 -126.020833 20.354167 418.229167 -16.770833 7.729167
43 44 45 46 47 48
-10.395833 470.479167 320.229167 178.479167 118.354167 969.729167
49 50 51 52 53 54
159.395833 -172.479167 -257.104167 -82.229167 -105.229167 -17.729167
55 56 57 58 59 60
8.145833 -33.979167 116.770833 218.020833 -15.104167 260.270833
61 62 63 64 65 66
-156.604167 652.520833 1255.895833 55.770833 257.770833 162.270833
67 68 69 70 71 72
-484.854167 -358.979167 -108.229167 103.020833 -160.104167 192.270833
73 74 75 76 77 78
-491.604167 -179.479167 324.895833 -93.229167 6.770833 119.270833
79 80 81 82 83 84
999.145833 -163.979167 61.770833 -173.979167 -217.104167 -472.729167
85 86 87 88 89 90
-711.604167 354.520833 -124.104167 64.770833 -254.229167 -180.729167
91 92 93 94 95 96
-276.854167 -271.979167 32.770833 131.020833 587.895833 -560.729167
> postscript(file="/var/www/rcomp/tmp/6kxh21290797650.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 = 96
Frequency = 1
lag(myerror, k = 1) myerror
0 1527.854167 NA
1 127.979167 1527.854167
2 -643.645833 127.979167
3 -276.770833 -643.645833
4 -241.770833 -276.770833
5 -25.270833 -241.770833
6 -158.395833 -25.270833
7 98.479167 -158.395833
8 -167.770833 98.479167
9 -104.520833 -167.770833
10 119.354167 -104.520833
11 -610.270833 119.354167
12 -378.145833 -610.270833
13 -578.020833 -378.145833
14 -317.645833 -578.020833
15 -130.770833 -317.645833
16 383.229167 -130.770833
17 78.729167 383.229167
18 -93.395833 78.729167
19 123.479167 -93.395833
20 -164.770833 123.479167
21 -497.520833 -164.770833
22 -238.645833 -497.520833
23 2.729167 -238.645833
24 619.854167 2.729167
25 -79.020833 619.854167
26 -258.645833 -79.020833
27 44.229167 -258.645833
28 -29.770833 44.229167
29 -144.270833 -29.770833
30 16.604167 -144.270833
31 136.479167 16.604167
32 -90.770833 136.479167
33 145.479167 -90.770833
34 -194.645833 145.479167
35 218.729167 -194.645833
36 -569.145833 218.729167
37 -126.020833 -569.145833
38 20.354167 -126.020833
39 418.229167 20.354167
40 -16.770833 418.229167
41 7.729167 -16.770833
42 -10.395833 7.729167
43 470.479167 -10.395833
44 320.229167 470.479167
45 178.479167 320.229167
46 118.354167 178.479167
47 969.729167 118.354167
48 159.395833 969.729167
49 -172.479167 159.395833
50 -257.104167 -172.479167
51 -82.229167 -257.104167
52 -105.229167 -82.229167
53 -17.729167 -105.229167
54 8.145833 -17.729167
55 -33.979167 8.145833
56 116.770833 -33.979167
57 218.020833 116.770833
58 -15.104167 218.020833
59 260.270833 -15.104167
60 -156.604167 260.270833
61 652.520833 -156.604167
62 1255.895833 652.520833
63 55.770833 1255.895833
64 257.770833 55.770833
65 162.270833 257.770833
66 -484.854167 162.270833
67 -358.979167 -484.854167
68 -108.229167 -358.979167
69 103.020833 -108.229167
70 -160.104167 103.020833
71 192.270833 -160.104167
72 -491.604167 192.270833
73 -179.479167 -491.604167
74 324.895833 -179.479167
75 -93.229167 324.895833
76 6.770833 -93.229167
77 119.270833 6.770833
78 999.145833 119.270833
79 -163.979167 999.145833
80 61.770833 -163.979167
81 -173.979167 61.770833
82 -217.104167 -173.979167
83 -472.729167 -217.104167
84 -711.604167 -472.729167
85 354.520833 -711.604167
86 -124.104167 354.520833
87 64.770833 -124.104167
88 -254.229167 64.770833
89 -180.729167 -254.229167
90 -276.854167 -180.729167
91 -271.979167 -276.854167
92 32.770833 -271.979167
93 131.020833 32.770833
94 587.895833 131.020833
95 -560.729167 587.895833
96 NA -560.729167
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 127.979167 1527.854167
[2,] -643.645833 127.979167
[3,] -276.770833 -643.645833
[4,] -241.770833 -276.770833
[5,] -25.270833 -241.770833
[6,] -158.395833 -25.270833
[7,] 98.479167 -158.395833
[8,] -167.770833 98.479167
[9,] -104.520833 -167.770833
[10,] 119.354167 -104.520833
[11,] -610.270833 119.354167
[12,] -378.145833 -610.270833
[13,] -578.020833 -378.145833
[14,] -317.645833 -578.020833
[15,] -130.770833 -317.645833
[16,] 383.229167 -130.770833
[17,] 78.729167 383.229167
[18,] -93.395833 78.729167
[19,] 123.479167 -93.395833
[20,] -164.770833 123.479167
[21,] -497.520833 -164.770833
[22,] -238.645833 -497.520833
[23,] 2.729167 -238.645833
[24,] 619.854167 2.729167
[25,] -79.020833 619.854167
[26,] -258.645833 -79.020833
[27,] 44.229167 -258.645833
[28,] -29.770833 44.229167
[29,] -144.270833 -29.770833
[30,] 16.604167 -144.270833
[31,] 136.479167 16.604167
[32,] -90.770833 136.479167
[33,] 145.479167 -90.770833
[34,] -194.645833 145.479167
[35,] 218.729167 -194.645833
[36,] -569.145833 218.729167
[37,] -126.020833 -569.145833
[38,] 20.354167 -126.020833
[39,] 418.229167 20.354167
[40,] -16.770833 418.229167
[41,] 7.729167 -16.770833
[42,] -10.395833 7.729167
[43,] 470.479167 -10.395833
[44,] 320.229167 470.479167
[45,] 178.479167 320.229167
[46,] 118.354167 178.479167
[47,] 969.729167 118.354167
[48,] 159.395833 969.729167
[49,] -172.479167 159.395833
[50,] -257.104167 -172.479167
[51,] -82.229167 -257.104167
[52,] -105.229167 -82.229167
[53,] -17.729167 -105.229167
[54,] 8.145833 -17.729167
[55,] -33.979167 8.145833
[56,] 116.770833 -33.979167
[57,] 218.020833 116.770833
[58,] -15.104167 218.020833
[59,] 260.270833 -15.104167
[60,] -156.604167 260.270833
[61,] 652.520833 -156.604167
[62,] 1255.895833 652.520833
[63,] 55.770833 1255.895833
[64,] 257.770833 55.770833
[65,] 162.270833 257.770833
[66,] -484.854167 162.270833
[67,] -358.979167 -484.854167
[68,] -108.229167 -358.979167
[69,] 103.020833 -108.229167
[70,] -160.104167 103.020833
[71,] 192.270833 -160.104167
[72,] -491.604167 192.270833
[73,] -179.479167 -491.604167
[74,] 324.895833 -179.479167
[75,] -93.229167 324.895833
[76,] 6.770833 -93.229167
[77,] 119.270833 6.770833
[78,] 999.145833 119.270833
[79,] -163.979167 999.145833
[80,] 61.770833 -163.979167
[81,] -173.979167 61.770833
[82,] -217.104167 -173.979167
[83,] -472.729167 -217.104167
[84,] -711.604167 -472.729167
[85,] 354.520833 -711.604167
[86,] -124.104167 354.520833
[87,] 64.770833 -124.104167
[88,] -254.229167 64.770833
[89,] -180.729167 -254.229167
[90,] -276.854167 -180.729167
[91,] -271.979167 -276.854167
[92,] 32.770833 -271.979167
[93,] 131.020833 32.770833
[94,] 587.895833 131.020833
[95,] -560.729167 587.895833
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 127.979167 1527.854167
2 -643.645833 127.979167
3 -276.770833 -643.645833
4 -241.770833 -276.770833
5 -25.270833 -241.770833
6 -158.395833 -25.270833
7 98.479167 -158.395833
8 -167.770833 98.479167
9 -104.520833 -167.770833
10 119.354167 -104.520833
11 -610.270833 119.354167
12 -378.145833 -610.270833
13 -578.020833 -378.145833
14 -317.645833 -578.020833
15 -130.770833 -317.645833
16 383.229167 -130.770833
17 78.729167 383.229167
18 -93.395833 78.729167
19 123.479167 -93.395833
20 -164.770833 123.479167
21 -497.520833 -164.770833
22 -238.645833 -497.520833
23 2.729167 -238.645833
24 619.854167 2.729167
25 -79.020833 619.854167
26 -258.645833 -79.020833
27 44.229167 -258.645833
28 -29.770833 44.229167
29 -144.270833 -29.770833
30 16.604167 -144.270833
31 136.479167 16.604167
32 -90.770833 136.479167
33 145.479167 -90.770833
34 -194.645833 145.479167
35 218.729167 -194.645833
36 -569.145833 218.729167
37 -126.020833 -569.145833
38 20.354167 -126.020833
39 418.229167 20.354167
40 -16.770833 418.229167
41 7.729167 -16.770833
42 -10.395833 7.729167
43 470.479167 -10.395833
44 320.229167 470.479167
45 178.479167 320.229167
46 118.354167 178.479167
47 969.729167 118.354167
48 159.395833 969.729167
49 -172.479167 159.395833
50 -257.104167 -172.479167
51 -82.229167 -257.104167
52 -105.229167 -82.229167
53 -17.729167 -105.229167
54 8.145833 -17.729167
55 -33.979167 8.145833
56 116.770833 -33.979167
57 218.020833 116.770833
58 -15.104167 218.020833
59 260.270833 -15.104167
60 -156.604167 260.270833
61 652.520833 -156.604167
62 1255.895833 652.520833
63 55.770833 1255.895833
64 257.770833 55.770833
65 162.270833 257.770833
66 -484.854167 162.270833
67 -358.979167 -484.854167
68 -108.229167 -358.979167
69 103.020833 -108.229167
70 -160.104167 103.020833
71 192.270833 -160.104167
72 -491.604167 192.270833
73 -179.479167 -491.604167
74 324.895833 -179.479167
75 -93.229167 324.895833
76 6.770833 -93.229167
77 119.270833 6.770833
78 999.145833 119.270833
79 -163.979167 999.145833
80 61.770833 -163.979167
81 -173.979167 61.770833
82 -217.104167 -173.979167
83 -472.729167 -217.104167
84 -711.604167 -472.729167
85 354.520833 -711.604167
86 -124.104167 354.520833
87 64.770833 -124.104167
88 -254.229167 64.770833
89 -180.729167 -254.229167
90 -276.854167 -180.729167
91 -271.979167 -276.854167
92 32.770833 -271.979167
93 131.020833 32.770833
94 587.895833 131.020833
95 -560.729167 587.895833
> 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/rcomp/tmp/7v6zo1290797650.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/rcomp/tmp/8v6zo1290797650.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/rcomp/tmp/9v6zo1290797650.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')
hat values (leverages) are all = 0.1354167
and there are no factor predictors; no plot no. 5
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/rcomp/tmp/10g8jl1290797651.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/1118z91290797651.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/rcomp/tmp/12n9ff1290797651.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/rcomp/tmp/1310do1290797651.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/rcomp/tmp/1441cu1290797651.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/rcomp/tmp/157kaz1290797651.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/rcomp/tmp/16mu881290797651.tab")
+ }
>
> try(system("convert tmp/1zx1x1290797650.ps tmp/1zx1x1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/29o0i1290797650.ps tmp/29o0i1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/39o0i1290797650.ps tmp/39o0i1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/49o0i1290797650.ps tmp/49o0i1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/59o0i1290797650.ps tmp/59o0i1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/6kxh21290797650.ps tmp/6kxh21290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/7v6zo1290797650.ps tmp/7v6zo1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/8v6zo1290797650.ps tmp/8v6zo1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/9v6zo1290797650.ps tmp/9v6zo1290797650.png",intern=TRUE))
character(0)
> try(system("convert tmp/10g8jl1290797651.ps tmp/10g8jl1290797651.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.410 0.780 5.171