R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-pc-linux-gnu (32-bit)
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(1.5
+ ,508643
+ ,493
+ ,797
+ ,1.6
+ ,527568
+ ,514
+ ,840
+ ,1.8
+ ,520008
+ ,522
+ ,988
+ ,1.5
+ ,498484
+ ,490
+ ,819
+ ,1.3
+ ,523917
+ ,484
+ ,831
+ ,1.6
+ ,553522
+ ,506
+ ,904
+ ,1.6
+ ,558901
+ ,501
+ ,814
+ ,1.8
+ ,548933
+ ,462
+ ,798
+ ,1.8
+ ,567013
+ ,465
+ ,828
+ ,1.6
+ ,551085
+ ,454
+ ,789
+ ,1.8
+ ,588245
+ ,464
+ ,930
+ ,2
+ ,605010
+ ,427
+ ,744
+ ,1.3
+ ,631572
+ ,460
+ ,832
+ ,1.1
+ ,639180
+ ,473
+ ,826
+ ,1
+ ,653847
+ ,465
+ ,907
+ ,1.2
+ ,657073
+ ,422
+ ,776
+ ,1.2
+ ,626291
+ ,415
+ ,835
+ ,1.3
+ ,625616
+ ,413
+ ,715
+ ,1.3
+ ,633352
+ ,420
+ ,729
+ ,1.4
+ ,672820
+ ,363
+ ,733
+ ,1.1
+ ,691369
+ ,376
+ ,736
+ ,0.9
+ ,702595
+ ,380
+ ,712
+ ,1
+ ,692241
+ ,384
+ ,711
+ ,1.1
+ ,718722
+ ,346
+ ,667
+ ,1.4
+ ,732297
+ ,389
+ ,799
+ ,1.5
+ ,721798
+ ,407
+ ,661
+ ,1.8
+ ,766192
+ ,393
+ ,692
+ ,1.8
+ ,788456
+ ,346
+ ,649
+ ,1.8
+ ,806132
+ ,348
+ ,729
+ ,1.7
+ ,813944
+ ,353
+ ,622
+ ,1.5
+ ,788025
+ ,364
+ ,671
+ ,1.1
+ ,765985
+ ,305
+ ,635
+ ,1.3
+ ,702684
+ ,307
+ ,648
+ ,1.6
+ ,730159
+ ,312
+ ,745
+ ,1.9
+ ,678942
+ ,312
+ ,624
+ ,1.9
+ ,672527
+ ,286
+ ,477
+ ,2
+ ,594783
+ ,324
+ ,710
+ ,2.2
+ ,594575
+ ,336
+ ,515
+ ,2.2
+ ,576299
+ ,327
+ ,461
+ ,2
+ ,530770
+ ,302
+ ,590
+ ,2.3
+ ,524491
+ ,299
+ ,415
+ ,2.6
+ ,456590
+ ,311
+ ,554
+ ,3.2
+ ,428448
+ ,315
+ ,585
+ ,3.2
+ ,444937
+ ,264
+ ,513
+ ,3.1
+ ,372206
+ ,278
+ ,591
+ ,2.8
+ ,317272
+ ,278
+ ,561
+ ,2.3
+ ,297604
+ ,287
+ ,684
+ ,1.9
+ ,288561
+ ,279
+ ,668
+ ,1.9
+ ,289287
+ ,324
+ ,795
+ ,2
+ ,258923
+ ,354
+ ,776
+ ,2
+ ,255493
+ ,354
+ ,1043
+ ,1.8
+ ,277992
+ ,360
+ ,964
+ ,1.6
+ ,295474
+ ,363
+ ,762
+ ,1.4
+ ,291680
+ ,385
+ ,1030
+ ,0.2
+ ,318736
+ ,412
+ ,939
+ ,0.3
+ ,338463
+ ,370
+ ,779
+ ,0.4
+ ,351963
+ ,389
+ ,918
+ ,0.7
+ ,347240
+ ,395
+ ,839
+ ,1
+ ,347081
+ ,417
+ ,874
+ ,1.1
+ ,383486
+ ,404
+ ,840)
+ ,dim=c(4
+ ,60)
+ ,dimnames=list(c('inflatie'
+ ,'beurswaarde'
+ ,'werkloosheid'
+ ,'failliet')
+ ,1:60))
> y <- array(NA,dim=c(4,60),dimnames=list(c('inflatie','beurswaarde','werkloosheid','failliet'),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 = 'No Linear Trend'
> par2 = 'Do not include Seasonal Dummies'
> par1 = '1'
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date, 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
inflatie beurswaarde werkloosheid failliet
1 1.5 508643 493 797
2 1.6 527568 514 840
3 1.8 520008 522 988
4 1.5 498484 490 819
5 1.3 523917 484 831
6 1.6 553522 506 904
7 1.6 558901 501 814
8 1.8 548933 462 798
9 1.8 567013 465 828
10 1.6 551085 454 789
11 1.8 588245 464 930
12 2.0 605010 427 744
13 1.3 631572 460 832
14 1.1 639180 473 826
15 1.0 653847 465 907
16 1.2 657073 422 776
17 1.2 626291 415 835
18 1.3 625616 413 715
19 1.3 633352 420 729
20 1.4 672820 363 733
21 1.1 691369 376 736
22 0.9 702595 380 712
23 1.0 692241 384 711
24 1.1 718722 346 667
25 1.4 732297 389 799
26 1.5 721798 407 661
27 1.8 766192 393 692
28 1.8 788456 346 649
29 1.8 806132 348 729
30 1.7 813944 353 622
31 1.5 788025 364 671
32 1.1 765985 305 635
33 1.3 702684 307 648
34 1.6 730159 312 745
35 1.9 678942 312 624
36 1.9 672527 286 477
37 2.0 594783 324 710
38 2.2 594575 336 515
39 2.2 576299 327 461
40 2.0 530770 302 590
41 2.3 524491 299 415
42 2.6 456590 311 554
43 3.2 428448 315 585
44 3.2 444937 264 513
45 3.1 372206 278 591
46 2.8 317272 278 561
47 2.3 297604 287 684
48 1.9 288561 279 668
49 1.9 289287 324 795
50 2.0 258923 354 776
51 2.0 255493 354 1043
52 1.8 277992 360 964
53 1.6 295474 363 762
54 1.4 291680 385 1030
55 0.2 318736 412 939
56 0.3 338463 370 779
57 0.4 351963 389 918
58 0.7 347240 395 839
59 1.0 347081 417 874
60 1.1 383486 404 840
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) beurswaarde werkloosheid failliet
4.359e+00 -1.249e-06 1.086e-05 -2.773e-03
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.48031 -0.26263 0.01852 0.31783 0.99476
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.359e+00 4.907e-01 8.883 2.79e-12 ***
beurswaarde -1.249e-06 4.619e-07 -2.703 0.009070 **
werkloosheid 1.086e-05 1.406e-03 0.008 0.993864
failliet -2.773e-03 7.334e-04 -3.781 0.000382 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5032 on 56 degrees of freedom
Multiple R-squared: 0.3733, Adjusted R-squared: 0.3397
F-statistic: 11.12 on 3 and 56 DF, p-value: 7.899e-06
> 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.0059348062 0.0118696124 0.9940652
[2,] 0.0261998161 0.0523996323 0.9738002
[3,] 0.0088421695 0.0176843390 0.9911578
[4,] 0.0027704507 0.0055409014 0.9972295
[5,] 0.0012484193 0.0024968386 0.9987516
[6,] 0.0008408003 0.0016816006 0.9991592
[7,] 0.0072285803 0.0144571605 0.9927714
[8,] 0.0084906656 0.0169813313 0.9915093
[9,] 0.0137473827 0.0274947654 0.9862526
[10,] 0.0093031034 0.0186062069 0.9906969
[11,] 0.0107879575 0.0215759149 0.9892120
[12,] 0.0058955167 0.0117910334 0.9941045
[13,] 0.0030901246 0.0061802491 0.9969099
[14,] 0.0014275445 0.0028550891 0.9985725
[15,] 0.0007303104 0.0014606209 0.9992697
[16,] 0.0004688819 0.0009377639 0.9995311
[17,] 0.0002277583 0.0004555166 0.9997722
[18,] 0.0001206807 0.0002413614 0.9998793
[19,] 0.0001502375 0.0003004750 0.9998498
[20,] 0.0003550909 0.0007101818 0.9996449
[21,] 0.0024634710 0.0049269420 0.9975365
[22,] 0.0049017092 0.0098034184 0.9950983
[23,] 0.0083502987 0.0167005974 0.9916497
[24,] 0.0074651934 0.0149303867 0.9925348
[25,] 0.0061981303 0.0123962606 0.9938019
[26,] 0.0055331155 0.0110662311 0.9944669
[27,] 0.0048066552 0.0096133104 0.9951933
[28,] 0.0040152802 0.0080305604 0.9959847
[29,] 0.0047133143 0.0094266286 0.9952867
[30,] 0.0071740304 0.0143480607 0.9928260
[31,] 0.0062897392 0.0125794784 0.9937103
[32,] 0.0050943009 0.0101886018 0.9949057
[33,] 0.0030848164 0.0061696329 0.9969152
[34,] 0.0029451345 0.0058902691 0.9970549
[35,] 0.0021833196 0.0043666392 0.9978167
[36,] 0.0015229678 0.0030459356 0.9984770
[37,] 0.0132028518 0.0264057037 0.9867971
[38,] 0.0143472290 0.0286944579 0.9856528
[39,] 0.0375817456 0.0751634912 0.9624183
[40,] 0.0666011222 0.1332022443 0.9333989
[41,] 0.0736946609 0.1473893218 0.9263053
[42,] 0.0868201853 0.1736403707 0.9131798
[43,] 0.0602862508 0.1205725016 0.9397137
[44,] 0.0423979375 0.0847958750 0.9576021
[45,] 0.0248768925 0.0497537850 0.9751231
[46,] 0.0195417243 0.0390834487 0.9804583
[47,] 0.0726605532 0.1453211063 0.9273394
> postscript(file="/var/wessaorg/rcomp/tmp/1x9je1355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/27ts91355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/32ish1355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4y3iu1355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/58gsw1355572655.ps",horizontal=F,onefile=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
-0.019210195 0.223422654 0.824258461 0.029135788 -0.105765548 0.433375468
7 8 9 10 11 12
0.190601623 0.334213361 0.439940952 0.112033099 0.749284549 0.454895201
13 14 15 16 17 18
0.031707587 -0.175569031 -0.032575091 -0.191306840 -0.066080579 -0.299629058
19 20 21 22 23 24
-0.251226144 -0.090228632 -0.358887558 -0.611457381 -0.527203638 -0.515721514
25 26 27 28 29 30
0.166764094 -0.129178856 0.312367025 0.221453392 0.465323678 0.078343237
31 32 33 34 35 36
-0.018280278 -0.544981479 -0.388008189 0.215202903 0.115743005 -0.299576657
37 38 39 40 41 42
0.348969279 0.007897455 -0.164555208 -0.063458707 -0.256494610 0.343989231
43 44 45 46 47 48
0.994756543 0.816265418 0.841559475 0.389775946 0.206162216 -0.249407480
49 50 51 52 53 54
0.103146914 0.112220741 0.848255486 0.457241708 -0.281050174 0.257063873
55 56 57 58 59 60
-1.161759841 -1.480305044 -0.978243431 -0.903252111 -0.506644082 -0.455313004
> postscript(file="/var/wessaorg/rcomp/tmp/66z1p1355572655.ps",horizontal=F,onefile=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 -0.019210195 NA
1 0.223422654 -0.019210195
2 0.824258461 0.223422654
3 0.029135788 0.824258461
4 -0.105765548 0.029135788
5 0.433375468 -0.105765548
6 0.190601623 0.433375468
7 0.334213361 0.190601623
8 0.439940952 0.334213361
9 0.112033099 0.439940952
10 0.749284549 0.112033099
11 0.454895201 0.749284549
12 0.031707587 0.454895201
13 -0.175569031 0.031707587
14 -0.032575091 -0.175569031
15 -0.191306840 -0.032575091
16 -0.066080579 -0.191306840
17 -0.299629058 -0.066080579
18 -0.251226144 -0.299629058
19 -0.090228632 -0.251226144
20 -0.358887558 -0.090228632
21 -0.611457381 -0.358887558
22 -0.527203638 -0.611457381
23 -0.515721514 -0.527203638
24 0.166764094 -0.515721514
25 -0.129178856 0.166764094
26 0.312367025 -0.129178856
27 0.221453392 0.312367025
28 0.465323678 0.221453392
29 0.078343237 0.465323678
30 -0.018280278 0.078343237
31 -0.544981479 -0.018280278
32 -0.388008189 -0.544981479
33 0.215202903 -0.388008189
34 0.115743005 0.215202903
35 -0.299576657 0.115743005
36 0.348969279 -0.299576657
37 0.007897455 0.348969279
38 -0.164555208 0.007897455
39 -0.063458707 -0.164555208
40 -0.256494610 -0.063458707
41 0.343989231 -0.256494610
42 0.994756543 0.343989231
43 0.816265418 0.994756543
44 0.841559475 0.816265418
45 0.389775946 0.841559475
46 0.206162216 0.389775946
47 -0.249407480 0.206162216
48 0.103146914 -0.249407480
49 0.112220741 0.103146914
50 0.848255486 0.112220741
51 0.457241708 0.848255486
52 -0.281050174 0.457241708
53 0.257063873 -0.281050174
54 -1.161759841 0.257063873
55 -1.480305044 -1.161759841
56 -0.978243431 -1.480305044
57 -0.903252111 -0.978243431
58 -0.506644082 -0.903252111
59 -0.455313004 -0.506644082
60 NA -0.455313004
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.223422654 -0.019210195
[2,] 0.824258461 0.223422654
[3,] 0.029135788 0.824258461
[4,] -0.105765548 0.029135788
[5,] 0.433375468 -0.105765548
[6,] 0.190601623 0.433375468
[7,] 0.334213361 0.190601623
[8,] 0.439940952 0.334213361
[9,] 0.112033099 0.439940952
[10,] 0.749284549 0.112033099
[11,] 0.454895201 0.749284549
[12,] 0.031707587 0.454895201
[13,] -0.175569031 0.031707587
[14,] -0.032575091 -0.175569031
[15,] -0.191306840 -0.032575091
[16,] -0.066080579 -0.191306840
[17,] -0.299629058 -0.066080579
[18,] -0.251226144 -0.299629058
[19,] -0.090228632 -0.251226144
[20,] -0.358887558 -0.090228632
[21,] -0.611457381 -0.358887558
[22,] -0.527203638 -0.611457381
[23,] -0.515721514 -0.527203638
[24,] 0.166764094 -0.515721514
[25,] -0.129178856 0.166764094
[26,] 0.312367025 -0.129178856
[27,] 0.221453392 0.312367025
[28,] 0.465323678 0.221453392
[29,] 0.078343237 0.465323678
[30,] -0.018280278 0.078343237
[31,] -0.544981479 -0.018280278
[32,] -0.388008189 -0.544981479
[33,] 0.215202903 -0.388008189
[34,] 0.115743005 0.215202903
[35,] -0.299576657 0.115743005
[36,] 0.348969279 -0.299576657
[37,] 0.007897455 0.348969279
[38,] -0.164555208 0.007897455
[39,] -0.063458707 -0.164555208
[40,] -0.256494610 -0.063458707
[41,] 0.343989231 -0.256494610
[42,] 0.994756543 0.343989231
[43,] 0.816265418 0.994756543
[44,] 0.841559475 0.816265418
[45,] 0.389775946 0.841559475
[46,] 0.206162216 0.389775946
[47,] -0.249407480 0.206162216
[48,] 0.103146914 -0.249407480
[49,] 0.112220741 0.103146914
[50,] 0.848255486 0.112220741
[51,] 0.457241708 0.848255486
[52,] -0.281050174 0.457241708
[53,] 0.257063873 -0.281050174
[54,] -1.161759841 0.257063873
[55,] -1.480305044 -1.161759841
[56,] -0.978243431 -1.480305044
[57,] -0.903252111 -0.978243431
[58,] -0.506644082 -0.903252111
[59,] -0.455313004 -0.506644082
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.223422654 -0.019210195
2 0.824258461 0.223422654
3 0.029135788 0.824258461
4 -0.105765548 0.029135788
5 0.433375468 -0.105765548
6 0.190601623 0.433375468
7 0.334213361 0.190601623
8 0.439940952 0.334213361
9 0.112033099 0.439940952
10 0.749284549 0.112033099
11 0.454895201 0.749284549
12 0.031707587 0.454895201
13 -0.175569031 0.031707587
14 -0.032575091 -0.175569031
15 -0.191306840 -0.032575091
16 -0.066080579 -0.191306840
17 -0.299629058 -0.066080579
18 -0.251226144 -0.299629058
19 -0.090228632 -0.251226144
20 -0.358887558 -0.090228632
21 -0.611457381 -0.358887558
22 -0.527203638 -0.611457381
23 -0.515721514 -0.527203638
24 0.166764094 -0.515721514
25 -0.129178856 0.166764094
26 0.312367025 -0.129178856
27 0.221453392 0.312367025
28 0.465323678 0.221453392
29 0.078343237 0.465323678
30 -0.018280278 0.078343237
31 -0.544981479 -0.018280278
32 -0.388008189 -0.544981479
33 0.215202903 -0.388008189
34 0.115743005 0.215202903
35 -0.299576657 0.115743005
36 0.348969279 -0.299576657
37 0.007897455 0.348969279
38 -0.164555208 0.007897455
39 -0.063458707 -0.164555208
40 -0.256494610 -0.063458707
41 0.343989231 -0.256494610
42 0.994756543 0.343989231
43 0.816265418 0.994756543
44 0.841559475 0.816265418
45 0.389775946 0.841559475
46 0.206162216 0.389775946
47 -0.249407480 0.206162216
48 0.103146914 -0.249407480
49 0.112220741 0.103146914
50 0.848255486 0.112220741
51 0.457241708 0.848255486
52 -0.281050174 0.457241708
53 0.257063873 -0.281050174
54 -1.161759841 0.257063873
55 -1.480305044 -1.161759841
56 -0.978243431 -1.480305044
57 -0.903252111 -0.978243431
58 -0.506644082 -0.903252111
59 -0.455313004 -0.506644082
> 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/wessaorg/rcomp/tmp/7hvsk1355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/8tju21355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/9w55e1355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10ehp01355572655.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11kmu61355572655.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/wessaorg/rcomp/tmp/12vv0t1355572655.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/wessaorg/rcomp/tmp/13x0f71355572655.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/wessaorg/rcomp/tmp/14o2mg1355572655.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/wessaorg/rcomp/tmp/15sixn1355572655.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/wessaorg/rcomp/tmp/16b9z21355572655.tab")
+ }
>
> try(system("convert tmp/1x9je1355572655.ps tmp/1x9je1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/27ts91355572655.ps tmp/27ts91355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/32ish1355572655.ps tmp/32ish1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/4y3iu1355572655.ps tmp/4y3iu1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/58gsw1355572655.ps tmp/58gsw1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/66z1p1355572655.ps tmp/66z1p1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/7hvsk1355572655.ps tmp/7hvsk1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/8tju21355572655.ps tmp/8tju21355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/9w55e1355572655.ps tmp/9w55e1355572655.png",intern=TRUE))
character(0)
> try(system("convert tmp/10ehp01355572655.ps tmp/10ehp01355572655.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
6.170 1.115 7.284