R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i486-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(129.99
+ ,30
+ ,94
+ ,13
+ ,1
+ ,59.99
+ ,12
+ ,85.5
+ ,6.666666667
+ ,0
+ ,49.99
+ ,15
+ ,86
+ ,7
+ ,0
+ ,84.99
+ ,40
+ ,94
+ ,7.5
+ ,0
+ ,179.99
+ ,512
+ ,109
+ ,15.5
+ ,1
+ ,329.99
+ ,1500
+ ,118
+ ,15
+ ,1
+ ,25.99
+ ,16
+ ,72
+ ,10.5
+ ,0
+ ,499.99
+ ,8000
+ ,140
+ ,6
+ ,1
+ ,89.99
+ ,7
+ ,102.8
+ ,9
+ ,0
+ ,119.99
+ ,20
+ ,99.8
+ ,12
+ ,0
+ ,79.99
+ ,128
+ ,80
+ ,12
+ ,1
+ ,199.99
+ ,256
+ ,106
+ ,4.5
+ ,1
+ ,449.99
+ ,256
+ ,122
+ ,6
+ ,1
+ ,549.99
+ ,4000
+ ,161
+ ,5.5
+ ,1
+ ,529.99
+ ,8000
+ ,135
+ ,12
+ ,1
+ ,639.99
+ ,16000
+ ,140
+ ,7
+ ,1
+ ,749.99
+ ,32000
+ ,140
+ ,7
+ ,1
+ ,399.99
+ ,130
+ ,135
+ ,6
+ ,1
+ ,169.99
+ ,256
+ ,109
+ ,7
+ ,1
+ ,189.99
+ ,8000
+ ,135
+ ,5
+ ,1
+ ,199.99
+ ,8000
+ ,135
+ ,5
+ ,1
+ ,69.99
+ ,20
+ ,90
+ ,4.5
+ ,0
+ ,69.99
+ ,20
+ ,90
+ ,4.5
+ ,0
+ ,109.99
+ ,5
+ ,81
+ ,3.5
+ ,1
+ ,159.99
+ ,128
+ ,104
+ ,4.75
+ ,1
+ ,159.99
+ ,128
+ ,104
+ ,4.75
+ ,1
+ ,199.99
+ ,1000
+ ,135
+ ,10
+ ,1
+ ,75
+ ,30
+ ,81
+ ,4
+ ,0
+ ,349.99
+ ,512
+ ,126
+ ,6
+ ,1
+ ,439.99
+ ,8000
+ ,140
+ ,3
+ ,1
+ ,309.99
+ ,512
+ ,120
+ ,7
+ ,1
+ ,379.99
+ ,512
+ ,120
+ ,9
+ ,1
+ ,349.99
+ ,512
+ ,110
+ ,7
+ ,1
+ ,169.99
+ ,256
+ ,108
+ ,7
+ ,0
+ ,239.99
+ ,192
+ ,120
+ ,8
+ ,1
+ ,229.99
+ ,512
+ ,118
+ ,7
+ ,1
+ ,69.99
+ ,64
+ ,85
+ ,6
+ ,0
+ ,99.99
+ ,20
+ ,94
+ ,7
+ ,0
+ ,29.99
+ ,8
+ ,72.6
+ ,13
+ ,0
+ ,39.99
+ ,12
+ ,78
+ ,4
+ ,0
+ ,21.99
+ ,8
+ ,65
+ ,10
+ ,0
+ ,499.99
+ ,60
+ ,130
+ ,3
+ ,1
+ ,29.99
+ ,1
+ ,70
+ ,4.5
+ ,0
+ ,29.99
+ ,4
+ ,78.5
+ ,8.52
+ ,0
+ ,49.99
+ ,32
+ ,93.5
+ ,5.2
+ ,0
+ ,49.99
+ ,10
+ ,80
+ ,4
+ ,0
+ ,55.99
+ ,10
+ ,78.8
+ ,10.4
+ ,0
+ ,59.99
+ ,9
+ ,90.3
+ ,5
+ ,0
+ ,79.99
+ ,30
+ ,87.7
+ ,7.2
+ ,0
+ ,139.99
+ ,51
+ ,107
+ ,7.4
+ ,0
+ ,159.99
+ ,16000
+ ,90
+ ,12
+ ,0
+ ,169.99
+ ,46
+ ,103
+ ,7.3
+ ,1
+ ,229.99
+ ,32000
+ ,126
+ ,12.3
+ ,1
+ ,249.99
+ ,16000
+ ,98
+ ,8
+ ,1
+ ,309.99
+ ,256
+ ,128
+ ,12.3
+ ,1
+ ,499.99
+ ,16000
+ ,132
+ ,5.5
+ ,1
+ ,65.99
+ ,7
+ ,94
+ ,9
+ ,0
+ ,89.99
+ ,48
+ ,111
+ ,5.4
+ ,0
+ ,89.99
+ ,100
+ ,95
+ ,3.3
+ ,0
+ ,449.99
+ ,16000
+ ,155
+ ,10
+ ,1)
+ ,dim=c(5
+ ,60)
+ ,dimnames=list(c('Prijs'
+ ,'Geheugen'
+ ,'Gewicht'
+ ,'Batterij'
+ ,'WiFi')
+ ,1:60))
> y <- array(NA,dim=c(5,60),dimnames=list(c('Prijs','Geheugen','Gewicht','Batterij','WiFi'),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
> 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
Prijs Geheugen Gewicht Batterij WiFi
1 129.99 30 94.0 13.000000 1
2 59.99 12 85.5 6.666667 0
3 49.99 15 86.0 7.000000 0
4 84.99 40 94.0 7.500000 0
5 179.99 512 109.0 15.500000 1
6 329.99 1500 118.0 15.000000 1
7 25.99 16 72.0 10.500000 0
8 499.99 8000 140.0 6.000000 1
9 89.99 7 102.8 9.000000 0
10 119.99 20 99.8 12.000000 0
11 79.99 128 80.0 12.000000 1
12 199.99 256 106.0 4.500000 1
13 449.99 256 122.0 6.000000 1
14 549.99 4000 161.0 5.500000 1
15 529.99 8000 135.0 12.000000 1
16 639.99 16000 140.0 7.000000 1
17 749.99 32000 140.0 7.000000 1
18 399.99 130 135.0 6.000000 1
19 169.99 256 109.0 7.000000 1
20 189.99 8000 135.0 5.000000 1
21 199.99 8000 135.0 5.000000 1
22 69.99 20 90.0 4.500000 0
23 69.99 20 90.0 4.500000 0
24 109.99 5 81.0 3.500000 1
25 159.99 128 104.0 4.750000 1
26 159.99 128 104.0 4.750000 1
27 199.99 1000 135.0 10.000000 1
28 75.00 30 81.0 4.000000 0
29 349.99 512 126.0 6.000000 1
30 439.99 8000 140.0 3.000000 1
31 309.99 512 120.0 7.000000 1
32 379.99 512 120.0 9.000000 1
33 349.99 512 110.0 7.000000 1
34 169.99 256 108.0 7.000000 0
35 239.99 192 120.0 8.000000 1
36 229.99 512 118.0 7.000000 1
37 69.99 64 85.0 6.000000 0
38 99.99 20 94.0 7.000000 0
39 29.99 8 72.6 13.000000 0
40 39.99 12 78.0 4.000000 0
41 21.99 8 65.0 10.000000 0
42 499.99 60 130.0 3.000000 1
43 29.99 1 70.0 4.500000 0
44 29.99 4 78.5 8.520000 0
45 49.99 32 93.5 5.200000 0
46 49.99 10 80.0 4.000000 0
47 55.99 10 78.8 10.400000 0
48 59.99 9 90.3 5.000000 0
49 79.99 30 87.7 7.200000 0
50 139.99 51 107.0 7.400000 0
51 159.99 16000 90.0 12.000000 0
52 169.99 46 103.0 7.300000 1
53 229.99 32000 126.0 12.300000 1
54 249.99 16000 98.0 8.000000 1
55 309.99 256 128.0 12.300000 1
56 499.99 16000 132.0 5.500000 1
57 65.99 7 94.0 9.000000 0
58 89.99 48 111.0 5.400000 0
59 89.99 100 95.0 3.300000 0
60 449.99 16000 155.0 10.000000 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Geheugen Gewicht Batterij WiFi
-3.226e+02 5.148e-03 4.687e+00 -2.824e+00 6.944e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-237.405 -33.359 1.147 37.543 202.014
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -3.226e+02 7.715e+01 -4.181 0.000105 ***
Geheugen 5.148e-03 1.781e-03 2.891 0.005492 **
Gewicht 4.687e+00 7.509e-01 6.242 6.53e-08 ***
Batterij -2.824e+00 3.699e+00 -0.763 0.448464
WiFi 6.944e+01 3.249e+01 2.138 0.037012 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 85.55 on 55 degrees of freedom
Multiple R-squared: 0.7816, Adjusted R-squared: 0.7658
F-statistic: 49.22 on 4 and 55 DF, p-value: < 2.2e-16
> if (n > n25) {
+ kp3 <- k + 3
+ nmkm3 <- n - k - 3
+ gqarr <- array(NA, dim=c(nmkm3-kp3+1,3))
+ numgqtests <- 0
+ numsignificant1 <- 0
+ numsignificant5 <- 0
+ numsignificant10 <- 0
+ for (mypoint in kp3:nmkm3) {
+ j <- 0
+ numgqtests <- numgqtests + 1
+ for (myalt in c('greater', 'two.sided', 'less')) {
+ j <- j + 1
+ gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value
+ }
+ if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1
+ if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1
+ }
+ gqarr
+ }
[,1] [,2] [,3]
[1,] 0.076096769 0.152193538 0.92390323
[2,] 0.041164777 0.082329554 0.95883522
[3,] 0.013586926 0.027173852 0.98641307
[4,] 0.004183415 0.008366830 0.99581659
[5,] 0.002198594 0.004397188 0.99780141
[6,] 0.077155039 0.154310077 0.92284496
[7,] 0.049962700 0.099925401 0.95003730
[8,] 0.052772690 0.105545380 0.94722731
[9,] 0.046820027 0.093640054 0.95317997
[10,] 0.127027250 0.254054500 0.87297275
[11,] 0.089490115 0.178980230 0.91050989
[12,] 0.118934293 0.237868586 0.88106571
[13,] 0.880529440 0.238941121 0.11947056
[14,] 0.989212067 0.021575866 0.01078793
[15,] 0.982377228 0.035245544 0.01762277
[16,] 0.972159040 0.055681920 0.02784096
[17,] 0.964285080 0.071429840 0.03571492
[18,] 0.960711947 0.078576106 0.03928805
[19,] 0.963198142 0.073603716 0.03680186
[20,] 0.991306720 0.017386560 0.00869328
[21,] 0.986328388 0.027343224 0.01367161
[22,] 0.979936333 0.040127335 0.02006367
[23,] 0.968524574 0.062950853 0.03147543
[24,] 0.953645525 0.092708949 0.04635447
[25,] 0.958526075 0.082947850 0.04147392
[26,] 0.967009097 0.065981806 0.03299090
[27,] 0.949919578 0.100160843 0.05008042
[28,] 0.939001928 0.121996144 0.06099807
[29,] 0.939770228 0.120459544 0.06022977
[30,] 0.909390555 0.181218891 0.09060945
[31,] 0.868033321 0.263933358 0.13196668
[32,] 0.831218610 0.337562779 0.16878139
[33,] 0.771196109 0.457607782 0.22880389
[34,] 0.739308810 0.521382380 0.26069119
[35,] 0.892311078 0.215377844 0.10768892
[36,] 0.844581978 0.310836044 0.15541802
[37,] 0.776293760 0.447412481 0.22370624
[38,] 0.720353911 0.559292179 0.27964609
[39,] 0.622996943 0.754006115 0.37700306
[40,] 0.542907433 0.914185133 0.45709257
[41,] 0.436458022 0.872916043 0.56354198
[42,] 0.325824384 0.651648769 0.67417562
[43,] 0.220198387 0.440396773 0.77980161
[44,] 0.434836383 0.869672767 0.56516362
[45,] 0.605708087 0.788583826 0.39429191
> postscript(file="/var/wessaorg/rcomp/tmp/109qx1321985234.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/23uvg1321985234.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/3okkv1321985234.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/4nmc61321985234.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/53idt1321985234.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
-20.8731482 0.6163238 -10.8013265 -12.0127591 -36.5976671 64.7230775
7 8 9 10 11 12
40.6915897 72.7394823 -43.8514630 8.6128848 -8.5858026 -32.2790264
13 14 15 16 17 18
146.9673050 43.4959974 143.1152052 174.3801231 202.0141928 36.6873111
19 20 21 22 23 24
-69.2804634 -216.6500370 -206.6500370 -16.6333503 -16.6333503 -6.6400830
25 26 27 28 29 30
-61.5405627 -61.5405627 -156.4969123 29.0947242 26.9021807 4.2686642
31 32 33 34 35 36
17.8466908 93.4939028 104.7148644 4.8480549 -47.6823846 -52.7796745
37 38 39 40 41 42
10.8096392 1.6783953 48.9796973 8.2378379 68.1286911 152.0109307
43 44 45 46 47 48
37.2008063 8.6983114 -51.1224613 8.8744989 38.5697583 -26.5709659
49 50 51 52 53 54
11.7185872 -18.2803719 12.2807219 -39.2314246 -237.4052524 -15.9499420
55 56 57 58 59 60
-3.3648812 67.6392529 -26.6074703 -92.6594097 -23.8675939 -77.4513191
> postscript(file="/var/wessaorg/rcomp/tmp/6ianu1321985234.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 -20.8731482 NA
1 0.6163238 -20.8731482
2 -10.8013265 0.6163238
3 -12.0127591 -10.8013265
4 -36.5976671 -12.0127591
5 64.7230775 -36.5976671
6 40.6915897 64.7230775
7 72.7394823 40.6915897
8 -43.8514630 72.7394823
9 8.6128848 -43.8514630
10 -8.5858026 8.6128848
11 -32.2790264 -8.5858026
12 146.9673050 -32.2790264
13 43.4959974 146.9673050
14 143.1152052 43.4959974
15 174.3801231 143.1152052
16 202.0141928 174.3801231
17 36.6873111 202.0141928
18 -69.2804634 36.6873111
19 -216.6500370 -69.2804634
20 -206.6500370 -216.6500370
21 -16.6333503 -206.6500370
22 -16.6333503 -16.6333503
23 -6.6400830 -16.6333503
24 -61.5405627 -6.6400830
25 -61.5405627 -61.5405627
26 -156.4969123 -61.5405627
27 29.0947242 -156.4969123
28 26.9021807 29.0947242
29 4.2686642 26.9021807
30 17.8466908 4.2686642
31 93.4939028 17.8466908
32 104.7148644 93.4939028
33 4.8480549 104.7148644
34 -47.6823846 4.8480549
35 -52.7796745 -47.6823846
36 10.8096392 -52.7796745
37 1.6783953 10.8096392
38 48.9796973 1.6783953
39 8.2378379 48.9796973
40 68.1286911 8.2378379
41 152.0109307 68.1286911
42 37.2008063 152.0109307
43 8.6983114 37.2008063
44 -51.1224613 8.6983114
45 8.8744989 -51.1224613
46 38.5697583 8.8744989
47 -26.5709659 38.5697583
48 11.7185872 -26.5709659
49 -18.2803719 11.7185872
50 12.2807219 -18.2803719
51 -39.2314246 12.2807219
52 -237.4052524 -39.2314246
53 -15.9499420 -237.4052524
54 -3.3648812 -15.9499420
55 67.6392529 -3.3648812
56 -26.6074703 67.6392529
57 -92.6594097 -26.6074703
58 -23.8675939 -92.6594097
59 -77.4513191 -23.8675939
60 NA -77.4513191
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.6163238 -20.8731482
[2,] -10.8013265 0.6163238
[3,] -12.0127591 -10.8013265
[4,] -36.5976671 -12.0127591
[5,] 64.7230775 -36.5976671
[6,] 40.6915897 64.7230775
[7,] 72.7394823 40.6915897
[8,] -43.8514630 72.7394823
[9,] 8.6128848 -43.8514630
[10,] -8.5858026 8.6128848
[11,] -32.2790264 -8.5858026
[12,] 146.9673050 -32.2790264
[13,] 43.4959974 146.9673050
[14,] 143.1152052 43.4959974
[15,] 174.3801231 143.1152052
[16,] 202.0141928 174.3801231
[17,] 36.6873111 202.0141928
[18,] -69.2804634 36.6873111
[19,] -216.6500370 -69.2804634
[20,] -206.6500370 -216.6500370
[21,] -16.6333503 -206.6500370
[22,] -16.6333503 -16.6333503
[23,] -6.6400830 -16.6333503
[24,] -61.5405627 -6.6400830
[25,] -61.5405627 -61.5405627
[26,] -156.4969123 -61.5405627
[27,] 29.0947242 -156.4969123
[28,] 26.9021807 29.0947242
[29,] 4.2686642 26.9021807
[30,] 17.8466908 4.2686642
[31,] 93.4939028 17.8466908
[32,] 104.7148644 93.4939028
[33,] 4.8480549 104.7148644
[34,] -47.6823846 4.8480549
[35,] -52.7796745 -47.6823846
[36,] 10.8096392 -52.7796745
[37,] 1.6783953 10.8096392
[38,] 48.9796973 1.6783953
[39,] 8.2378379 48.9796973
[40,] 68.1286911 8.2378379
[41,] 152.0109307 68.1286911
[42,] 37.2008063 152.0109307
[43,] 8.6983114 37.2008063
[44,] -51.1224613 8.6983114
[45,] 8.8744989 -51.1224613
[46,] 38.5697583 8.8744989
[47,] -26.5709659 38.5697583
[48,] 11.7185872 -26.5709659
[49,] -18.2803719 11.7185872
[50,] 12.2807219 -18.2803719
[51,] -39.2314246 12.2807219
[52,] -237.4052524 -39.2314246
[53,] -15.9499420 -237.4052524
[54,] -3.3648812 -15.9499420
[55,] 67.6392529 -3.3648812
[56,] -26.6074703 67.6392529
[57,] -92.6594097 -26.6074703
[58,] -23.8675939 -92.6594097
[59,] -77.4513191 -23.8675939
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.6163238 -20.8731482
2 -10.8013265 0.6163238
3 -12.0127591 -10.8013265
4 -36.5976671 -12.0127591
5 64.7230775 -36.5976671
6 40.6915897 64.7230775
7 72.7394823 40.6915897
8 -43.8514630 72.7394823
9 8.6128848 -43.8514630
10 -8.5858026 8.6128848
11 -32.2790264 -8.5858026
12 146.9673050 -32.2790264
13 43.4959974 146.9673050
14 143.1152052 43.4959974
15 174.3801231 143.1152052
16 202.0141928 174.3801231
17 36.6873111 202.0141928
18 -69.2804634 36.6873111
19 -216.6500370 -69.2804634
20 -206.6500370 -216.6500370
21 -16.6333503 -206.6500370
22 -16.6333503 -16.6333503
23 -6.6400830 -16.6333503
24 -61.5405627 -6.6400830
25 -61.5405627 -61.5405627
26 -156.4969123 -61.5405627
27 29.0947242 -156.4969123
28 26.9021807 29.0947242
29 4.2686642 26.9021807
30 17.8466908 4.2686642
31 93.4939028 17.8466908
32 104.7148644 93.4939028
33 4.8480549 104.7148644
34 -47.6823846 4.8480549
35 -52.7796745 -47.6823846
36 10.8096392 -52.7796745
37 1.6783953 10.8096392
38 48.9796973 1.6783953
39 8.2378379 48.9796973
40 68.1286911 8.2378379
41 152.0109307 68.1286911
42 37.2008063 152.0109307
43 8.6983114 37.2008063
44 -51.1224613 8.6983114
45 8.8744989 -51.1224613
46 38.5697583 8.8744989
47 -26.5709659 38.5697583
48 11.7185872 -26.5709659
49 -18.2803719 11.7185872
50 12.2807219 -18.2803719
51 -39.2314246 12.2807219
52 -237.4052524 -39.2314246
53 -15.9499420 -237.4052524
54 -3.3648812 -15.9499420
55 67.6392529 -3.3648812
56 -26.6074703 67.6392529
57 -92.6594097 -26.6074703
58 -23.8675939 -92.6594097
59 -77.4513191 -23.8675939
> 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/746me1321985234.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/8bywb1321985234.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/97n8a1321985234.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/10h4r61321985234.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/11ob2c1321985234.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/12xei11321985234.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/13xwug1321985234.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/146ibb1321985235.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/15oxqz1321985235.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/16vmb21321985235.tab")
+ }
>
> try(system("convert tmp/109qx1321985234.ps tmp/109qx1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/23uvg1321985234.ps tmp/23uvg1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/3okkv1321985234.ps tmp/3okkv1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/4nmc61321985234.ps tmp/4nmc61321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/53idt1321985234.ps tmp/53idt1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ianu1321985234.ps tmp/6ianu1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/746me1321985234.ps tmp/746me1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/8bywb1321985234.ps tmp/8bywb1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/97n8a1321985234.ps tmp/97n8a1321985234.png",intern=TRUE))
character(0)
> try(system("convert tmp/10h4r61321985234.ps tmp/10h4r61321985234.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.245 0.562 4.003