R version 2.9.0 (2009-04-17)
Copyright (C) 2009 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(6.5
+ ,501
+ ,6.7
+ ,6.7
+ ,6.9
+ ,7.0
+ ,6.4
+ ,507
+ ,6.5
+ ,6.7
+ ,6.7
+ ,6.9
+ ,6.5
+ ,569
+ ,6.4
+ ,6.5
+ ,6.7
+ ,6.7
+ ,6.5
+ ,580
+ ,6.5
+ ,6.4
+ ,6.5
+ ,6.7
+ ,6.5
+ ,578
+ ,6.5
+ ,6.5
+ ,6.4
+ ,6.5
+ ,6.7
+ ,565
+ ,6.5
+ ,6.5
+ ,6.5
+ ,6.4
+ ,6.8
+ ,547
+ ,6.7
+ ,6.5
+ ,6.5
+ ,6.5
+ ,7.2
+ ,555
+ ,6.8
+ ,6.7
+ ,6.5
+ ,6.5
+ ,7.6
+ ,562
+ ,7.2
+ ,6.8
+ ,6.7
+ ,6.5
+ ,7.6
+ ,561
+ ,7.6
+ ,7.2
+ ,6.8
+ ,6.7
+ ,7.2
+ ,555
+ ,7.6
+ ,7.6
+ ,7.2
+ ,6.8
+ ,6.4
+ ,544
+ ,7.2
+ ,7.6
+ ,7.6
+ ,7.2
+ ,6.1
+ ,537
+ ,6.4
+ ,7.2
+ ,7.6
+ ,7.6
+ ,6.3
+ ,543
+ ,6.1
+ ,6.4
+ ,7.2
+ ,7.6
+ ,7.1
+ ,594
+ ,6.3
+ ,6.1
+ ,6.4
+ ,7.2
+ ,7.5
+ ,611
+ ,7.1
+ ,6.3
+ ,6.1
+ ,6.4
+ ,7.4
+ ,613
+ ,7.5
+ ,7.1
+ ,6.3
+ ,6.1
+ ,7.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+ ,5.9
+ ,6.2
+ ,6.2
+ ,528
+ ,5.6
+ ,5.4
+ ,5.7
+ ,5.9
+ ,6.3
+ ,534
+ ,6.2
+ ,5.6
+ ,5.4
+ ,5.7
+ ,6.0
+ ,518
+ ,6.3
+ ,6.2
+ ,5.6
+ ,5.4
+ ,5.6
+ ,506
+ ,6.0
+ ,6.3
+ ,6.2
+ ,5.6
+ ,5.5
+ ,502
+ ,5.6
+ ,6.0
+ ,6.3
+ ,6.2
+ ,5.9
+ ,516
+ ,5.5
+ ,5.6
+ ,6.0
+ ,6.3)
+ ,dim=c(6
+ ,68)
+ ,dimnames=list(c('wkgo'
+ ,'werkl'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:68))
> y <- array(NA,dim=c(6,68),dimnames=list(c('wkgo','werkl','Y1','Y2','Y3','Y4'),1:68))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
wkgo werkl Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 6.5 501 6.7 6.7 6.9 7.0 1 0 0 0 0 0 0 0 0 0 0 1
2 6.4 507 6.5 6.7 6.7 6.9 0 1 0 0 0 0 0 0 0 0 0 2
3 6.5 569 6.4 6.5 6.7 6.7 0 0 1 0 0 0 0 0 0 0 0 3
4 6.5 580 6.5 6.4 6.5 6.7 0 0 0 1 0 0 0 0 0 0 0 4
5 6.5 578 6.5 6.5 6.4 6.5 0 0 0 0 1 0 0 0 0 0 0 5
6 6.7 565 6.5 6.5 6.5 6.4 0 0 0 0 0 1 0 0 0 0 0 6
7 6.8 547 6.7 6.5 6.5 6.5 0 0 0 0 0 0 1 0 0 0 0 7
8 7.2 555 6.8 6.7 6.5 6.5 0 0 0 0 0 0 0 1 0 0 0 8
9 7.6 562 7.2 6.8 6.7 6.5 0 0 0 0 0 0 0 0 1 0 0 9
10 7.6 561 7.6 7.2 6.8 6.7 0 0 0 0 0 0 0 0 0 1 0 10
11 7.2 555 7.6 7.6 7.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5.9 527 5.7 5.9 6.1 6.1 0 0 0 0 0 1 0 0 0 0 0 54
55 5.9 510 5.9 5.7 5.9 6.1 0 0 0 0 0 0 1 0 0 0 0 55
56 6.1 514 5.9 5.9 5.7 5.9 0 0 0 0 0 0 0 1 0 0 0 56
57 6.3 517 6.1 5.9 5.9 5.7 0 0 0 0 0 0 0 0 1 0 0 57
58 6.2 508 6.3 6.1 5.9 5.9 0 0 0 0 0 0 0 0 0 1 0 58
59 5.9 493 6.2 6.3 6.1 5.9 0 0 0 0 0 0 0 0 0 0 1 59
60 5.7 490 5.9 6.2 6.3 6.1 0 0 0 0 0 0 0 0 0 0 0 60
61 5.4 469 5.7 5.9 6.2 6.3 1 0 0 0 0 0 0 0 0 0 0 61
62 5.6 478 5.4 5.7 5.9 6.2 0 1 0 0 0 0 0 0 0 0 0 62
63 6.2 528 5.6 5.4 5.7 5.9 0 0 1 0 0 0 0 0 0 0 0 63
64 6.3 534 6.2 5.6 5.4 5.7 0 0 0 1 0 0 0 0 0 0 0 64
65 6.0 518 6.3 6.2 5.6 5.4 0 0 0 0 1 0 0 0 0 0 0 65
66 5.6 506 6.0 6.3 6.2 5.6 0 0 0 0 0 1 0 0 0 0 0 66
67 5.5 502 5.6 6.0 6.3 6.2 0 0 0 0 0 0 1 0 0 0 0 67
68 5.9 516 5.5 5.6 6.0 6.3 0 0 0 0 0 0 0 1 0 0 0 68
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) werkl Y1 Y2 Y3 Y4
0.611568 0.006755 1.124741 -0.594297 -0.239259 0.091272
M1 M2 M3 M4 M5 M6
0.036897 0.002528 -0.176381 -0.566368 -0.517097 -0.260759
M7 M8 M9 M10 M11 t
-0.209771 0.006604 -0.025880 -0.074937 -0.048670 -0.003230
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.267738 -0.058293 -0.002630 0.070258 0.273049
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.611568 0.352134 1.737 0.088589 .
werkl 0.006755 0.001471 4.591 3.00e-05 ***
Y1 1.124741 0.134875 8.339 4.99e-11 ***
Y2 -0.594297 0.207644 -2.862 0.006131 **
Y3 -0.239259 0.207740 -1.152 0.254913
Y4 0.091272 0.124034 0.736 0.465252
M1 0.036897 0.084448 0.437 0.664047
M2 0.002528 0.087198 0.029 0.976985
M3 -0.176381 0.121840 -1.448 0.153958
M4 -0.566368 0.130890 -4.327 7.23e-05 ***
M5 -0.517097 0.134149 -3.855 0.000332 ***
M6 -0.260759 0.119739 -2.178 0.034171 *
M7 -0.209771 0.097609 -2.149 0.036492 *
M8 0.006604 0.102593 0.064 0.948935
M9 -0.025880 0.102453 -0.253 0.801608
M10 -0.074937 0.094754 -0.791 0.432765
M11 -0.048670 0.085601 -0.569 0.572198
t -0.003230 0.001117 -2.892 0.005648 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.1303 on 50 degrees of freedom
Multiple R-squared: 0.9622, Adjusted R-squared: 0.9494
F-statistic: 74.94 on 17 and 50 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.07089657 0.1417931 0.9291034
[2,] 0.29216966 0.5843393 0.7078303
[3,] 0.40924359 0.8184872 0.5907564
[4,] 0.39437206 0.7887441 0.6056279
[5,] 0.49968585 0.9993717 0.5003142
[6,] 0.48980750 0.9796150 0.5101925
[7,] 0.38560188 0.7712038 0.6143981
[8,] 0.33217464 0.6643493 0.6678254
[9,] 0.24122706 0.4824541 0.7587729
[10,] 0.17308552 0.3461710 0.8269145
[11,] 0.11840793 0.2368159 0.8815921
[12,] 0.08599978 0.1719996 0.9140002
[13,] 0.07304980 0.1460996 0.9269502
[14,] 0.06366593 0.1273319 0.9363341
[15,] 0.06131663 0.1226333 0.9386834
[16,] 0.24713288 0.4942658 0.7528671
[17,] 0.20242160 0.4048432 0.7975784
[18,] 0.14530315 0.2906063 0.8546968
[19,] 0.34461835 0.6892367 0.6553817
[20,] 0.25304445 0.5060889 0.7469556
[21,] 0.18942360 0.3788472 0.8105764
[22,] 0.51898311 0.9620338 0.4810169
[23,] 0.54076615 0.9184677 0.4592338
[24,] 0.45585146 0.9117029 0.5441485
[25,] 0.84034989 0.3193002 0.1596501
[26,] 0.73775051 0.5244990 0.2622495
[27,] 0.67988126 0.6402375 0.3201187
> postscript(file="/var/www/html/rcomp/tmp/1urrj1258987127.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/26r601258987127.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/3f8yp1258987127.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/489s51258987127.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/5k55q1258987127.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 = 68
Frequency = 1
1 2 3 4 5
-0.0714290798 0.0118643768 -0.1129307392 -0.0137735844 0.0074532927
6 7 8 9 10
0.0752128305 0.0149677096 0.1541688797 0.1999837517 0.0525190117
11 12 13 14 15
-0.0056929980 -0.2677376947 0.0714442201 0.0347952050 0.1142990964
16 17 18 19 20
0.0129890696 -0.0457871636 -0.0620388342 0.0057151246 -0.0154862716
21 22 23 24 25
-0.0061664518 -0.0627589812 -0.1473726977 -0.2245245656 0.1932742630
26 27 28 29 30
-0.1625352531 -0.0057528851 0.0730814553 -0.0243156592 -0.0165358198
31 32 33 34 35
0.0001282170 -0.0065352551 -0.0429782891 0.1086852892 0.1040879067
36 37 38 39 40
0.2476343507 0.0503192774 -0.0053876210 -0.2221654988 0.0418030676
41 42 43 44 45
0.0294270924 -0.1707789520 0.0096006174 -0.0369699069 -0.0937940346
46 47 48 49 50
0.0698623547 0.1598133289 0.2730485483 -0.0278522698 0.0043021688
51 52 53 54 55
0.0889017811 -0.0949270775 -0.0289794266 0.1618343511 -0.1627496903
56 57 58 59 60
-0.1136522982 -0.0570449762 -0.1683076744 -0.1108355399 -0.0284206386
61 62 63 64 65
-0.2157564109 0.1169611235 0.1376482456 -0.0191729306 0.0622018644
66 67 68
0.0123064244 0.1323380216 0.0184748522
> postscript(file="/var/www/html/rcomp/tmp/616zp1258987127.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 = 68
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.0714290798 NA
1 0.0118643768 -0.0714290798
2 -0.1129307392 0.0118643768
3 -0.0137735844 -0.1129307392
4 0.0074532927 -0.0137735844
5 0.0752128305 0.0074532927
6 0.0149677096 0.0752128305
7 0.1541688797 0.0149677096
8 0.1999837517 0.1541688797
9 0.0525190117 0.1999837517
10 -0.0056929980 0.0525190117
11 -0.2677376947 -0.0056929980
12 0.0714442201 -0.2677376947
13 0.0347952050 0.0714442201
14 0.1142990964 0.0347952050
15 0.0129890696 0.1142990964
16 -0.0457871636 0.0129890696
17 -0.0620388342 -0.0457871636
18 0.0057151246 -0.0620388342
19 -0.0154862716 0.0057151246
20 -0.0061664518 -0.0154862716
21 -0.0627589812 -0.0061664518
22 -0.1473726977 -0.0627589812
23 -0.2245245656 -0.1473726977
24 0.1932742630 -0.2245245656
25 -0.1625352531 0.1932742630
26 -0.0057528851 -0.1625352531
27 0.0730814553 -0.0057528851
28 -0.0243156592 0.0730814553
29 -0.0165358198 -0.0243156592
30 0.0001282170 -0.0165358198
31 -0.0065352551 0.0001282170
32 -0.0429782891 -0.0065352551
33 0.1086852892 -0.0429782891
34 0.1040879067 0.1086852892
35 0.2476343507 0.1040879067
36 0.0503192774 0.2476343507
37 -0.0053876210 0.0503192774
38 -0.2221654988 -0.0053876210
39 0.0418030676 -0.2221654988
40 0.0294270924 0.0418030676
41 -0.1707789520 0.0294270924
42 0.0096006174 -0.1707789520
43 -0.0369699069 0.0096006174
44 -0.0937940346 -0.0369699069
45 0.0698623547 -0.0937940346
46 0.1598133289 0.0698623547
47 0.2730485483 0.1598133289
48 -0.0278522698 0.2730485483
49 0.0043021688 -0.0278522698
50 0.0889017811 0.0043021688
51 -0.0949270775 0.0889017811
52 -0.0289794266 -0.0949270775
53 0.1618343511 -0.0289794266
54 -0.1627496903 0.1618343511
55 -0.1136522982 -0.1627496903
56 -0.0570449762 -0.1136522982
57 -0.1683076744 -0.0570449762
58 -0.1108355399 -0.1683076744
59 -0.0284206386 -0.1108355399
60 -0.2157564109 -0.0284206386
61 0.1169611235 -0.2157564109
62 0.1376482456 0.1169611235
63 -0.0191729306 0.1376482456
64 0.0622018644 -0.0191729306
65 0.0123064244 0.0622018644
66 0.1323380216 0.0123064244
67 0.0184748522 0.1323380216
68 NA 0.0184748522
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.0118643768 -0.0714290798
[2,] -0.1129307392 0.0118643768
[3,] -0.0137735844 -0.1129307392
[4,] 0.0074532927 -0.0137735844
[5,] 0.0752128305 0.0074532927
[6,] 0.0149677096 0.0752128305
[7,] 0.1541688797 0.0149677096
[8,] 0.1999837517 0.1541688797
[9,] 0.0525190117 0.1999837517
[10,] -0.0056929980 0.0525190117
[11,] -0.2677376947 -0.0056929980
[12,] 0.0714442201 -0.2677376947
[13,] 0.0347952050 0.0714442201
[14,] 0.1142990964 0.0347952050
[15,] 0.0129890696 0.1142990964
[16,] -0.0457871636 0.0129890696
[17,] -0.0620388342 -0.0457871636
[18,] 0.0057151246 -0.0620388342
[19,] -0.0154862716 0.0057151246
[20,] -0.0061664518 -0.0154862716
[21,] -0.0627589812 -0.0061664518
[22,] -0.1473726977 -0.0627589812
[23,] -0.2245245656 -0.1473726977
[24,] 0.1932742630 -0.2245245656
[25,] -0.1625352531 0.1932742630
[26,] -0.0057528851 -0.1625352531
[27,] 0.0730814553 -0.0057528851
[28,] -0.0243156592 0.0730814553
[29,] -0.0165358198 -0.0243156592
[30,] 0.0001282170 -0.0165358198
[31,] -0.0065352551 0.0001282170
[32,] -0.0429782891 -0.0065352551
[33,] 0.1086852892 -0.0429782891
[34,] 0.1040879067 0.1086852892
[35,] 0.2476343507 0.1040879067
[36,] 0.0503192774 0.2476343507
[37,] -0.0053876210 0.0503192774
[38,] -0.2221654988 -0.0053876210
[39,] 0.0418030676 -0.2221654988
[40,] 0.0294270924 0.0418030676
[41,] -0.1707789520 0.0294270924
[42,] 0.0096006174 -0.1707789520
[43,] -0.0369699069 0.0096006174
[44,] -0.0937940346 -0.0369699069
[45,] 0.0698623547 -0.0937940346
[46,] 0.1598133289 0.0698623547
[47,] 0.2730485483 0.1598133289
[48,] -0.0278522698 0.2730485483
[49,] 0.0043021688 -0.0278522698
[50,] 0.0889017811 0.0043021688
[51,] -0.0949270775 0.0889017811
[52,] -0.0289794266 -0.0949270775
[53,] 0.1618343511 -0.0289794266
[54,] -0.1627496903 0.1618343511
[55,] -0.1136522982 -0.1627496903
[56,] -0.0570449762 -0.1136522982
[57,] -0.1683076744 -0.0570449762
[58,] -0.1108355399 -0.1683076744
[59,] -0.0284206386 -0.1108355399
[60,] -0.2157564109 -0.0284206386
[61,] 0.1169611235 -0.2157564109
[62,] 0.1376482456 0.1169611235
[63,] -0.0191729306 0.1376482456
[64,] 0.0622018644 -0.0191729306
[65,] 0.0123064244 0.0622018644
[66,] 0.1323380216 0.0123064244
[67,] 0.0184748522 0.1323380216
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.0118643768 -0.0714290798
2 -0.1129307392 0.0118643768
3 -0.0137735844 -0.1129307392
4 0.0074532927 -0.0137735844
5 0.0752128305 0.0074532927
6 0.0149677096 0.0752128305
7 0.1541688797 0.0149677096
8 0.1999837517 0.1541688797
9 0.0525190117 0.1999837517
10 -0.0056929980 0.0525190117
11 -0.2677376947 -0.0056929980
12 0.0714442201 -0.2677376947
13 0.0347952050 0.0714442201
14 0.1142990964 0.0347952050
15 0.0129890696 0.1142990964
16 -0.0457871636 0.0129890696
17 -0.0620388342 -0.0457871636
18 0.0057151246 -0.0620388342
19 -0.0154862716 0.0057151246
20 -0.0061664518 -0.0154862716
21 -0.0627589812 -0.0061664518
22 -0.1473726977 -0.0627589812
23 -0.2245245656 -0.1473726977
24 0.1932742630 -0.2245245656
25 -0.1625352531 0.1932742630
26 -0.0057528851 -0.1625352531
27 0.0730814553 -0.0057528851
28 -0.0243156592 0.0730814553
29 -0.0165358198 -0.0243156592
30 0.0001282170 -0.0165358198
31 -0.0065352551 0.0001282170
32 -0.0429782891 -0.0065352551
33 0.1086852892 -0.0429782891
34 0.1040879067 0.1086852892
35 0.2476343507 0.1040879067
36 0.0503192774 0.2476343507
37 -0.0053876210 0.0503192774
38 -0.2221654988 -0.0053876210
39 0.0418030676 -0.2221654988
40 0.0294270924 0.0418030676
41 -0.1707789520 0.0294270924
42 0.0096006174 -0.1707789520
43 -0.0369699069 0.0096006174
44 -0.0937940346 -0.0369699069
45 0.0698623547 -0.0937940346
46 0.1598133289 0.0698623547
47 0.2730485483 0.1598133289
48 -0.0278522698 0.2730485483
49 0.0043021688 -0.0278522698
50 0.0889017811 0.0043021688
51 -0.0949270775 0.0889017811
52 -0.0289794266 -0.0949270775
53 0.1618343511 -0.0289794266
54 -0.1627496903 0.1618343511
55 -0.1136522982 -0.1627496903
56 -0.0570449762 -0.1136522982
57 -0.1683076744 -0.0570449762
58 -0.1108355399 -0.1683076744
59 -0.0284206386 -0.1108355399
60 -0.2157564109 -0.0284206386
61 0.1169611235 -0.2157564109
62 0.1376482456 0.1169611235
63 -0.0191729306 0.1376482456
64 0.0622018644 -0.0191729306
65 0.0123064244 0.0622018644
66 0.1323380216 0.0123064244
67 0.0184748522 0.1323380216
> 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/75z2g1258987127.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/817o81258987127.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/90zzt1258987127.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/10fvl51258987127.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/11hyo91258987127.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/12zqjt1258987127.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/13e7k61258987127.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/14z96w1258987127.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/15fuwb1258987127.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/16xntq1258987127.tab")
+ }
>
> system("convert tmp/1urrj1258987127.ps tmp/1urrj1258987127.png")
> system("convert tmp/26r601258987127.ps tmp/26r601258987127.png")
> system("convert tmp/3f8yp1258987127.ps tmp/3f8yp1258987127.png")
> system("convert tmp/489s51258987127.ps tmp/489s51258987127.png")
> system("convert tmp/5k55q1258987127.ps tmp/5k55q1258987127.png")
> system("convert tmp/616zp1258987127.ps tmp/616zp1258987127.png")
> system("convert tmp/75z2g1258987127.ps tmp/75z2g1258987127.png")
> system("convert tmp/817o81258987127.ps tmp/817o81258987127.png")
> system("convert tmp/90zzt1258987127.ps tmp/90zzt1258987127.png")
> system("convert tmp/10fvl51258987127.ps tmp/10fvl51258987127.png")
>
>
> proc.time()
user system elapsed
2.511 1.595 3.652