R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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(99.2
+ ,11554.5
+ ,93.6
+ ,13182.1
+ ,104.2
+ ,14800.1
+ ,95.3
+ ,12150.7
+ ,102.7
+ ,14478.2
+ ,103.1
+ ,13253.9
+ ,100
+ ,12036.8
+ ,107.2
+ ,12653.2
+ ,107
+ ,14035.4
+ ,119
+ ,14571.4
+ ,110.4
+ ,15400.9
+ ,101.7
+ ,14283.2
+ ,102.4
+ ,14485.3
+ ,98.8
+ ,14196.3
+ ,105.6
+ ,15559.1
+ ,104.4
+ ,13767.4
+ ,106.3
+ ,14634
+ ,107.2
+ ,14381.1
+ ,108.5
+ ,12509.9
+ ,106.9
+ ,12122.3
+ ,114.2
+ ,13122.3
+ ,125.9
+ ,13908.7
+ ,110.6
+ ,13456.5
+ ,110.5
+ ,12441.6
+ ,106.7
+ ,12953
+ ,104.7
+ ,13057.2
+ ,107.4
+ ,14350.1
+ ,109.8
+ ,13830.2
+ ,103.4
+ ,13755.5
+ ,114.8
+ ,13574.4
+ ,114.3
+ ,12802.6
+ ,109.6
+ ,11737.3
+ ,118.3
+ ,13850.2
+ ,127.3
+ ,15081.8
+ ,112.3
+ ,13653.3
+ ,114.9
+ ,14019.1
+ ,108.2
+ ,13962
+ ,105.4
+ ,13768.7
+ ,122.1
+ ,14747.1
+ ,113.5
+ ,13858.1
+ ,110
+ ,13188
+ ,125.3
+ ,13693.1
+ ,114.3
+ ,12970
+ ,115.6
+ ,11392.8
+ ,127.1
+ ,13985.2
+ ,123
+ ,14994.7
+ ,122.2
+ ,13584.7
+ ,126.4
+ ,14257.8
+ ,112.7
+ ,13553.4
+ ,105.8
+ ,14007.3
+ ,120.9
+ ,16535.8
+ ,116.3
+ ,14721.4
+ ,115.7
+ ,13664.6
+ ,127.9
+ ,16405.9
+ ,108.3
+ ,13829.4
+ ,121.1
+ ,13735.6
+ ,128.6
+ ,15870.5
+ ,123.1
+ ,15962.4
+ ,127.7
+ ,15744.1
+ ,126.6
+ ,16083.7
+ ,118.4
+ ,14863.9
+ ,110
+ ,15533.1
+ ,129.6
+ ,17473.1
+ ,115.8
+ ,15925.5
+ ,125.9
+ ,15573.7
+ ,128.4
+ ,17495
+ ,114
+ ,14155.8
+ ,125.6
+ ,14913.9
+ ,128.5
+ ,17250.4
+ ,136.6
+ ,15879.8
+ ,133.1
+ ,17647.8
+ ,124.6
+ ,17749.9)
+ ,dim=c(2
+ ,72)
+ ,dimnames=list(c('Voeding'
+ ,'Invoer')
+ ,1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('Voeding','Invoer'),1:72))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'Linear Trend'
> par2 = 'Include Monthly Dummies'
> par1 = '1'
> #'GNU S' R Code compiled by R2WASP v. 1.0.44 ()
> #Author: Prof. Dr. P. Wessa
> #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/
> #Source of accompanying publication: Office for Research, Development, and Education
> #Technical description: Write here your technical program description (don't use hard returns!)
> library(lattice)
> library(lmtest)
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from package:base :
as.Date.numeric
> n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
> par1 <- as.numeric(par1)
> x <- t(y)
> k <- length(x[1,])
> n <- length(x[,1])
> x1 <- cbind(x[,par1], x[,1:k!=par1])
> mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1])
> colnames(x1) <- mycolnames #colnames(x)[par1]
> x <- x1
> if (par3 == 'First Differences'){
+ x2 <- array(0, dim=c(n-1,k), dimnames=list(1:(n-1), paste('(1-B)',colnames(x),sep='')))
+ for (i in 1:n-1) {
+ for (j in 1:k) {
+ x2[i,j] <- x[i+1,j] - x[i,j]
+ }
+ }
+ x <- x2
+ }
> if (par2 == 'Include Monthly Dummies'){
+ x2 <- array(0, dim=c(n,11), dimnames=list(1:n, paste('M', seq(1:11), sep ='')))
+ for (i in 1:11){
+ x2[seq(i,n,12),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> if (par2 == 'Include Quarterly Dummies'){
+ x2 <- array(0, dim=c(n,3), dimnames=list(1:n, paste('Q', seq(1:3), sep ='')))
+ for (i in 1:3){
+ x2[seq(i,n,4),i] <- 1
+ }
+ x <- cbind(x, x2)
+ }
> k <- length(x[1,])
> if (par3 == 'Linear Trend'){
+ x <- cbind(x, c(1:n))
+ colnames(x)[k+1] <- 't'
+ }
> x
Voeding Invoer M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 99.2 11554.5 1 0 0 0 0 0 0 0 0 0 0 1
2 93.6 13182.1 0 1 0 0 0 0 0 0 0 0 0 2
3 104.2 14800.1 0 0 1 0 0 0 0 0 0 0 0 3
4 95.3 12150.7 0 0 0 1 0 0 0 0 0 0 0 4
5 102.7 14478.2 0 0 0 0 1 0 0 0 0 0 0 5
6 103.1 13253.9 0 0 0 0 0 1 0 0 0 0 0 6
7 100.0 12036.8 0 0 0 0 0 0 1 0 0 0 0 7
8 107.2 12653.2 0 0 0 0 0 0 0 1 0 0 0 8
9 107.0 14035.4 0 0 0 0 0 0 0 0 1 0 0 9
10 119.0 14571.4 0 0 0 0 0 0 0 0 0 1 0 10
11 110.4 15400.9 0 0 0 0 0 0 0 0 0 0 1 11
12 101.7 14283.2 0 0 0 0 0 0 0 0 0 0 0 12
13 102.4 14485.3 1 0 0 0 0 0 0 0 0 0 0 13
14 98.8 14196.3 0 1 0 0 0 0 0 0 0 0 0 14
15 105.6 15559.1 0 0 1 0 0 0 0 0 0 0 0 15
16 104.4 13767.4 0 0 0 1 0 0 0 0 0 0 0 16
17 106.3 14634.0 0 0 0 0 1 0 0 0 0 0 0 17
18 107.2 14381.1 0 0 0 0 0 1 0 0 0 0 0 18
19 108.5 12509.9 0 0 0 0 0 0 1 0 0 0 0 19
20 106.9 12122.3 0 0 0 0 0 0 0 1 0 0 0 20
21 114.2 13122.3 0 0 0 0 0 0 0 0 1 0 0 21
22 125.9 13908.7 0 0 0 0 0 0 0 0 0 1 0 22
23 110.6 13456.5 0 0 0 0 0 0 0 0 0 0 1 23
24 110.5 12441.6 0 0 0 0 0 0 0 0 0 0 0 24
25 106.7 12953.0 1 0 0 0 0 0 0 0 0 0 0 25
26 104.7 13057.2 0 1 0 0 0 0 0 0 0 0 0 26
27 107.4 14350.1 0 0 1 0 0 0 0 0 0 0 0 27
28 109.8 13830.2 0 0 0 1 0 0 0 0 0 0 0 28
29 103.4 13755.5 0 0 0 0 1 0 0 0 0 0 0 29
30 114.8 13574.4 0 0 0 0 0 1 0 0 0 0 0 30
31 114.3 12802.6 0 0 0 0 0 0 1 0 0 0 0 31
32 109.6 11737.3 0 0 0 0 0 0 0 1 0 0 0 32
33 118.3 13850.2 0 0 0 0 0 0 0 0 1 0 0 33
34 127.3 15081.8 0 0 0 0 0 0 0 0 0 1 0 34
35 112.3 13653.3 0 0 0 0 0 0 0 0 0 0 1 35
36 114.9 14019.1 0 0 0 0 0 0 0 0 0 0 0 36
37 108.2 13962.0 1 0 0 0 0 0 0 0 0 0 0 37
38 105.4 13768.7 0 1 0 0 0 0 0 0 0 0 0 38
39 122.1 14747.1 0 0 1 0 0 0 0 0 0 0 0 39
40 113.5 13858.1 0 0 0 1 0 0 0 0 0 0 0 40
41 110.0 13188.0 0 0 0 0 1 0 0 0 0 0 0 41
42 125.3 13693.1 0 0 0 0 0 1 0 0 0 0 0 42
43 114.3 12970.0 0 0 0 0 0 0 1 0 0 0 0 43
44 115.6 11392.8 0 0 0 0 0 0 0 1 0 0 0 44
45 127.1 13985.2 0 0 0 0 0 0 0 0 1 0 0 45
46 123.0 14994.7 0 0 0 0 0 0 0 0 0 1 0 46
47 122.2 13584.7 0 0 0 0 0 0 0 0 0 0 1 47
48 126.4 14257.8 0 0 0 0 0 0 0 0 0 0 0 48
49 112.7 13553.4 1 0 0 0 0 0 0 0 0 0 0 49
50 105.8 14007.3 0 1 0 0 0 0 0 0 0 0 0 50
51 120.9 16535.8 0 0 1 0 0 0 0 0 0 0 0 51
52 116.3 14721.4 0 0 0 1 0 0 0 0 0 0 0 52
53 115.7 13664.6 0 0 0 0 1 0 0 0 0 0 0 53
54 127.9 16405.9 0 0 0 0 0 1 0 0 0 0 0 54
55 108.3 13829.4 0 0 0 0 0 0 1 0 0 0 0 55
56 121.1 13735.6 0 0 0 0 0 0 0 1 0 0 0 56
57 128.6 15870.5 0 0 0 0 0 0 0 0 1 0 0 57
58 123.1 15962.4 0 0 0 0 0 0 0 0 0 1 0 58
59 127.7 15744.1 0 0 0 0 0 0 0 0 0 0 1 59
60 126.6 16083.7 0 0 0 0 0 0 0 0 0 0 0 60
61 118.4 14863.9 1 0 0 0 0 0 0 0 0 0 0 61
62 110.0 15533.1 0 1 0 0 0 0 0 0 0 0 0 62
63 129.6 17473.1 0 0 1 0 0 0 0 0 0 0 0 63
64 115.8 15925.5 0 0 0 1 0 0 0 0 0 0 0 64
65 125.9 15573.7 0 0 0 0 1 0 0 0 0 0 0 65
66 128.4 17495.0 0 0 0 0 0 1 0 0 0 0 0 66
67 114.0 14155.8 0 0 0 0 0 0 1 0 0 0 0 67
68 125.6 14913.9 0 0 0 0 0 0 0 1 0 0 0 68
69 128.5 17250.4 0 0 0 0 0 0 0 0 1 0 0 69
70 136.6 15879.8 0 0 0 0 0 0 0 0 0 1 0 70
71 133.1 17647.8 0 0 0 0 0 0 0 0 0 0 1 71
72 124.6 17749.9 0 0 0 0 0 0 0 0 0 0 0 72
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Invoer M1 M2 M3 M4
9.971e+01 2.698e-04 -5.582e+00 -1.090e+01 2.531e-01 -5.443e+00
M5 M6 M7 M8 M9 M10
-4.334e+00 2.298e+00 -5.441e+00 -1.256e+00 4.181e+00 8.951e+00
M11 t
2.231e+00 3.272e-01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-8.8477 -2.5315 0.2445 2.4171 7.1348
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.971e+01 7.300e+00 13.659 < 2e-16 ***
Invoer 2.698e-04 5.407e-04 0.499 0.619620
M1 -5.582e+00 2.290e+00 -2.438 0.017857 *
M2 -1.090e+01 2.260e+00 -4.824 1.06e-05 ***
M3 2.531e-01 2.329e+00 0.109 0.913831
M4 -5.443e+00 2.255e+00 -2.413 0.018988 *
M5 -4.334e+00 2.248e+00 -1.928 0.058725 .
M6 2.298e+00 2.244e+00 1.024 0.310100
M7 -5.441e+00 2.390e+00 -2.276 0.026553 *
M8 -1.256e+00 2.458e+00 -0.511 0.611430
M9 4.181e+00 2.237e+00 1.869 0.066721 .
M10 8.951e+00 2.244e+00 3.988 0.000189 ***
M11 2.231e+00 2.238e+00 0.997 0.322885
t 3.272e-01 3.158e-02 10.362 8.17e-15 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.873 on 58 degrees of freedom
Multiple R-squared: 0.876, Adjusted R-squared: 0.8482
F-statistic: 31.51 on 13 and 58 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.18525745 0.37051489 0.8147426
[2,] 0.09011896 0.18023793 0.9098810
[3,] 0.08272269 0.16544537 0.9172773
[4,] 0.07965200 0.15930401 0.9203480
[5,] 0.06256449 0.12512899 0.9374355
[6,] 0.04691599 0.09383198 0.9530840
[7,] 0.04022139 0.08044278 0.9597786
[8,] 0.04340896 0.08681792 0.9565910
[9,] 0.02437944 0.04875888 0.9756206
[10,] 0.01599474 0.03198947 0.9840053
[11,] 0.02807091 0.05614182 0.9719291
[12,] 0.02173683 0.04347365 0.9782632
[13,] 0.07209638 0.14419277 0.9279036
[14,] 0.07100245 0.14200489 0.9289976
[15,] 0.10441312 0.20882625 0.8955869
[16,] 0.09745740 0.19491480 0.9025426
[17,] 0.06882605 0.13765210 0.9311740
[18,] 0.09615106 0.19230213 0.9038489
[19,] 0.14912561 0.29825121 0.8508744
[20,] 0.13123389 0.26246778 0.8687661
[21,] 0.11593055 0.23186111 0.8840694
[22,] 0.09249551 0.18499102 0.9075045
[23,] 0.18394530 0.36789060 0.8160547
[24,] 0.14846752 0.29693504 0.8515325
[25,] 0.14762361 0.29524721 0.8523764
[26,] 0.21348251 0.42696503 0.7865175
[27,] 0.42081205 0.84162409 0.5791880
[28,] 0.39387779 0.78775558 0.6061222
[29,] 0.38589122 0.77178244 0.6141088
[30,] 0.50088967 0.99822066 0.4991103
[31,] 0.57235297 0.85529407 0.4276470
[32,] 0.63610501 0.72778999 0.3638950
[33,] 0.55025783 0.89948433 0.4497422
[34,] 0.48747739 0.97495478 0.5125226
[35,] 0.41828896 0.83657792 0.5817110
[36,] 0.38554314 0.77108628 0.6144569
[37,] 0.66526855 0.66946289 0.3347314
[38,] 0.60790032 0.78419936 0.3920997
[39,] 0.60415353 0.79169295 0.3958465
> postscript(file="/var/www/html/freestat/rcomp/tmp/1vipx1229761480.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/freestat/rcomp/tmp/29y9d1229761480.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/freestat/rcomp/tmp/3fi521229761480.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/freestat/rcomp/tmp/482y51229761480.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/freestat/rcomp/tmp/5j3dz1229761480.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 = 72
Frequency = 1
1 2 3 4 5 6
1.62385353 0.57471679 -0.74138324 -3.55744624 1.77800267 -4.45049558
7 8 9 10 11 12
0.18909717 2.71077122 -3.62570055 3.13242252 0.70094454 -5.79345913
13 14 15 16 17 18
0.10684574 1.57485669 -3.47238386 1.18012375 1.40976083 -4.58084598
19 20 21 22 23 24
4.63523968 -1.37218140 -0.10552585 6.28503290 -2.50060964 -0.42275139
25 26 27 28 29 30
0.89409644 3.85601197 -5.27236777 2.63697569 -5.17940043 -0.68938071
31 32 33 34 35 36
6.43005872 -2.49450158 -0.12813489 3.44229752 -4.77991433 -0.37460423
37 38 39 40 41 42
-1.80436057 0.43782807 5.39430847 2.40324454 -2.35247744 5.85238798
43 44 45 46 47 48
2.45868691 -0.32774969 4.70923564 -4.76040369 1.21239269 7.13478539
49 50 51 52 53 54
-1.12031286 -3.15275533 -0.21453154 1.04410111 -0.70727932 3.79420217
55 56 57 58 59 60
-7.69940420 0.61389996 1.77433048 -8.84771691 2.20352834 2.91590787
61 62 63 64 65 66
0.29987772 -3.29065819 4.30635794 -3.70699886 5.05139368 0.07413213
67 68 69 70 71 72
-6.01367828 0.86976148 -2.62420483 0.74836767 3.16365840 -3.45987850
> postscript(file="/var/www/html/freestat/rcomp/tmp/6f7nx1229761480.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 = 72
Frequency = 1
lag(myerror, k = 1) myerror
0 1.62385353 NA
1 0.57471679 1.62385353
2 -0.74138324 0.57471679
3 -3.55744624 -0.74138324
4 1.77800267 -3.55744624
5 -4.45049558 1.77800267
6 0.18909717 -4.45049558
7 2.71077122 0.18909717
8 -3.62570055 2.71077122
9 3.13242252 -3.62570055
10 0.70094454 3.13242252
11 -5.79345913 0.70094454
12 0.10684574 -5.79345913
13 1.57485669 0.10684574
14 -3.47238386 1.57485669
15 1.18012375 -3.47238386
16 1.40976083 1.18012375
17 -4.58084598 1.40976083
18 4.63523968 -4.58084598
19 -1.37218140 4.63523968
20 -0.10552585 -1.37218140
21 6.28503290 -0.10552585
22 -2.50060964 6.28503290
23 -0.42275139 -2.50060964
24 0.89409644 -0.42275139
25 3.85601197 0.89409644
26 -5.27236777 3.85601197
27 2.63697569 -5.27236777
28 -5.17940043 2.63697569
29 -0.68938071 -5.17940043
30 6.43005872 -0.68938071
31 -2.49450158 6.43005872
32 -0.12813489 -2.49450158
33 3.44229752 -0.12813489
34 -4.77991433 3.44229752
35 -0.37460423 -4.77991433
36 -1.80436057 -0.37460423
37 0.43782807 -1.80436057
38 5.39430847 0.43782807
39 2.40324454 5.39430847
40 -2.35247744 2.40324454
41 5.85238798 -2.35247744
42 2.45868691 5.85238798
43 -0.32774969 2.45868691
44 4.70923564 -0.32774969
45 -4.76040369 4.70923564
46 1.21239269 -4.76040369
47 7.13478539 1.21239269
48 -1.12031286 7.13478539
49 -3.15275533 -1.12031286
50 -0.21453154 -3.15275533
51 1.04410111 -0.21453154
52 -0.70727932 1.04410111
53 3.79420217 -0.70727932
54 -7.69940420 3.79420217
55 0.61389996 -7.69940420
56 1.77433048 0.61389996
57 -8.84771691 1.77433048
58 2.20352834 -8.84771691
59 2.91590787 2.20352834
60 0.29987772 2.91590787
61 -3.29065819 0.29987772
62 4.30635794 -3.29065819
63 -3.70699886 4.30635794
64 5.05139368 -3.70699886
65 0.07413213 5.05139368
66 -6.01367828 0.07413213
67 0.86976148 -6.01367828
68 -2.62420483 0.86976148
69 0.74836767 -2.62420483
70 3.16365840 0.74836767
71 -3.45987850 3.16365840
72 NA -3.45987850
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.57471679 1.62385353
[2,] -0.74138324 0.57471679
[3,] -3.55744624 -0.74138324
[4,] 1.77800267 -3.55744624
[5,] -4.45049558 1.77800267
[6,] 0.18909717 -4.45049558
[7,] 2.71077122 0.18909717
[8,] -3.62570055 2.71077122
[9,] 3.13242252 -3.62570055
[10,] 0.70094454 3.13242252
[11,] -5.79345913 0.70094454
[12,] 0.10684574 -5.79345913
[13,] 1.57485669 0.10684574
[14,] -3.47238386 1.57485669
[15,] 1.18012375 -3.47238386
[16,] 1.40976083 1.18012375
[17,] -4.58084598 1.40976083
[18,] 4.63523968 -4.58084598
[19,] -1.37218140 4.63523968
[20,] -0.10552585 -1.37218140
[21,] 6.28503290 -0.10552585
[22,] -2.50060964 6.28503290
[23,] -0.42275139 -2.50060964
[24,] 0.89409644 -0.42275139
[25,] 3.85601197 0.89409644
[26,] -5.27236777 3.85601197
[27,] 2.63697569 -5.27236777
[28,] -5.17940043 2.63697569
[29,] -0.68938071 -5.17940043
[30,] 6.43005872 -0.68938071
[31,] -2.49450158 6.43005872
[32,] -0.12813489 -2.49450158
[33,] 3.44229752 -0.12813489
[34,] -4.77991433 3.44229752
[35,] -0.37460423 -4.77991433
[36,] -1.80436057 -0.37460423
[37,] 0.43782807 -1.80436057
[38,] 5.39430847 0.43782807
[39,] 2.40324454 5.39430847
[40,] -2.35247744 2.40324454
[41,] 5.85238798 -2.35247744
[42,] 2.45868691 5.85238798
[43,] -0.32774969 2.45868691
[44,] 4.70923564 -0.32774969
[45,] -4.76040369 4.70923564
[46,] 1.21239269 -4.76040369
[47,] 7.13478539 1.21239269
[48,] -1.12031286 7.13478539
[49,] -3.15275533 -1.12031286
[50,] -0.21453154 -3.15275533
[51,] 1.04410111 -0.21453154
[52,] -0.70727932 1.04410111
[53,] 3.79420217 -0.70727932
[54,] -7.69940420 3.79420217
[55,] 0.61389996 -7.69940420
[56,] 1.77433048 0.61389996
[57,] -8.84771691 1.77433048
[58,] 2.20352834 -8.84771691
[59,] 2.91590787 2.20352834
[60,] 0.29987772 2.91590787
[61,] -3.29065819 0.29987772
[62,] 4.30635794 -3.29065819
[63,] -3.70699886 4.30635794
[64,] 5.05139368 -3.70699886
[65,] 0.07413213 5.05139368
[66,] -6.01367828 0.07413213
[67,] 0.86976148 -6.01367828
[68,] -2.62420483 0.86976148
[69,] 0.74836767 -2.62420483
[70,] 3.16365840 0.74836767
[71,] -3.45987850 3.16365840
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.57471679 1.62385353
2 -0.74138324 0.57471679
3 -3.55744624 -0.74138324
4 1.77800267 -3.55744624
5 -4.45049558 1.77800267
6 0.18909717 -4.45049558
7 2.71077122 0.18909717
8 -3.62570055 2.71077122
9 3.13242252 -3.62570055
10 0.70094454 3.13242252
11 -5.79345913 0.70094454
12 0.10684574 -5.79345913
13 1.57485669 0.10684574
14 -3.47238386 1.57485669
15 1.18012375 -3.47238386
16 1.40976083 1.18012375
17 -4.58084598 1.40976083
18 4.63523968 -4.58084598
19 -1.37218140 4.63523968
20 -0.10552585 -1.37218140
21 6.28503290 -0.10552585
22 -2.50060964 6.28503290
23 -0.42275139 -2.50060964
24 0.89409644 -0.42275139
25 3.85601197 0.89409644
26 -5.27236777 3.85601197
27 2.63697569 -5.27236777
28 -5.17940043 2.63697569
29 -0.68938071 -5.17940043
30 6.43005872 -0.68938071
31 -2.49450158 6.43005872
32 -0.12813489 -2.49450158
33 3.44229752 -0.12813489
34 -4.77991433 3.44229752
35 -0.37460423 -4.77991433
36 -1.80436057 -0.37460423
37 0.43782807 -1.80436057
38 5.39430847 0.43782807
39 2.40324454 5.39430847
40 -2.35247744 2.40324454
41 5.85238798 -2.35247744
42 2.45868691 5.85238798
43 -0.32774969 2.45868691
44 4.70923564 -0.32774969
45 -4.76040369 4.70923564
46 1.21239269 -4.76040369
47 7.13478539 1.21239269
48 -1.12031286 7.13478539
49 -3.15275533 -1.12031286
50 -0.21453154 -3.15275533
51 1.04410111 -0.21453154
52 -0.70727932 1.04410111
53 3.79420217 -0.70727932
54 -7.69940420 3.79420217
55 0.61389996 -7.69940420
56 1.77433048 0.61389996
57 -8.84771691 1.77433048
58 2.20352834 -8.84771691
59 2.91590787 2.20352834
60 0.29987772 2.91590787
61 -3.29065819 0.29987772
62 4.30635794 -3.29065819
63 -3.70699886 4.30635794
64 5.05139368 -3.70699886
65 0.07413213 5.05139368
66 -6.01367828 0.07413213
67 0.86976148 -6.01367828
68 -2.62420483 0.86976148
69 0.74836767 -2.62420483
70 3.16365840 0.74836767
71 -3.45987850 3.16365840
> 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/freestat/rcomp/tmp/7hbc11229761480.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/freestat/rcomp/tmp/8lp5p1229761480.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/freestat/rcomp/tmp/9kpri1229761480.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/freestat/rcomp/tmp/10rg4p1229761480.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11j1ka1229761480.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/freestat/rcomp/tmp/12dsl61229761480.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/freestat/rcomp/tmp/13c4yt1229761480.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/freestat/rcomp/tmp/145rx21229761480.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/freestat/rcomp/tmp/156po71229761480.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/freestat/rcomp/tmp/16ifkn1229761480.tab")
+ }
>
> system("convert tmp/1vipx1229761480.ps tmp/1vipx1229761480.png")
> system("convert tmp/29y9d1229761480.ps tmp/29y9d1229761480.png")
> system("convert tmp/3fi521229761480.ps tmp/3fi521229761480.png")
> system("convert tmp/482y51229761480.ps tmp/482y51229761480.png")
> system("convert tmp/5j3dz1229761480.ps tmp/5j3dz1229761480.png")
> system("convert tmp/6f7nx1229761480.ps tmp/6f7nx1229761480.png")
> system("convert tmp/7hbc11229761480.ps tmp/7hbc11229761480.png")
> system("convert tmp/8lp5p1229761480.ps tmp/8lp5p1229761480.png")
> system("convert tmp/9kpri1229761480.ps tmp/9kpri1229761480.png")
> system("convert tmp/10rg4p1229761480.ps tmp/10rg4p1229761480.png")
>
>
> proc.time()
user system elapsed
3.800 2.483 4.468