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(478
+ ,184
+ ,40
+ ,74
+ ,11
+ ,31
+ ,20
+ ,494
+ ,213
+ ,32
+ ,72
+ ,11
+ ,43
+ ,18
+ ,643
+ ,347
+ ,57
+ ,70
+ ,18
+ ,16
+ ,16
+ ,341
+ ,565
+ ,31
+ ,71
+ ,11
+ ,25
+ ,19
+ ,773
+ ,327
+ ,67
+ ,72
+ ,9
+ ,29
+ ,24
+ ,603
+ ,260
+ ,25
+ ,68
+ ,8
+ ,32
+ ,15
+ ,484
+ ,325
+ ,34
+ ,68
+ ,12
+ ,24
+ ,14
+ ,546
+ ,102
+ ,33
+ ,62
+ ,13
+ ,28
+ ,11
+ ,424
+ ,38
+ ,36
+ ,69
+ ,7
+ ,25
+ ,12
+ ,548
+ ,226
+ ,31
+ ,66
+ ,9
+ ,58
+ ,15
+ ,506
+ ,137
+ ,35
+ ,60
+ ,13
+ ,21
+ ,9
+ ,819
+ ,369
+ ,30
+ ,81
+ ,4
+ ,77
+ ,36
+ ,541
+ ,109
+ ,44
+ ,66
+ ,9
+ ,37
+ ,12
+ ,491
+ ,809
+ ,32
+ ,67
+ ,11
+ ,37
+ ,16
+ ,514
+ ,29
+ ,30
+ ,65
+ ,12
+ ,35
+ ,11
+ ,371
+ ,245
+ ,16
+ ,64
+ ,10
+ ,42
+ ,14
+ ,457
+ ,118
+ ,29
+ ,64
+ ,12
+ ,21
+ ,10
+ ,437
+ ,148
+ ,36
+ ,62
+ ,7
+ ,81
+ ,27
+ ,570
+ ,387
+ ,30
+ ,59
+ ,15
+ ,31
+ ,16
+ ,432
+ ,98
+ ,23
+ ,56
+ ,15
+ ,50
+ ,15
+ ,619
+ ,608
+ ,33
+ ,46
+ ,22
+ ,24
+ ,8
+ ,357
+ ,218
+ ,35
+ ,54
+ ,14
+ ,27
+ ,13
+ ,623
+ ,254
+ ,38
+ ,54
+ ,20
+ ,22
+ ,11
+ ,547
+ ,697
+ ,44
+ ,45
+ ,26
+ ,18
+ ,8
+ ,792
+ ,827
+ ,28
+ ,57
+ ,12
+ ,23
+ ,11
+ ,799
+ ,693
+ ,35
+ ,57
+ ,9
+ ,60
+ ,18
+ ,439
+ ,448
+ ,31
+ ,61
+ ,19
+ ,14
+ ,12
+ ,867
+ ,942
+ ,39
+ ,52
+ ,17
+ ,31
+ ,10
+ ,912
+ ,1017
+ ,27
+ ,44
+ ,21
+ ,24
+ ,9
+ ,462
+ ,216
+ ,36
+ ,43
+ ,18
+ ,23
+ ,8
+ ,859
+ ,673
+ ,38
+ ,48
+ ,19
+ ,22
+ ,10
+ ,805
+ ,989
+ ,46
+ ,57
+ ,14
+ ,25
+ ,12
+ ,652
+ ,630
+ ,29
+ ,47
+ ,19
+ ,25
+ ,9
+ ,776
+ ,404
+ ,32
+ ,50
+ ,19
+ ,21
+ ,9
+ ,919
+ ,692
+ ,39
+ ,48
+ ,16
+ ,32
+ ,11
+ ,732
+ ,1517
+ ,44
+ ,49
+ ,13
+ ,31
+ ,14
+ ,657
+ ,879
+ ,33
+ ,72
+ ,13
+ ,13
+ ,22
+ ,1419
+ ,631
+ ,43
+ ,59
+ ,14
+ ,21
+ ,13
+ ,989
+ ,1375
+ ,22
+ ,49
+ ,9
+ ,46
+ ,13
+ ,821
+ ,1139
+ ,30
+ ,54
+ ,13
+ ,27
+ ,12
+ ,1740
+ ,3545
+ ,86
+ ,62
+ ,22
+ ,18
+ ,15
+ ,815
+ ,706
+ ,30
+ ,47
+ ,17
+ ,39
+ ,11
+ ,760
+ ,451
+ ,32
+ ,45
+ ,34
+ ,15
+ ,10
+ ,936
+ ,433
+ ,43
+ ,48
+ ,26
+ ,23
+ ,12
+ ,863
+ ,601
+ ,20
+ ,69
+ ,23
+ ,7
+ ,12
+ ,783
+ ,1024
+ ,55
+ ,42
+ ,23
+ ,23
+ ,11
+ ,715
+ ,457
+ ,44
+ ,49
+ ,18
+ ,30
+ ,12
+ ,1504
+ ,1441
+ ,37
+ ,57
+ ,15
+ ,35
+ ,13
+ ,1324
+ ,1022
+ ,82
+ ,72
+ ,22
+ ,15
+ ,16
+ ,940
+ ,1244
+ ,66
+ ,67
+ ,26
+ ,18
+ ,16)
+ ,dim=c(7
+ ,50)
+ ,dimnames=list(c('TotaalCrimFeiten'
+ ,'GerappFeit'
+ ,'Fondsen'
+ ,'Crim25+MD'
+ ,'Crim16-19ZD'
+ ,'Crim18-24HD'
+ ,'Crim25+HD')
+ ,1:50))
> y <- array(NA,dim=c(7,50),dimnames=list(c('TotaalCrimFeiten','GerappFeit','Fondsen','Crim25+MD','Crim16-19ZD','Crim18-24HD','Crim25+HD'),1:50))
> 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 = '3'
> par3 <- 'No Linear Trend'
> par2 <- 'Do not include Seasonal Dummies'
> par1 <- '3'
> #'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, 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
Fondsen TotaalCrimFeiten GerappFeit Crim25+MD Crim16-19ZD Crim18-24HD
1 40 478 184 74 11 31
2 32 494 213 72 11 43
3 57 643 347 70 18 16
4 31 341 565 71 11 25
5 67 773 327 72 9 29
6 25 603 260 68 8 32
7 34 484 325 68 12 24
8 33 546 102 62 13 28
9 36 424 38 69 7 25
10 31 548 226 66 9 58
11 35 506 137 60 13 21
12 30 819 369 81 4 77
13 44 541 109 66 9 37
14 32 491 809 67 11 37
15 30 514 29 65 12 35
16 16 371 245 64 10 42
17 29 457 118 64 12 21
18 36 437 148 62 7 81
19 30 570 387 59 15 31
20 23 432 98 56 15 50
21 33 619 608 46 22 24
22 35 357 218 54 14 27
23 38 623 254 54 20 22
24 44 547 697 45 26 18
25 28 792 827 57 12 23
26 35 799 693 57 9 60
27 31 439 448 61 19 14
28 39 867 942 52 17 31
29 27 912 1017 44 21 24
30 36 462 216 43 18 23
31 38 859 673 48 19 22
32 46 805 989 57 14 25
33 29 652 630 47 19 25
34 32 776 404 50 19 21
35 39 919 692 48 16 32
36 44 732 1517 49 13 31
37 33 657 879 72 13 13
38 43 1419 631 59 14 21
39 22 989 1375 49 9 46
40 30 821 1139 54 13 27
41 86 1740 3545 62 22 18
42 30 815 706 47 17 39
43 32 760 451 45 34 15
44 43 936 433 48 26 23
45 20 863 601 69 23 7
46 55 783 1024 42 23 23
47 44 715 457 49 18 30
48 37 1504 1441 57 15 35
49 82 1324 1022 72 22 15
50 66 940 1244 67 26 18
Crim25+HD
1 20
2 18
3 16
4 19
5 24
6 15
7 14
8 11
9 12
10 15
11 9
12 36
13 12
14 16
15 11
16 14
17 10
18 27
19 16
20 15
21 8
22 13
23 11
24 8
25 11
26 18
27 12
28 10
29 9
30 8
31 10
32 12
33 9
34 9
35 11
36 14
37 22
38 13
39 13
40 12
41 15
42 11
43 10
44 12
45 12
46 11
47 12
48 13
49 16
50 16
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) TotaalCrimFeiten GerappFeit `Crim25+MD`
-4.864635 0.012287 0.005785 0.279901
`Crim16-19ZD` `Crim18-24HD` `Crim25+HD`
0.626771 -0.194463 0.719450
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-30.2165 -6.7048 0.0621 6.6202 23.0541
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -4.864635 20.553818 -0.237 0.814
TotaalCrimFeiten 0.012287 0.008244 1.490 0.143
GerappFeit 0.005785 0.004247 1.362 0.180
`Crim25+MD` 0.279901 0.287808 0.973 0.336
`Crim16-19ZD` 0.626771 0.424625 1.476 0.147
`Crim18-24HD` -0.194463 0.188890 -1.030 0.309
`Crim25+HD` 0.719450 0.584434 1.231 0.225
Residual standard error: 10.82 on 43 degrees of freedom
Multiple R-squared: 0.4622, Adjusted R-squared: 0.3872
F-statistic: 6.16 on 6 and 43 DF, p-value: 0.000101
> 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.514958565 0.970082871 0.4850414
[2,] 0.349014554 0.698029109 0.6509854
[3,] 0.474346649 0.948693298 0.5256534
[4,] 0.541179753 0.917640494 0.4588202
[5,] 0.424999166 0.849998332 0.5750008
[6,] 0.335397930 0.670795860 0.6646021
[7,] 0.247283279 0.494566558 0.7527167
[8,] 0.204366256 0.408732512 0.7956337
[9,] 0.281599529 0.563199058 0.7184005
[10,] 0.314125828 0.628251656 0.6858742
[11,] 0.251194959 0.502389918 0.7488050
[12,] 0.178798954 0.357597909 0.8212010
[13,] 0.136698086 0.273396173 0.8633019
[14,] 0.097264492 0.194528984 0.9027355
[15,] 0.080027140 0.160054279 0.9199729
[16,] 0.059028729 0.118057457 0.9409713
[17,] 0.042821291 0.085642582 0.9571787
[18,] 0.029312096 0.058624193 0.9706879
[19,] 0.017568208 0.035136417 0.9824318
[20,] 0.021981640 0.043963280 0.9780184
[21,] 0.018217158 0.036434317 0.9817828
[22,] 0.010180810 0.020361620 0.9898192
[23,] 0.013338256 0.026676513 0.9866617
[24,] 0.007613416 0.015226831 0.9923866
[25,] 0.005421956 0.010843912 0.9945780
[26,] 0.003086076 0.006172152 0.9969139
[27,] 0.002609646 0.005219291 0.9973904
[28,] 0.143163831 0.286327663 0.8568362
[29,] 0.113720630 0.227441259 0.8862794
[30,] 0.234809679 0.469619358 0.7651903
[31,] 0.220463895 0.440927789 0.7795361
> postscript(file="/var/wessaorg/rcomp/tmp/1lp6g1353092687.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/2w7hl1353092687.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/3ey0o1353092687.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/4gdz71353092687.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/5ldae1353092687.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 = 50
Frequency = 1
1 2 3 4 5 6
1.95936718 -2.07271346 12.68218996 -7.16888649 23.05414631 -7.66469519
7 8 9 10 11 12
-0.92189370 2.59511951 7.96281943 4.19684186 5.52159214 -13.43840878
13 14 15 16 17 18
16.03426547 -3.81185050 1.55889022 -11.19721766 -0.97872301 9.22429011
19 20 21 22 23 24
-5.77607770 -4.15477718 -1.01086625 6.22540198 2.45479394 6.96499736
25 26 27 28 29 30
-8.56733747 3.16110128 -7.01431677 1.38672052 -12.50970976 9.33806375
31 32 33 34 35 36
0.15696098 6.75176244 -4.46816932 -3.30198304 3.41533699 5.18829572
37 38 39 40 41 42
-16.89326947 -3.77862109 -13.00454091 -8.45711800 10.54480231 -3.37343470
43 44 45 46 47 48
-13.26556395 -0.03266277 -30.21654420 14.70770469 9.63942746 -12.85301361
49 50
22.14885050 9.05865284
> postscript(file="/var/wessaorg/rcomp/tmp/6e4li1353092687.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 = 50
Frequency = 1
lag(myerror, k = 1) myerror
0 1.95936718 NA
1 -2.07271346 1.95936718
2 12.68218996 -2.07271346
3 -7.16888649 12.68218996
4 23.05414631 -7.16888649
5 -7.66469519 23.05414631
6 -0.92189370 -7.66469519
7 2.59511951 -0.92189370
8 7.96281943 2.59511951
9 4.19684186 7.96281943
10 5.52159214 4.19684186
11 -13.43840878 5.52159214
12 16.03426547 -13.43840878
13 -3.81185050 16.03426547
14 1.55889022 -3.81185050
15 -11.19721766 1.55889022
16 -0.97872301 -11.19721766
17 9.22429011 -0.97872301
18 -5.77607770 9.22429011
19 -4.15477718 -5.77607770
20 -1.01086625 -4.15477718
21 6.22540198 -1.01086625
22 2.45479394 6.22540198
23 6.96499736 2.45479394
24 -8.56733747 6.96499736
25 3.16110128 -8.56733747
26 -7.01431677 3.16110128
27 1.38672052 -7.01431677
28 -12.50970976 1.38672052
29 9.33806375 -12.50970976
30 0.15696098 9.33806375
31 6.75176244 0.15696098
32 -4.46816932 6.75176244
33 -3.30198304 -4.46816932
34 3.41533699 -3.30198304
35 5.18829572 3.41533699
36 -16.89326947 5.18829572
37 -3.77862109 -16.89326947
38 -13.00454091 -3.77862109
39 -8.45711800 -13.00454091
40 10.54480231 -8.45711800
41 -3.37343470 10.54480231
42 -13.26556395 -3.37343470
43 -0.03266277 -13.26556395
44 -30.21654420 -0.03266277
45 14.70770469 -30.21654420
46 9.63942746 14.70770469
47 -12.85301361 9.63942746
48 22.14885050 -12.85301361
49 9.05865284 22.14885050
50 NA 9.05865284
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.07271346 1.95936718
[2,] 12.68218996 -2.07271346
[3,] -7.16888649 12.68218996
[4,] 23.05414631 -7.16888649
[5,] -7.66469519 23.05414631
[6,] -0.92189370 -7.66469519
[7,] 2.59511951 -0.92189370
[8,] 7.96281943 2.59511951
[9,] 4.19684186 7.96281943
[10,] 5.52159214 4.19684186
[11,] -13.43840878 5.52159214
[12,] 16.03426547 -13.43840878
[13,] -3.81185050 16.03426547
[14,] 1.55889022 -3.81185050
[15,] -11.19721766 1.55889022
[16,] -0.97872301 -11.19721766
[17,] 9.22429011 -0.97872301
[18,] -5.77607770 9.22429011
[19,] -4.15477718 -5.77607770
[20,] -1.01086625 -4.15477718
[21,] 6.22540198 -1.01086625
[22,] 2.45479394 6.22540198
[23,] 6.96499736 2.45479394
[24,] -8.56733747 6.96499736
[25,] 3.16110128 -8.56733747
[26,] -7.01431677 3.16110128
[27,] 1.38672052 -7.01431677
[28,] -12.50970976 1.38672052
[29,] 9.33806375 -12.50970976
[30,] 0.15696098 9.33806375
[31,] 6.75176244 0.15696098
[32,] -4.46816932 6.75176244
[33,] -3.30198304 -4.46816932
[34,] 3.41533699 -3.30198304
[35,] 5.18829572 3.41533699
[36,] -16.89326947 5.18829572
[37,] -3.77862109 -16.89326947
[38,] -13.00454091 -3.77862109
[39,] -8.45711800 -13.00454091
[40,] 10.54480231 -8.45711800
[41,] -3.37343470 10.54480231
[42,] -13.26556395 -3.37343470
[43,] -0.03266277 -13.26556395
[44,] -30.21654420 -0.03266277
[45,] 14.70770469 -30.21654420
[46,] 9.63942746 14.70770469
[47,] -12.85301361 9.63942746
[48,] 22.14885050 -12.85301361
[49,] 9.05865284 22.14885050
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.07271346 1.95936718
2 12.68218996 -2.07271346
3 -7.16888649 12.68218996
4 23.05414631 -7.16888649
5 -7.66469519 23.05414631
6 -0.92189370 -7.66469519
7 2.59511951 -0.92189370
8 7.96281943 2.59511951
9 4.19684186 7.96281943
10 5.52159214 4.19684186
11 -13.43840878 5.52159214
12 16.03426547 -13.43840878
13 -3.81185050 16.03426547
14 1.55889022 -3.81185050
15 -11.19721766 1.55889022
16 -0.97872301 -11.19721766
17 9.22429011 -0.97872301
18 -5.77607770 9.22429011
19 -4.15477718 -5.77607770
20 -1.01086625 -4.15477718
21 6.22540198 -1.01086625
22 2.45479394 6.22540198
23 6.96499736 2.45479394
24 -8.56733747 6.96499736
25 3.16110128 -8.56733747
26 -7.01431677 3.16110128
27 1.38672052 -7.01431677
28 -12.50970976 1.38672052
29 9.33806375 -12.50970976
30 0.15696098 9.33806375
31 6.75176244 0.15696098
32 -4.46816932 6.75176244
33 -3.30198304 -4.46816932
34 3.41533699 -3.30198304
35 5.18829572 3.41533699
36 -16.89326947 5.18829572
37 -3.77862109 -16.89326947
38 -13.00454091 -3.77862109
39 -8.45711800 -13.00454091
40 10.54480231 -8.45711800
41 -3.37343470 10.54480231
42 -13.26556395 -3.37343470
43 -0.03266277 -13.26556395
44 -30.21654420 -0.03266277
45 14.70770469 -30.21654420
46 9.63942746 14.70770469
47 -12.85301361 9.63942746
48 22.14885050 -12.85301361
49 9.05865284 22.14885050
> 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/7cfij1353092687.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/8koas1353092687.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/9y8tn1353092687.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/106ubz1353092687.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/110euh1353092687.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/127bub1353092687.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/13w3n51353092687.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/14fqql1353092687.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/15fhp21353092687.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/16fmmx1353092687.tab")
+ }
>
> try(system("convert tmp/1lp6g1353092687.ps tmp/1lp6g1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/2w7hl1353092687.ps tmp/2w7hl1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/3ey0o1353092687.ps tmp/3ey0o1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/4gdz71353092687.ps tmp/4gdz71353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ldae1353092687.ps tmp/5ldae1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/6e4li1353092687.ps tmp/6e4li1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/7cfij1353092687.ps tmp/7cfij1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/8koas1353092687.ps tmp/8koas1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/9y8tn1353092687.ps tmp/9y8tn1353092687.png",intern=TRUE))
character(0)
> try(system("convert tmp/106ubz1353092687.ps tmp/106ubz1353092687.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
5.807 0.869 6.686