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(100
+ ,100
+ ,96.21064363
+ ,97.82226485
+ ,96.31280765
+ ,94.04971502
+ ,107.1793443
+ ,91.12460521
+ ,114.9066592
+ ,93.13202153
+ ,92.56060184
+ ,93.88342812
+ ,114.9995356
+ ,92.55349954
+ ,107.1236185
+ ,94.43494835
+ ,117.7765394
+ ,96.25017563
+ ,107.3650971
+ ,100.4355715
+ ,106.2970187
+ ,101.5036685
+ ,114.5072908
+ ,99.39789728
+ ,98.0031578
+ ,99.68990733
+ ,103.0649206
+ ,101.6895041
+ ,100.2879168
+ ,103.6652759
+ ,104.6066685
+ ,103.0532766
+ ,111.1544534
+ ,100.9500712
+ ,104.9874617
+ ,102.345366
+ ,109.9284852
+ ,101.6472299
+ ,111.5352466
+ ,99.56809393
+ ,132.4974459
+ ,95.67727392
+ ,100.3436426
+ ,96.58494865
+ ,123.0983561
+ ,96.32604937
+ ,114.2379493
+ ,95.37109101
+ ,104.569518
+ ,96.00056203
+ ,109.0833101
+ ,96.88367859
+ ,106.9843039
+ ,94.85280372
+ ,133.6769759
+ ,92.46943974
+ ,124.8537197
+ ,93.99180173
+ ,122.5132349
+ ,93.45262168
+ ,116.8013374
+ ,92.26698759
+ ,116.0118882
+ ,90.39653498
+ ,129.7575926
+ ,90.43001228
+ ,125.1973623
+ ,91.04995327
+ ,143.7912139
+ ,89.07845784
+ ,127.9465032
+ ,89.69314509
+ ,130.2962757
+ ,87.92459054
+ ,108.4424631
+ ,85.8789319
+ ,129.3675118
+ ,83.20612366
+ ,143.6797622
+ ,83.85722053
+ ,131.8844618
+ ,83.01393462
+ ,117.6186496
+ ,82.84508195
+ ,118.9560695
+ ,78.68864276
+ ,104.8202842
+ ,77.56959675
+ ,134.624315
+ ,78.53689529
+ ,140.401226
+ ,78.55717715
+ ,143.8005015
+ ,77.4761291
+ ,153.4317823
+ ,81.58931659
+ ,153.2924677
+ ,85.02428326
+ ,127.3149438
+ ,91.71290159
+ ,153.5525216
+ ,95.96293061
+ ,136.9276493
+ ,90.84689022
+ ,131.7730101
+ ,92.28788036
+ ,144.3391845
+ ,95.56511274
+ ,107.4208229
+ ,93.62452884
+ ,113.6249652
+ ,92.63071726
+ ,124.2221603
+ ,89.50914211
+ ,102.0618557
+ ,87.17171779
+ ,96.36853348
+ ,86.72624975
+ ,111.6838488
+ ,85.63212844)
+ ,dim=c(2
+ ,60)
+ ,dimnames=list(c('Import'
+ ,'Wisselkoers')
+ ,1:60))
> y <- array(NA,dim=c(2,60),dimnames=list(c('Import','Wisselkoers'),1:60))
> 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
Import Wisselkoers M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 100.00000 100.00000 1 0 0 0 0 0 0 0 0 0 0 1
2 96.21064 97.82226 0 1 0 0 0 0 0 0 0 0 0 2
3 96.31281 94.04972 0 0 1 0 0 0 0 0 0 0 0 3
4 107.17934 91.12461 0 0 0 1 0 0 0 0 0 0 0 4
5 114.90666 93.13202 0 0 0 0 1 0 0 0 0 0 0 5
6 92.56060 93.88343 0 0 0 0 0 1 0 0 0 0 0 6
7 114.99954 92.55350 0 0 0 0 0 0 1 0 0 0 0 7
8 107.12362 94.43495 0 0 0 0 0 0 0 1 0 0 0 8
9 117.77654 96.25018 0 0 0 0 0 0 0 0 1 0 0 9
10 107.36510 100.43557 0 0 0 0 0 0 0 0 0 1 0 10
11 106.29702 101.50367 0 0 0 0 0 0 0 0 0 0 1 11
12 114.50729 99.39790 0 0 0 0 0 0 0 0 0 0 0 12
13 98.00316 99.68991 1 0 0 0 0 0 0 0 0 0 0 13
14 103.06492 101.68950 0 1 0 0 0 0 0 0 0 0 0 14
15 100.28792 103.66528 0 0 1 0 0 0 0 0 0 0 0 15
16 104.60667 103.05328 0 0 0 1 0 0 0 0 0 0 0 16
17 111.15445 100.95007 0 0 0 0 1 0 0 0 0 0 0 17
18 104.98746 102.34537 0 0 0 0 0 1 0 0 0 0 0 18
19 109.92849 101.64723 0 0 0 0 0 0 1 0 0 0 0 19
20 111.53525 99.56809 0 0 0 0 0 0 0 1 0 0 0 20
21 132.49745 95.67727 0 0 0 0 0 0 0 0 1 0 0 21
22 100.34364 96.58495 0 0 0 0 0 0 0 0 0 1 0 22
23 123.09836 96.32605 0 0 0 0 0 0 0 0 0 0 1 23
24 114.23795 95.37109 0 0 0 0 0 0 0 0 0 0 0 24
25 104.56952 96.00056 1 0 0 0 0 0 0 0 0 0 0 25
26 109.08331 96.88368 0 1 0 0 0 0 0 0 0 0 0 26
27 106.98430 94.85280 0 0 1 0 0 0 0 0 0 0 0 27
28 133.67698 92.46944 0 0 0 1 0 0 0 0 0 0 0 28
29 124.85372 93.99180 0 0 0 0 1 0 0 0 0 0 0 29
30 122.51323 93.45262 0 0 0 0 0 1 0 0 0 0 0 30
31 116.80134 92.26699 0 0 0 0 0 0 1 0 0 0 0 31
32 116.01189 90.39653 0 0 0 0 0 0 0 1 0 0 0 32
33 129.75759 90.43001 0 0 0 0 0 0 0 0 1 0 0 33
34 125.19736 91.04995 0 0 0 0 0 0 0 0 0 1 0 34
35 143.79121 89.07846 0 0 0 0 0 0 0 0 0 0 1 35
36 127.94650 89.69315 0 0 0 0 0 0 0 0 0 0 0 36
37 130.29628 87.92459 1 0 0 0 0 0 0 0 0 0 0 37
38 108.44246 85.87893 0 1 0 0 0 0 0 0 0 0 0 38
39 129.36751 83.20612 0 0 1 0 0 0 0 0 0 0 0 39
40 143.67976 83.85722 0 0 0 1 0 0 0 0 0 0 0 40
41 131.88446 83.01393 0 0 0 0 1 0 0 0 0 0 0 41
42 117.61865 82.84508 0 0 0 0 0 1 0 0 0 0 0 42
43 118.95607 78.68864 0 0 0 0 0 0 1 0 0 0 0 43
44 104.82028 77.56960 0 0 0 0 0 0 0 1 0 0 0 44
45 134.62431 78.53690 0 0 0 0 0 0 0 0 1 0 0 45
46 140.40123 78.55718 0 0 0 0 0 0 0 0 0 1 0 46
47 143.80050 77.47613 0 0 0 0 0 0 0 0 0 0 1 47
48 153.43178 81.58932 0 0 0 0 0 0 0 0 0 0 0 48
49 153.29247 85.02428 1 0 0 0 0 0 0 0 0 0 0 49
50 127.31494 91.71290 0 1 0 0 0 0 0 0 0 0 0 50
51 153.55252 95.96293 0 0 1 0 0 0 0 0 0 0 0 51
52 136.92765 90.84689 0 0 0 1 0 0 0 0 0 0 0 52
53 131.77301 92.28788 0 0 0 0 1 0 0 0 0 0 0 53
54 144.33918 95.56511 0 0 0 0 0 1 0 0 0 0 0 54
55 107.42082 93.62453 0 0 0 0 0 0 1 0 0 0 0 55
56 113.62497 92.63072 0 0 0 0 0 0 0 1 0 0 0 56
57 124.22216 89.50914 0 0 0 0 0 0 0 0 1 0 0 57
58 102.06186 87.17172 0 0 0 0 0 0 0 0 0 1 0 58
59 96.36853 86.72625 0 0 0 0 0 0 0 0 0 0 1 59
60 111.68385 85.63213 0 0 0 0 0 0 0 0 0 0 0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Wisselkoers M1 M2 M3 M4
159.2358 -0.5277 -1.4295 -9.6296 -1.7448 4.7167
M5 M6 M7 M8 M9 M10
2.2753 -4.0931 -8.2138 -12.0086 4.3454 -8.3534
M11 t
-1.3954 0.3555
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-36.679 -8.057 1.574 7.143 28.573
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 159.2358 33.8162 4.709 2.32e-05 ***
Wisselkoers -0.5277 0.3334 -1.583 0.12034
M1 -1.4295 8.6312 -0.166 0.86918
M2 -9.6296 8.6412 -1.114 0.27090
M3 -1.7448 8.6245 -0.202 0.84057
M4 4.7167 8.5931 0.549 0.58573
M5 2.2753 8.5864 0.265 0.79221
M6 -4.0931 8.5970 -0.476 0.63625
M7 -8.2138 8.5693 -0.959 0.34281
M8 -12.0086 8.5645 -1.402 0.16759
M9 4.3454 8.5655 0.507 0.61436
M10 -8.3534 8.5561 -0.976 0.33402
M11 -1.3954 8.5550 -0.163 0.87115
t 0.3555 0.1314 2.705 0.00955 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 13.52 on 46 degrees of freedom
Multiple R-squared: 0.4368, Adjusted R-squared: 0.2777
F-statistic: 2.745 on 13 and 46 DF, p-value: 0.005851
> 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.104763e-02 4.209526e-02 0.9789524
[2,] 2.286118e-02 4.572237e-02 0.9771388
[3,] 1.035576e-02 2.071151e-02 0.9896442
[4,] 3.178350e-03 6.356700e-03 0.9968217
[5,] 2.192195e-03 4.384391e-03 0.9978078
[6,] 2.459213e-03 4.918426e-03 0.9975408
[7,] 1.938978e-03 3.877955e-03 0.9980610
[8,] 8.549469e-04 1.709894e-03 0.9991451
[9,] 4.892204e-04 9.784407e-04 0.9995108
[10,] 1.680363e-04 3.360726e-04 0.9998320
[11,] 1.285921e-04 2.571843e-04 0.9998714
[12,] 6.589425e-04 1.317885e-03 0.9993411
[13,] 2.654802e-04 5.309603e-04 0.9997345
[14,] 2.570996e-04 5.141991e-04 0.9997429
[15,] 1.484106e-04 2.968212e-04 0.9998516
[16,] 6.573105e-05 1.314621e-04 0.9999343
[17,] 3.133406e-05 6.266811e-05 0.9999687
[18,] 1.680221e-05 3.360442e-05 0.9999832
[19,] 2.418663e-05 4.837326e-05 0.9999758
[20,] 8.378452e-06 1.675690e-05 0.9999916
[21,] 4.752874e-05 9.505748e-05 0.9999525
[22,] 1.248200e-03 2.496400e-03 0.9987518
[23,] 1.867083e-03 3.734166e-03 0.9981329
[24,] 2.611703e-03 5.223407e-03 0.9973883
[25,] 4.033664e-03 8.067328e-03 0.9959663
[26,] 1.092079e-01 2.184157e-01 0.8907921
[27,] 1.063381e-01 2.126762e-01 0.8936619
> postscript(file="/var/www/html/rcomp/tmp/1q6zp1258731941.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/25val1258731941.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/3o3fs1258731941.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/4rebw1258731941.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/5ogcg1258731941.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 = 60
Frequency = 1
1 2 3 4 5 6
-5.3912493 -2.4852074 -12.6140809 -10.1081200 0.7644939 -15.1721291
7 8 9 10 11 12
10.3302342 6.8864840 1.7877914 5.9283749 -1.8895708 3.4586470
13 14 15 16 17 18
-11.8173279 2.1442333 -7.8303884 -10.6515719 -3.1276847 -2.5454588
19 20 21 22 23 24
5.7923944 9.7413012 11.9407758 -7.3906725 7.9139108 -3.2012603
25 26 27 28 29 30
-11.4634535 1.3609644 -10.0499883 8.5679901 2.6340672 6.0219674
31 32 33 34 35 36
3.4496443 5.1124639 2.1663160 10.2766021 20.5165774 3.2454127
37 38 39 40 41 42
5.7359725 -9.3527444 1.9216062 9.7604640 -0.3938680 -8.7358715
43 44 45 46 47 48
-5.8265867 -17.1135820 -3.5086211 14.6223630 10.1376560 20.1886599
49 50 51 52 53 54
22.9360582 8.3327541 28.5728515 2.4312378 0.1229916 20.4314919
55 56 57 58 59 60
-13.7456862 -4.6266671 -12.3862621 -23.4366676 -36.6785734 -23.6914593
> postscript(file="/var/www/html/rcomp/tmp/6mmn11258731941.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 = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 -5.3912493 NA
1 -2.4852074 -5.3912493
2 -12.6140809 -2.4852074
3 -10.1081200 -12.6140809
4 0.7644939 -10.1081200
5 -15.1721291 0.7644939
6 10.3302342 -15.1721291
7 6.8864840 10.3302342
8 1.7877914 6.8864840
9 5.9283749 1.7877914
10 -1.8895708 5.9283749
11 3.4586470 -1.8895708
12 -11.8173279 3.4586470
13 2.1442333 -11.8173279
14 -7.8303884 2.1442333
15 -10.6515719 -7.8303884
16 -3.1276847 -10.6515719
17 -2.5454588 -3.1276847
18 5.7923944 -2.5454588
19 9.7413012 5.7923944
20 11.9407758 9.7413012
21 -7.3906725 11.9407758
22 7.9139108 -7.3906725
23 -3.2012603 7.9139108
24 -11.4634535 -3.2012603
25 1.3609644 -11.4634535
26 -10.0499883 1.3609644
27 8.5679901 -10.0499883
28 2.6340672 8.5679901
29 6.0219674 2.6340672
30 3.4496443 6.0219674
31 5.1124639 3.4496443
32 2.1663160 5.1124639
33 10.2766021 2.1663160
34 20.5165774 10.2766021
35 3.2454127 20.5165774
36 5.7359725 3.2454127
37 -9.3527444 5.7359725
38 1.9216062 -9.3527444
39 9.7604640 1.9216062
40 -0.3938680 9.7604640
41 -8.7358715 -0.3938680
42 -5.8265867 -8.7358715
43 -17.1135820 -5.8265867
44 -3.5086211 -17.1135820
45 14.6223630 -3.5086211
46 10.1376560 14.6223630
47 20.1886599 10.1376560
48 22.9360582 20.1886599
49 8.3327541 22.9360582
50 28.5728515 8.3327541
51 2.4312378 28.5728515
52 0.1229916 2.4312378
53 20.4314919 0.1229916
54 -13.7456862 20.4314919
55 -4.6266671 -13.7456862
56 -12.3862621 -4.6266671
57 -23.4366676 -12.3862621
58 -36.6785734 -23.4366676
59 -23.6914593 -36.6785734
60 NA -23.6914593
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.4852074 -5.3912493
[2,] -12.6140809 -2.4852074
[3,] -10.1081200 -12.6140809
[4,] 0.7644939 -10.1081200
[5,] -15.1721291 0.7644939
[6,] 10.3302342 -15.1721291
[7,] 6.8864840 10.3302342
[8,] 1.7877914 6.8864840
[9,] 5.9283749 1.7877914
[10,] -1.8895708 5.9283749
[11,] 3.4586470 -1.8895708
[12,] -11.8173279 3.4586470
[13,] 2.1442333 -11.8173279
[14,] -7.8303884 2.1442333
[15,] -10.6515719 -7.8303884
[16,] -3.1276847 -10.6515719
[17,] -2.5454588 -3.1276847
[18,] 5.7923944 -2.5454588
[19,] 9.7413012 5.7923944
[20,] 11.9407758 9.7413012
[21,] -7.3906725 11.9407758
[22,] 7.9139108 -7.3906725
[23,] -3.2012603 7.9139108
[24,] -11.4634535 -3.2012603
[25,] 1.3609644 -11.4634535
[26,] -10.0499883 1.3609644
[27,] 8.5679901 -10.0499883
[28,] 2.6340672 8.5679901
[29,] 6.0219674 2.6340672
[30,] 3.4496443 6.0219674
[31,] 5.1124639 3.4496443
[32,] 2.1663160 5.1124639
[33,] 10.2766021 2.1663160
[34,] 20.5165774 10.2766021
[35,] 3.2454127 20.5165774
[36,] 5.7359725 3.2454127
[37,] -9.3527444 5.7359725
[38,] 1.9216062 -9.3527444
[39,] 9.7604640 1.9216062
[40,] -0.3938680 9.7604640
[41,] -8.7358715 -0.3938680
[42,] -5.8265867 -8.7358715
[43,] -17.1135820 -5.8265867
[44,] -3.5086211 -17.1135820
[45,] 14.6223630 -3.5086211
[46,] 10.1376560 14.6223630
[47,] 20.1886599 10.1376560
[48,] 22.9360582 20.1886599
[49,] 8.3327541 22.9360582
[50,] 28.5728515 8.3327541
[51,] 2.4312378 28.5728515
[52,] 0.1229916 2.4312378
[53,] 20.4314919 0.1229916
[54,] -13.7456862 20.4314919
[55,] -4.6266671 -13.7456862
[56,] -12.3862621 -4.6266671
[57,] -23.4366676 -12.3862621
[58,] -36.6785734 -23.4366676
[59,] -23.6914593 -36.6785734
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.4852074 -5.3912493
2 -12.6140809 -2.4852074
3 -10.1081200 -12.6140809
4 0.7644939 -10.1081200
5 -15.1721291 0.7644939
6 10.3302342 -15.1721291
7 6.8864840 10.3302342
8 1.7877914 6.8864840
9 5.9283749 1.7877914
10 -1.8895708 5.9283749
11 3.4586470 -1.8895708
12 -11.8173279 3.4586470
13 2.1442333 -11.8173279
14 -7.8303884 2.1442333
15 -10.6515719 -7.8303884
16 -3.1276847 -10.6515719
17 -2.5454588 -3.1276847
18 5.7923944 -2.5454588
19 9.7413012 5.7923944
20 11.9407758 9.7413012
21 -7.3906725 11.9407758
22 7.9139108 -7.3906725
23 -3.2012603 7.9139108
24 -11.4634535 -3.2012603
25 1.3609644 -11.4634535
26 -10.0499883 1.3609644
27 8.5679901 -10.0499883
28 2.6340672 8.5679901
29 6.0219674 2.6340672
30 3.4496443 6.0219674
31 5.1124639 3.4496443
32 2.1663160 5.1124639
33 10.2766021 2.1663160
34 20.5165774 10.2766021
35 3.2454127 20.5165774
36 5.7359725 3.2454127
37 -9.3527444 5.7359725
38 1.9216062 -9.3527444
39 9.7604640 1.9216062
40 -0.3938680 9.7604640
41 -8.7358715 -0.3938680
42 -5.8265867 -8.7358715
43 -17.1135820 -5.8265867
44 -3.5086211 -17.1135820
45 14.6223630 -3.5086211
46 10.1376560 14.6223630
47 20.1886599 10.1376560
48 22.9360582 20.1886599
49 8.3327541 22.9360582
50 28.5728515 8.3327541
51 2.4312378 28.5728515
52 0.1229916 2.4312378
53 20.4314919 0.1229916
54 -13.7456862 20.4314919
55 -4.6266671 -13.7456862
56 -12.3862621 -4.6266671
57 -23.4366676 -12.3862621
58 -36.6785734 -23.4366676
59 -23.6914593 -36.6785734
> 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/72vrg1258731941.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/82bg81258731941.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/9kz4v1258731941.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/10yija1258731941.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/11jjgj1258731941.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/12lo7j1258731941.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/1310ry1258731941.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/14h1vo1258731942.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/15wuhy1258731942.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/16vb4w1258731942.tab")
+ }
>
> system("convert tmp/1q6zp1258731941.ps tmp/1q6zp1258731941.png")
> system("convert tmp/25val1258731941.ps tmp/25val1258731941.png")
> system("convert tmp/3o3fs1258731941.ps tmp/3o3fs1258731941.png")
> system("convert tmp/4rebw1258731941.ps tmp/4rebw1258731941.png")
> system("convert tmp/5ogcg1258731941.ps tmp/5ogcg1258731941.png")
> system("convert tmp/6mmn11258731941.ps tmp/6mmn11258731941.png")
> system("convert tmp/72vrg1258731941.ps tmp/72vrg1258731941.png")
> system("convert tmp/82bg81258731941.ps tmp/82bg81258731941.png")
> system("convert tmp/9kz4v1258731941.ps tmp/9kz4v1258731941.png")
> system("convert tmp/10yija1258731941.ps tmp/10yija1258731941.png")
>
>
> proc.time()
user system elapsed
2.393 1.557 2.817