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(73
+ ,2
+ ,71.91
+ ,5.11
+ ,50
+ ,3
+ ,28
+ ,6
+ ,6.06
+ ,3.53
+ ,48
+ ,5
+ ,40
+ ,5
+ ,8.1
+ ,4.52
+ ,63
+ ,11
+ ,79
+ ,3
+ ,79.38
+ ,3.72
+ ,113
+ ,13
+ ,75
+ ,3
+ ,65.34
+ ,5.99
+ ,128
+ ,11
+ ,21
+ ,3
+ ,34.62
+ ,3.15
+ ,52
+ ,7
+ ,16
+ ,2
+ ,26.26
+ ,3.17
+ ,104
+ ,1
+ ,81
+ ,2
+ ,60.92
+ ,3.5
+ ,40
+ ,1
+ ,90
+ ,2
+ ,39.56
+ ,3.39
+ ,89
+ ,11
+ ,87
+ ,5
+ ,65.61
+ ,4.15
+ ,97
+ ,3
+ ,99
+ ,3
+ ,56.49
+ ,4.5
+ ,29
+ ,9
+ ,54
+ ,3
+ ,56.19
+ ,3.31
+ ,36
+ ,5
+ ,53
+ ,5
+ ,80.3
+ ,3.09
+ ,114
+ ,11
+ ,6
+ ,4
+ ,61.2
+ ,5.31
+ ,49
+ ,9
+ ,71
+ ,5
+ ,58.2
+ ,4.24
+ ,57
+ ,7
+ ,93
+ ,6
+ ,75.91
+ ,5.06
+ ,82
+ ,4
+ ,82
+ ,3
+ ,73.66
+ ,4.72
+ ,34
+ ,10
+ ,32
+ ,4
+ ,73.87
+ ,4.58
+ ,36
+ ,13
+ ,93
+ ,4
+ ,87.21
+ ,5.3
+ ,89
+ ,9
+ ,24
+ ,4
+ ,64.29
+ ,5.11
+ ,69
+ ,5
+ ,96
+ ,5
+ ,71.82
+ ,4.05
+ ,35
+ ,8
+ ,88
+ ,4
+ ,89.31
+ ,4.62
+ ,65
+ ,12
+ ,83
+ ,2
+ ,1.41
+ ,4.66
+ ,70
+ ,8
+ ,23
+ ,6
+ ,35.17
+ ,4.66
+ ,60
+ ,5
+ ,23
+ ,5
+ ,34.68
+ ,2.76
+ ,57
+ ,9
+ ,20
+ ,5
+ ,41.08
+ ,5.1
+ ,127
+ ,11
+ ,33
+ ,3
+ ,30.57
+ ,4.97
+ ,96
+ ,8
+ ,88
+ ,2
+ ,68.84
+ ,2.87
+ ,61
+ ,9
+ ,42
+ ,6
+ ,7.17
+ ,5.14
+ ,127
+ ,10
+ ,98
+ ,2
+ ,71.05
+ ,4.98
+ ,36
+ ,1
+ ,34
+ ,4
+ ,23.32
+ ,4.55
+ ,55
+ ,9
+ ,59
+ ,3
+ ,61.39
+ ,5.45
+ ,75
+ ,2
+ ,26
+ ,6
+ ,8.41
+ ,4.36
+ ,42
+ ,3
+ ,64
+ ,4
+ ,65.88
+ ,4.78
+ ,64
+ ,4
+ ,13
+ ,1
+ ,64.06
+ ,4.74
+ ,83
+ ,3
+ ,6
+ ,2
+ ,26.8
+ ,5.44
+ ,56
+ ,1
+ ,49
+ ,4
+ ,12.78
+ ,5.78
+ ,114
+ ,5
+ ,3
+ ,5
+ ,23.84
+ ,2.92
+ ,33
+ ,4
+ ,87
+ ,6
+ ,42.69
+ ,4.22
+ ,91
+ ,2
+ ,77
+ ,2
+ ,54.94
+ ,3.93
+ ,127
+ ,2
+ ,70
+ ,4
+ ,89.99
+ ,3.01
+ ,45
+ ,10
+ ,76
+ ,4
+ ,5.68
+ ,3.22
+ ,80
+ ,6
+ ,82
+ ,4
+ ,72.64
+ ,5.12
+ ,40
+ ,9
+ ,12
+ ,2
+ ,45.92
+ ,3.04
+ ,115
+ ,7
+ ,44
+ ,3
+ ,24.96
+ ,5.82
+ ,33
+ ,1
+ ,63
+ ,5
+ ,18.17
+ ,3.11
+ ,127
+ ,13
+ ,35
+ ,1
+ ,29.12
+ ,3.87
+ ,45
+ ,9
+ ,69
+ ,1
+ ,40.08
+ ,3.75
+ ,74
+ ,11
+ ,10
+ ,5
+ ,1.08
+ ,4.82
+ ,105
+ ,10
+ ,36
+ ,2
+ ,57.52
+ ,2.83
+ ,60
+ ,7)
+ ,dim=c(6
+ ,50)
+ ,dimnames=list(c('slaagkans'
+ ,'verzekeraar'
+ ,'kost'
+ ,'grootte'
+ ,'snelheid'
+ ,'maand')
+ ,1:50))
> y <- array(NA,dim=c(6,50),dimnames=list(c('slaagkans','verzekeraar','kost','grootte','snelheid','maand'),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 = '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
slaagkans verzekeraar kost grootte snelheid maand
1 73 2 71.91 5.11 50 3
2 28 6 6.06 3.53 48 5
3 40 5 8.10 4.52 63 11
4 79 3 79.38 3.72 113 13
5 75 3 65.34 5.99 128 11
6 21 3 34.62 3.15 52 7
7 16 2 26.26 3.17 104 1
8 81 2 60.92 3.50 40 1
9 90 2 39.56 3.39 89 11
10 87 5 65.61 4.15 97 3
11 99 3 56.49 4.50 29 9
12 54 3 56.19 3.31 36 5
13 53 5 80.30 3.09 114 11
14 6 4 61.20 5.31 49 9
15 71 5 58.20 4.24 57 7
16 93 6 75.91 5.06 82 4
17 82 3 73.66 4.72 34 10
18 32 4 73.87 4.58 36 13
19 93 4 87.21 5.30 89 9
20 24 4 64.29 5.11 69 5
21 96 5 71.82 4.05 35 8
22 88 4 89.31 4.62 65 12
23 83 2 1.41 4.66 70 8
24 23 6 35.17 4.66 60 5
25 23 5 34.68 2.76 57 9
26 20 5 41.08 5.10 127 11
27 33 3 30.57 4.97 96 8
28 88 2 68.84 2.87 61 9
29 42 6 7.17 5.14 127 10
30 98 2 71.05 4.98 36 1
31 34 4 23.32 4.55 55 9
32 59 3 61.39 5.45 75 2
33 26 6 8.41 4.36 42 3
34 64 4 65.88 4.78 64 4
35 13 1 64.06 4.74 83 3
36 6 2 26.80 5.44 56 1
37 49 4 12.78 5.78 114 5
38 3 5 23.84 2.92 33 4
39 87 6 42.69 4.22 91 2
40 77 2 54.94 3.93 127 2
41 70 4 89.99 3.01 45 10
42 76 4 5.68 3.22 80 6
43 82 4 72.64 5.12 40 9
44 12 2 45.92 3.04 115 7
45 44 3 24.96 5.82 33 1
46 63 5 18.17 3.11 127 13
47 35 1 29.12 3.87 45 9
48 69 1 40.08 3.75 74 11
49 10 5 1.08 4.82 105 10
50 36 2 57.52 2.83 60 7
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) verzekeraar kost grootte snelheid maand
21.2435 -0.1890 0.5467 0.7887 0.0270 0.3451
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-56.560 -22.177 4.155 18.482 53.037
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 21.2435 24.7105 0.860 0.39462
verzekeraar -0.1890 2.7668 -0.068 0.94584
kost 0.5467 0.1589 3.440 0.00128 **
grootte 0.7887 4.4479 0.177 0.86007
snelheid 0.0270 0.1341 0.201 0.84141
maand 0.3451 1.1346 0.304 0.76244
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 27.79 on 44 degrees of freedom
Multiple R-squared: 0.2302, Adjusted R-squared: 0.1427
F-statistic: 2.632 on 5 and 44 DF, p-value: 0.03632
> 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.5370328 0.9259344 0.4629672
[2,] 0.4878840 0.9757681 0.5121160
[3,] 0.4118896 0.8237792 0.5881104
[4,] 0.3282962 0.6565924 0.6717038
[5,] 0.2937722 0.5875444 0.7062278
[6,] 0.7324441 0.5351118 0.2675559
[7,] 0.6537194 0.6925611 0.3462806
[8,] 0.6146210 0.7707580 0.3853790
[9,] 0.5217571 0.9564857 0.4782429
[10,] 0.5837841 0.8324317 0.4162159
[11,] 0.5042974 0.9914052 0.4957026
[12,] 0.5862232 0.8275536 0.4137768
[13,] 0.5804861 0.8390277 0.4195139
[14,] 0.4974537 0.9949075 0.5025463
[15,] 0.6695425 0.6609150 0.3304575
[16,] 0.6380185 0.7239629 0.3619815
[17,] 0.6015503 0.7968995 0.3984497
[18,] 0.6431746 0.7136508 0.3568254
[19,] 0.5758008 0.8483983 0.4241992
[20,] 0.5402625 0.9194749 0.4597375
[21,] 0.4706840 0.9413680 0.5293160
[22,] 0.5485785 0.9028430 0.4514215
[23,] 0.4595332 0.9190663 0.5404668
[24,] 0.3685137 0.7370275 0.6314863
[25,] 0.2854932 0.5709864 0.7145068
[26,] 0.2049348 0.4098696 0.7950652
[27,] 0.3177798 0.6355596 0.6822202
[28,] 0.3401494 0.6802987 0.6598506
[29,] 0.2584750 0.5169501 0.7415250
[30,] 0.3303951 0.6607901 0.6696049
[31,] 0.2700796 0.5401592 0.7299204
[32,] 0.3677449 0.7354898 0.6322551
[33,] 0.2629762 0.5259525 0.7370238
> postscript(file="/var/www/html/rcomp/tmp/1lzm01290534863.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/2e8l31290534863.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/3e8l31290534863.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/4e8l31290534863.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/5pz261290534863.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 = 50
Frequency = 1
1 2 3 4 5 6
6.4086970 -1.2278267 6.2115338 4.4582820 6.6282185 -24.9059703
7 8 9 10 11 12
-24.8742385 22.6464801 38.6357337 23.9077205 40.0047466 -2.7013427
13 14 15 16 17 18
-20.5065342 -56.5598800 11.5871859 23.8083973 12.9649956 -37.9396706
19 20 21 22 23 24
15.1493112 -39.2509722 29.5405044 9.1503966 53.0374811 -23.3563010
25 26 27 28 29 30
-23.0783539 -34.0028718 -13.6606222 22.4859597 7.0368942 33.0495890
31 32 33 34 35 36
-7.4150705 -2.2495522 -4.3148653 0.6202191 -50.0883295 -35.6636164
37 38 39 40 41 42
12.1638739 -34.9052013 37.0780642 18.8820339 -6.7212994 45.6371678
43 44 45 46 47 48
13.5792195 -41.8866456 3.8526183 22.4003549 -9.3464233 17.2835640
49 50
-20.9765395 -22.5771156
> postscript(file="/var/www/html/rcomp/tmp/6pz261290534863.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 = 50
Frequency = 1
lag(myerror, k = 1) myerror
0 6.4086970 NA
1 -1.2278267 6.4086970
2 6.2115338 -1.2278267
3 4.4582820 6.2115338
4 6.6282185 4.4582820
5 -24.9059703 6.6282185
6 -24.8742385 -24.9059703
7 22.6464801 -24.8742385
8 38.6357337 22.6464801
9 23.9077205 38.6357337
10 40.0047466 23.9077205
11 -2.7013427 40.0047466
12 -20.5065342 -2.7013427
13 -56.5598800 -20.5065342
14 11.5871859 -56.5598800
15 23.8083973 11.5871859
16 12.9649956 23.8083973
17 -37.9396706 12.9649956
18 15.1493112 -37.9396706
19 -39.2509722 15.1493112
20 29.5405044 -39.2509722
21 9.1503966 29.5405044
22 53.0374811 9.1503966
23 -23.3563010 53.0374811
24 -23.0783539 -23.3563010
25 -34.0028718 -23.0783539
26 -13.6606222 -34.0028718
27 22.4859597 -13.6606222
28 7.0368942 22.4859597
29 33.0495890 7.0368942
30 -7.4150705 33.0495890
31 -2.2495522 -7.4150705
32 -4.3148653 -2.2495522
33 0.6202191 -4.3148653
34 -50.0883295 0.6202191
35 -35.6636164 -50.0883295
36 12.1638739 -35.6636164
37 -34.9052013 12.1638739
38 37.0780642 -34.9052013
39 18.8820339 37.0780642
40 -6.7212994 18.8820339
41 45.6371678 -6.7212994
42 13.5792195 45.6371678
43 -41.8866456 13.5792195
44 3.8526183 -41.8866456
45 22.4003549 3.8526183
46 -9.3464233 22.4003549
47 17.2835640 -9.3464233
48 -20.9765395 17.2835640
49 -22.5771156 -20.9765395
50 NA -22.5771156
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.2278267 6.4086970
[2,] 6.2115338 -1.2278267
[3,] 4.4582820 6.2115338
[4,] 6.6282185 4.4582820
[5,] -24.9059703 6.6282185
[6,] -24.8742385 -24.9059703
[7,] 22.6464801 -24.8742385
[8,] 38.6357337 22.6464801
[9,] 23.9077205 38.6357337
[10,] 40.0047466 23.9077205
[11,] -2.7013427 40.0047466
[12,] -20.5065342 -2.7013427
[13,] -56.5598800 -20.5065342
[14,] 11.5871859 -56.5598800
[15,] 23.8083973 11.5871859
[16,] 12.9649956 23.8083973
[17,] -37.9396706 12.9649956
[18,] 15.1493112 -37.9396706
[19,] -39.2509722 15.1493112
[20,] 29.5405044 -39.2509722
[21,] 9.1503966 29.5405044
[22,] 53.0374811 9.1503966
[23,] -23.3563010 53.0374811
[24,] -23.0783539 -23.3563010
[25,] -34.0028718 -23.0783539
[26,] -13.6606222 -34.0028718
[27,] 22.4859597 -13.6606222
[28,] 7.0368942 22.4859597
[29,] 33.0495890 7.0368942
[30,] -7.4150705 33.0495890
[31,] -2.2495522 -7.4150705
[32,] -4.3148653 -2.2495522
[33,] 0.6202191 -4.3148653
[34,] -50.0883295 0.6202191
[35,] -35.6636164 -50.0883295
[36,] 12.1638739 -35.6636164
[37,] -34.9052013 12.1638739
[38,] 37.0780642 -34.9052013
[39,] 18.8820339 37.0780642
[40,] -6.7212994 18.8820339
[41,] 45.6371678 -6.7212994
[42,] 13.5792195 45.6371678
[43,] -41.8866456 13.5792195
[44,] 3.8526183 -41.8866456
[45,] 22.4003549 3.8526183
[46,] -9.3464233 22.4003549
[47,] 17.2835640 -9.3464233
[48,] -20.9765395 17.2835640
[49,] -22.5771156 -20.9765395
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.2278267 6.4086970
2 6.2115338 -1.2278267
3 4.4582820 6.2115338
4 6.6282185 4.4582820
5 -24.9059703 6.6282185
6 -24.8742385 -24.9059703
7 22.6464801 -24.8742385
8 38.6357337 22.6464801
9 23.9077205 38.6357337
10 40.0047466 23.9077205
11 -2.7013427 40.0047466
12 -20.5065342 -2.7013427
13 -56.5598800 -20.5065342
14 11.5871859 -56.5598800
15 23.8083973 11.5871859
16 12.9649956 23.8083973
17 -37.9396706 12.9649956
18 15.1493112 -37.9396706
19 -39.2509722 15.1493112
20 29.5405044 -39.2509722
21 9.1503966 29.5405044
22 53.0374811 9.1503966
23 -23.3563010 53.0374811
24 -23.0783539 -23.3563010
25 -34.0028718 -23.0783539
26 -13.6606222 -34.0028718
27 22.4859597 -13.6606222
28 7.0368942 22.4859597
29 33.0495890 7.0368942
30 -7.4150705 33.0495890
31 -2.2495522 -7.4150705
32 -4.3148653 -2.2495522
33 0.6202191 -4.3148653
34 -50.0883295 0.6202191
35 -35.6636164 -50.0883295
36 12.1638739 -35.6636164
37 -34.9052013 12.1638739
38 37.0780642 -34.9052013
39 18.8820339 37.0780642
40 -6.7212994 18.8820339
41 45.6371678 -6.7212994
42 13.5792195 45.6371678
43 -41.8866456 13.5792195
44 3.8526183 -41.8866456
45 22.4003549 3.8526183
46 -9.3464233 22.4003549
47 17.2835640 -9.3464233
48 -20.9765395 17.2835640
49 -22.5771156 -20.9765395
> 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/7z81r1290534863.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/8a0iu1290534863.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/9a0iu1290534863.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/103r0x1290534863.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/116sy31290534863.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/12rsf91290534863.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/1362ci1290534863.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/1492b51290534863.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/15ulat1290534863.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/16y38h1290534863.tab")
+ }
>
> try(system("convert tmp/1lzm01290534863.ps tmp/1lzm01290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/2e8l31290534863.ps tmp/2e8l31290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/3e8l31290534863.ps tmp/3e8l31290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/4e8l31290534863.ps tmp/4e8l31290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/5pz261290534863.ps tmp/5pz261290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/6pz261290534863.ps tmp/6pz261290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/7z81r1290534863.ps tmp/7z81r1290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/8a0iu1290534863.ps tmp/8a0iu1290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/9a0iu1290534863.ps tmp/9a0iu1290534863.png",intern=TRUE))
character(0)
> try(system("convert tmp/103r0x1290534863.ps tmp/103r0x1290534863.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.389 1.573 5.428