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(101.3,163095,102,159044,109.2,155511,88.6,153745,94.3,150569,98.3,150605,86.4,179612,80.6,194690,104.1,189917,108.2,184128,93.4,175335,71.9,179566,94.1,181140,94.9,177876,96.4,175041,91.1,169292,84.4,166070,86.4,166972,88,206348,75.1,215706,109.7,202108,103,195411,82.1,193111,68,195198,96.4,198770,94.3,194163,90,190420,88,189733,76.1,186029,82.5,191531,81.4,232571,66.5,243477,97.2,227247,94.1,217859,80.7,208679,70.5,213188,87.8,216234,89.5,213586,99.6,209465,84.2,204045,75.1,200237,92,203666,80.8,241476,73.1,260307,99.8,243324,90,244460,83.1,233575,72.4,237217,78.8,235243,87.3,230354,91,227184,80.1,221678,73.6,217142,86.4,219452,74.5,256446,71.2,265845,92.4,248624,81.5,241114,85.3,229245,69.9,231805,84.2,219277,90.7,219313,100.3,212610,79.4,214771,84.8,211142,92.9,211457,81.6,240048,76,240636,98.7,230580,89.1,208795,88.7,197922,67.1,194596),dim=c(2,72),dimnames=list(c('textiel','invoer'),1:72))
> y <- array(NA,dim=c(2,72),dimnames=list(c('textiel','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 = 'No 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
textiel invoer M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 101.3 163095 1 0 0 0 0 0 0 0 0 0 0
2 102.0 159044 0 1 0 0 0 0 0 0 0 0 0
3 109.2 155511 0 0 1 0 0 0 0 0 0 0 0
4 88.6 153745 0 0 0 1 0 0 0 0 0 0 0
5 94.3 150569 0 0 0 0 1 0 0 0 0 0 0
6 98.3 150605 0 0 0 0 0 1 0 0 0 0 0
7 86.4 179612 0 0 0 0 0 0 1 0 0 0 0
8 80.6 194690 0 0 0 0 0 0 0 1 0 0 0
9 104.1 189917 0 0 0 0 0 0 0 0 1 0 0
10 108.2 184128 0 0 0 0 0 0 0 0 0 1 0
11 93.4 175335 0 0 0 0 0 0 0 0 0 0 1
12 71.9 179566 0 0 0 0 0 0 0 0 0 0 0
13 94.1 181140 1 0 0 0 0 0 0 0 0 0 0
14 94.9 177876 0 1 0 0 0 0 0 0 0 0 0
15 96.4 175041 0 0 1 0 0 0 0 0 0 0 0
16 91.1 169292 0 0 0 1 0 0 0 0 0 0 0
17 84.4 166070 0 0 0 0 1 0 0 0 0 0 0
18 86.4 166972 0 0 0 0 0 1 0 0 0 0 0
19 88.0 206348 0 0 0 0 0 0 1 0 0 0 0
20 75.1 215706 0 0 0 0 0 0 0 1 0 0 0
21 109.7 202108 0 0 0 0 0 0 0 0 1 0 0
22 103.0 195411 0 0 0 0 0 0 0 0 0 1 0
23 82.1 193111 0 0 0 0 0 0 0 0 0 0 1
24 68.0 195198 0 0 0 0 0 0 0 0 0 0 0
25 96.4 198770 1 0 0 0 0 0 0 0 0 0 0
26 94.3 194163 0 1 0 0 0 0 0 0 0 0 0
27 90.0 190420 0 0 1 0 0 0 0 0 0 0 0
28 88.0 189733 0 0 0 1 0 0 0 0 0 0 0
29 76.1 186029 0 0 0 0 1 0 0 0 0 0 0
30 82.5 191531 0 0 0 0 0 1 0 0 0 0 0
31 81.4 232571 0 0 0 0 0 0 1 0 0 0 0
32 66.5 243477 0 0 0 0 0 0 0 1 0 0 0
33 97.2 227247 0 0 0 0 0 0 0 0 1 0 0
34 94.1 217859 0 0 0 0 0 0 0 0 0 1 0
35 80.7 208679 0 0 0 0 0 0 0 0 0 0 1
36 70.5 213188 0 0 0 0 0 0 0 0 0 0 0
37 87.8 216234 1 0 0 0 0 0 0 0 0 0 0
38 89.5 213586 0 1 0 0 0 0 0 0 0 0 0
39 99.6 209465 0 0 1 0 0 0 0 0 0 0 0
40 84.2 204045 0 0 0 1 0 0 0 0 0 0 0
41 75.1 200237 0 0 0 0 1 0 0 0 0 0 0
42 92.0 203666 0 0 0 0 0 1 0 0 0 0 0
43 80.8 241476 0 0 0 0 0 0 1 0 0 0 0
44 73.1 260307 0 0 0 0 0 0 0 1 0 0 0
45 99.8 243324 0 0 0 0 0 0 0 0 1 0 0
46 90.0 244460 0 0 0 0 0 0 0 0 0 1 0
47 83.1 233575 0 0 0 0 0 0 0 0 0 0 1
48 72.4 237217 0 0 0 0 0 0 0 0 0 0 0
49 78.8 235243 1 0 0 0 0 0 0 0 0 0 0
50 87.3 230354 0 1 0 0 0 0 0 0 0 0 0
51 91.0 227184 0 0 1 0 0 0 0 0 0 0 0
52 80.1 221678 0 0 0 1 0 0 0 0 0 0 0
53 73.6 217142 0 0 0 0 1 0 0 0 0 0 0
54 86.4 219452 0 0 0 0 0 1 0 0 0 0 0
55 74.5 256446 0 0 0 0 0 0 1 0 0 0 0
56 71.2 265845 0 0 0 0 0 0 0 1 0 0 0
57 92.4 248624 0 0 0 0 0 0 0 0 1 0 0
58 81.5 241114 0 0 0 0 0 0 0 0 0 1 0
59 85.3 229245 0 0 0 0 0 0 0 0 0 0 1
60 69.9 231805 0 0 0 0 0 0 0 0 0 0 0
61 84.2 219277 1 0 0 0 0 0 0 0 0 0 0
62 90.7 219313 0 1 0 0 0 0 0 0 0 0 0
63 100.3 212610 0 0 1 0 0 0 0 0 0 0 0
64 79.4 214771 0 0 0 1 0 0 0 0 0 0 0
65 84.8 211142 0 0 0 0 1 0 0 0 0 0 0
66 92.9 211457 0 0 0 0 0 1 0 0 0 0 0
67 81.6 240048 0 0 0 0 0 0 1 0 0 0 0
68 76.0 240636 0 0 0 0 0 0 0 1 0 0 0
69 98.7 230580 0 0 0 0 0 0 0 0 1 0 0
70 89.1 208795 0 0 0 0 0 0 0 0 0 1 0
71 88.7 197922 0 0 0 0 0 0 0 0 0 0 1
72 67.1 194596 0 0 0 0 0 0 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) invoer M1 M2 M3 M4
1.053e+02 -1.694e-04 1.940e+01 2.153e+01 2.549e+01 1.249e+01
M5 M6 M7 M8 M9 M10
8.019e+00 1.674e+01 1.511e+01 8.556e+00 3.290e+01 2.548e+01
M11
1.520e+01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-8.5322 -3.0242 0.2862 2.6575 8.6050
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.053e+02 5.089e+00 20.691 < 2e-16 ***
invoer -1.694e-04 2.273e-05 -7.450 4.67e-10 ***
M1 1.940e+01 2.616e+00 7.415 5.36e-10 ***
M2 2.153e+01 2.621e+00 8.215 2.37e-11 ***
M3 2.549e+01 2.630e+00 9.689 8.28e-14 ***
M4 1.249e+01 2.639e+00 4.734 1.42e-05 ***
M5 8.019e+00 2.652e+00 3.024 0.00369 **
M6 1.674e+01 2.644e+00 6.330 3.64e-08 ***
M7 1.511e+01 2.642e+00 5.719 3.77e-07 ***
M8 8.556e+00 2.690e+00 3.181 0.00234 **
M9 3.290e+01 2.635e+00 12.486 < 2e-16 ***
M10 2.548e+01 2.617e+00 9.739 6.86e-14 ***
M11 1.520e+01 2.613e+00 5.816 2.61e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 4.525 on 59 degrees of freedom
Multiple R-squared: 0.8475, Adjusted R-squared: 0.8165
F-statistic: 27.33 on 12 and 59 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.4924627 0.9849254 0.5075373
[2,] 0.3829500 0.7659000 0.6170500
[3,] 0.3429254 0.6858507 0.6570746
[4,] 0.6056307 0.7887385 0.3943693
[5,] 0.4848189 0.9696378 0.5151811
[6,] 0.5968878 0.8062245 0.4031122
[7,] 0.6016401 0.7967198 0.3983599
[8,] 0.5901168 0.8197663 0.4098832
[9,] 0.5062004 0.9875991 0.4937996
[10,] 0.6191246 0.7617508 0.3808754
[11,] 0.5509329 0.8981341 0.4490671
[12,] 0.6458388 0.7083225 0.3541612
[13,] 0.6549973 0.6900055 0.3450027
[14,] 0.6605095 0.6789811 0.3394905
[15,] 0.7163958 0.5672084 0.2836042
[16,] 0.6806656 0.6386688 0.3193344
[17,] 0.7208896 0.5582209 0.2791104
[18,] 0.6528247 0.6943506 0.3471753
[19,] 0.6644915 0.6710169 0.3355085
[20,] 0.6705652 0.6588696 0.3294348
[21,] 0.6850208 0.6299584 0.3149792
[22,] 0.6577313 0.6845375 0.3422687
[23,] 0.5843777 0.8312446 0.4156223
[24,] 0.6777184 0.6445633 0.3222816
[25,] 0.6257576 0.7484848 0.3742424
[26,] 0.6223283 0.7553434 0.3776717
[27,] 0.6837767 0.6324466 0.3162233
[28,] 0.6198723 0.7602553 0.3801277
[29,] 0.5967050 0.8065899 0.4032950
[30,] 0.5691507 0.8616985 0.4308493
[31,] 0.6214495 0.7571011 0.3785505
[32,] 0.5602004 0.8795992 0.4397996
[33,] 0.7117828 0.5764345 0.2882172
[34,] 0.6816962 0.6366076 0.3183038
[35,] 0.5847825 0.8304350 0.4152175
[36,] 0.5953414 0.8093171 0.4046586
[37,] 0.4855574 0.9711147 0.5144426
[38,] 0.6946717 0.6106567 0.3053283
[39,] 0.6878116 0.6243769 0.3121884
[40,] 0.6630713 0.6738574 0.3369287
[41,] 0.5208047 0.9583907 0.4791953
> postscript(file="/var/www/html/freestat/rcomp/tmp/1syb11229715090.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/2o81d1229715090.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/3tqiq1229715090.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/4m4mn1229715090.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/5sq7g1229715090.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 7
4.2280893 2.1069257 4.7556470 -3.1478549 6.4873611 1.7741287 -3.5870512
8 9 10 11 12 13 14
-0.2778001 -1.9268441 8.6049941 2.6038955 -2.9830002 0.0841794 -1.8036984
15 16 17 18 19 20 21
-4.7367643 1.9851754 -0.7873991 -7.3539663 2.5409412 -2.2185433 5.7378162
22 23 24 25 26 27 28
5.3158760 -5.6855721 -4.2355743 5.3699853 0.3546579 -8.5321863 2.3470506
29 30 31 32 33 34 35
-5.7071552 -7.0946692 0.3820523 -6.1152639 -2.5046583 0.2176555 -4.4489852
36 37 38 39 40 41 42
1.3112010 -0.2723224 -1.1558748 4.2932631 0.9709221 -4.3008971 4.4605069
43 44 45 46 47 48 49
1.2901976 3.3350545 2.8181325 0.6227844 2.1673860 7.2807376 -6.0529699
50 51 52 53 54 55 56
-0.5160567 -1.3058579 -0.1427639 -2.9378767 1.5340141 -2.4744924 2.3729668
57 58 59 60 61 62 63
-3.6842628 -8.4438921 3.6340599 3.8641646 -3.3569618 1.0140464 5.5258984
64 65 66 67 68 69 70
-2.0125292 7.2459670 6.6799859 1.8483524 2.9035861 -0.4401835 -6.3174180
71 72
1.7292159 -5.2375287
> postscript(file="/var/www/html/freestat/rcomp/tmp/6lh5z1229715090.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 4.2280893 NA
1 2.1069257 4.2280893
2 4.7556470 2.1069257
3 -3.1478549 4.7556470
4 6.4873611 -3.1478549
5 1.7741287 6.4873611
6 -3.5870512 1.7741287
7 -0.2778001 -3.5870512
8 -1.9268441 -0.2778001
9 8.6049941 -1.9268441
10 2.6038955 8.6049941
11 -2.9830002 2.6038955
12 0.0841794 -2.9830002
13 -1.8036984 0.0841794
14 -4.7367643 -1.8036984
15 1.9851754 -4.7367643
16 -0.7873991 1.9851754
17 -7.3539663 -0.7873991
18 2.5409412 -7.3539663
19 -2.2185433 2.5409412
20 5.7378162 -2.2185433
21 5.3158760 5.7378162
22 -5.6855721 5.3158760
23 -4.2355743 -5.6855721
24 5.3699853 -4.2355743
25 0.3546579 5.3699853
26 -8.5321863 0.3546579
27 2.3470506 -8.5321863
28 -5.7071552 2.3470506
29 -7.0946692 -5.7071552
30 0.3820523 -7.0946692
31 -6.1152639 0.3820523
32 -2.5046583 -6.1152639
33 0.2176555 -2.5046583
34 -4.4489852 0.2176555
35 1.3112010 -4.4489852
36 -0.2723224 1.3112010
37 -1.1558748 -0.2723224
38 4.2932631 -1.1558748
39 0.9709221 4.2932631
40 -4.3008971 0.9709221
41 4.4605069 -4.3008971
42 1.2901976 4.4605069
43 3.3350545 1.2901976
44 2.8181325 3.3350545
45 0.6227844 2.8181325
46 2.1673860 0.6227844
47 7.2807376 2.1673860
48 -6.0529699 7.2807376
49 -0.5160567 -6.0529699
50 -1.3058579 -0.5160567
51 -0.1427639 -1.3058579
52 -2.9378767 -0.1427639
53 1.5340141 -2.9378767
54 -2.4744924 1.5340141
55 2.3729668 -2.4744924
56 -3.6842628 2.3729668
57 -8.4438921 -3.6842628
58 3.6340599 -8.4438921
59 3.8641646 3.6340599
60 -3.3569618 3.8641646
61 1.0140464 -3.3569618
62 5.5258984 1.0140464
63 -2.0125292 5.5258984
64 7.2459670 -2.0125292
65 6.6799859 7.2459670
66 1.8483524 6.6799859
67 2.9035861 1.8483524
68 -0.4401835 2.9035861
69 -6.3174180 -0.4401835
70 1.7292159 -6.3174180
71 -5.2375287 1.7292159
72 NA -5.2375287
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 2.1069257 4.2280893
[2,] 4.7556470 2.1069257
[3,] -3.1478549 4.7556470
[4,] 6.4873611 -3.1478549
[5,] 1.7741287 6.4873611
[6,] -3.5870512 1.7741287
[7,] -0.2778001 -3.5870512
[8,] -1.9268441 -0.2778001
[9,] 8.6049941 -1.9268441
[10,] 2.6038955 8.6049941
[11,] -2.9830002 2.6038955
[12,] 0.0841794 -2.9830002
[13,] -1.8036984 0.0841794
[14,] -4.7367643 -1.8036984
[15,] 1.9851754 -4.7367643
[16,] -0.7873991 1.9851754
[17,] -7.3539663 -0.7873991
[18,] 2.5409412 -7.3539663
[19,] -2.2185433 2.5409412
[20,] 5.7378162 -2.2185433
[21,] 5.3158760 5.7378162
[22,] -5.6855721 5.3158760
[23,] -4.2355743 -5.6855721
[24,] 5.3699853 -4.2355743
[25,] 0.3546579 5.3699853
[26,] -8.5321863 0.3546579
[27,] 2.3470506 -8.5321863
[28,] -5.7071552 2.3470506
[29,] -7.0946692 -5.7071552
[30,] 0.3820523 -7.0946692
[31,] -6.1152639 0.3820523
[32,] -2.5046583 -6.1152639
[33,] 0.2176555 -2.5046583
[34,] -4.4489852 0.2176555
[35,] 1.3112010 -4.4489852
[36,] -0.2723224 1.3112010
[37,] -1.1558748 -0.2723224
[38,] 4.2932631 -1.1558748
[39,] 0.9709221 4.2932631
[40,] -4.3008971 0.9709221
[41,] 4.4605069 -4.3008971
[42,] 1.2901976 4.4605069
[43,] 3.3350545 1.2901976
[44,] 2.8181325 3.3350545
[45,] 0.6227844 2.8181325
[46,] 2.1673860 0.6227844
[47,] 7.2807376 2.1673860
[48,] -6.0529699 7.2807376
[49,] -0.5160567 -6.0529699
[50,] -1.3058579 -0.5160567
[51,] -0.1427639 -1.3058579
[52,] -2.9378767 -0.1427639
[53,] 1.5340141 -2.9378767
[54,] -2.4744924 1.5340141
[55,] 2.3729668 -2.4744924
[56,] -3.6842628 2.3729668
[57,] -8.4438921 -3.6842628
[58,] 3.6340599 -8.4438921
[59,] 3.8641646 3.6340599
[60,] -3.3569618 3.8641646
[61,] 1.0140464 -3.3569618
[62,] 5.5258984 1.0140464
[63,] -2.0125292 5.5258984
[64,] 7.2459670 -2.0125292
[65,] 6.6799859 7.2459670
[66,] 1.8483524 6.6799859
[67,] 2.9035861 1.8483524
[68,] -0.4401835 2.9035861
[69,] -6.3174180 -0.4401835
[70,] 1.7292159 -6.3174180
[71,] -5.2375287 1.7292159
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 2.1069257 4.2280893
2 4.7556470 2.1069257
3 -3.1478549 4.7556470
4 6.4873611 -3.1478549
5 1.7741287 6.4873611
6 -3.5870512 1.7741287
7 -0.2778001 -3.5870512
8 -1.9268441 -0.2778001
9 8.6049941 -1.9268441
10 2.6038955 8.6049941
11 -2.9830002 2.6038955
12 0.0841794 -2.9830002
13 -1.8036984 0.0841794
14 -4.7367643 -1.8036984
15 1.9851754 -4.7367643
16 -0.7873991 1.9851754
17 -7.3539663 -0.7873991
18 2.5409412 -7.3539663
19 -2.2185433 2.5409412
20 5.7378162 -2.2185433
21 5.3158760 5.7378162
22 -5.6855721 5.3158760
23 -4.2355743 -5.6855721
24 5.3699853 -4.2355743
25 0.3546579 5.3699853
26 -8.5321863 0.3546579
27 2.3470506 -8.5321863
28 -5.7071552 2.3470506
29 -7.0946692 -5.7071552
30 0.3820523 -7.0946692
31 -6.1152639 0.3820523
32 -2.5046583 -6.1152639
33 0.2176555 -2.5046583
34 -4.4489852 0.2176555
35 1.3112010 -4.4489852
36 -0.2723224 1.3112010
37 -1.1558748 -0.2723224
38 4.2932631 -1.1558748
39 0.9709221 4.2932631
40 -4.3008971 0.9709221
41 4.4605069 -4.3008971
42 1.2901976 4.4605069
43 3.3350545 1.2901976
44 2.8181325 3.3350545
45 0.6227844 2.8181325
46 2.1673860 0.6227844
47 7.2807376 2.1673860
48 -6.0529699 7.2807376
49 -0.5160567 -6.0529699
50 -1.3058579 -0.5160567
51 -0.1427639 -1.3058579
52 -2.9378767 -0.1427639
53 1.5340141 -2.9378767
54 -2.4744924 1.5340141
55 2.3729668 -2.4744924
56 -3.6842628 2.3729668
57 -8.4438921 -3.6842628
58 3.6340599 -8.4438921
59 3.8641646 3.6340599
60 -3.3569618 3.8641646
61 1.0140464 -3.3569618
62 5.5258984 1.0140464
63 -2.0125292 5.5258984
64 7.2459670 -2.0125292
65 6.6799859 7.2459670
66 1.8483524 6.6799859
67 2.9035861 1.8483524
68 -0.4401835 2.9035861
69 -6.3174180 -0.4401835
70 1.7292159 -6.3174180
71 -5.2375287 1.7292159
> 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/7t9i81229715090.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/8ltpf1229715090.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/9603g1229715090.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/10iih91229715090.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/11z41t1229715090.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/12j5zo1229715090.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/137frf1229715090.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/145owc1229715090.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/15m2zc1229715090.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/16zk3h1229715090.tab")
+ }
>
> system("convert tmp/1syb11229715090.ps tmp/1syb11229715090.png")
> system("convert tmp/2o81d1229715090.ps tmp/2o81d1229715090.png")
> system("convert tmp/3tqiq1229715090.ps tmp/3tqiq1229715090.png")
> system("convert tmp/4m4mn1229715090.ps tmp/4m4mn1229715090.png")
> system("convert tmp/5sq7g1229715090.ps tmp/5sq7g1229715090.png")
> system("convert tmp/6lh5z1229715090.ps tmp/6lh5z1229715090.png")
> system("convert tmp/7t9i81229715090.ps tmp/7t9i81229715090.png")
> system("convert tmp/8ltpf1229715090.ps tmp/8ltpf1229715090.png")
> system("convert tmp/9603g1229715090.ps tmp/9603g1229715090.png")
> system("convert tmp/10iih91229715090.ps tmp/10iih91229715090.png")
>
>
> proc.time()
user system elapsed
3.812 2.495 4.183