R version 2.12.0 (2010-10-15)
Copyright (C) 2010 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(-999.00
+ ,-999.00
+ ,38.60
+ ,6654.00
+ ,5712.00
+ ,645.00
+ ,3.00
+ ,5.00
+ ,3.00
+ ,6.30
+ ,2.00
+ ,4.50
+ ,1.00
+ ,6600.00
+ ,42.00
+ ,3.00
+ ,1.00
+ ,3.00
+ ,-999.00
+ ,-999.00
+ ,14.00
+ ,3.39
+ ,44.50
+ ,60.00
+ ,1.00
+ ,1.00
+ ,1.00
+ ,-999.00
+ ,-999.00
+ ,-999.00
+ ,0.92
+ ,5.70
+ ,25.00
+ ,5.00
+ ,2.00
+ ,3.00
+ ,2.10
+ ,1.80
+ ,69.00
+ ,2547.00
+ ,4603.00
+ ,624.00
+ ,3.00
+ ,5.00
+ ,4.00
+ ,9.10
+ ,0.70
+ ,27.00
+ ,10.55
+ ,179.50
+ ,180.00
+ ,4.00
+ ,4.00
+ ,4.00
+ ,15.80
+ ,3.90
+ ,19.00
+ ,0.02
+ ,0.30
+ ,35.00
+ ,1.00
+ ,1.00
+ ,1.00
+ ,5.20
+ ,1.00
+ ,30.40
+ ,160.00
+ ,169.00
+ ,392.00
+ ,4.00
+ ,5.00
+ ,4.00
+ ,10.90
+ ,3.60
+ ,28.00
+ ,3.30
+ ,25.60
+ ,63.00
+ ,1.00
+ ,2.00
+ ,1.00
+ ,8.30
+ ,1.40
+ ,50.00
+ ,52.16
+ ,440.00
+ ,230.00
+ ,1.00
+ ,1.00
+ ,1.00
+ ,11.00
+ ,1.50
+ ,7.00
+ ,0.43
+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 ,5.00
+ ,5.00
+ ,3.20
+ ,0.60
+ ,20.00
+ ,55.50
+ ,175.00
+ ,151.00
+ ,5.00
+ ,5.00
+ ,5.00
+ ,-999.00
+ ,-999.00
+ ,12.70
+ ,1.40
+ ,12.50
+ ,90.00
+ ,2.00
+ ,2.00
+ ,2.00
+ ,8.10
+ ,2.20
+ ,3.50
+ ,0.06
+ ,1.00
+ ,-999.00
+ ,3.00
+ ,1.00
+ ,2.00
+ ,11.00
+ ,2.30
+ ,4.50
+ ,0.90
+ ,2.60
+ ,60.00
+ ,2.00
+ ,1.00
+ ,2.00
+ ,4.90
+ ,0.50
+ ,7.50
+ ,2.00
+ ,12.30
+ ,200.00
+ ,3.00
+ ,1.00
+ ,3.00
+ ,13.20
+ ,2.60
+ ,2.30
+ ,0.10
+ ,2.50
+ ,46.00
+ ,3.00
+ ,2.00
+ ,2.00
+ ,9.70
+ ,0.60
+ ,24.00
+ ,4.19
+ ,58.00
+ ,210.00
+ ,4.00
+ ,3.00
+ ,4.00
+ ,12.80
+ ,6.60
+ ,3.00
+ ,3.50
+ ,3.90
+ ,14.00
+ ,2.00
+ ,1.00
+ ,1.00
+ ,-999.00
+ ,-999.00
+ ,13.00
+ ,4.05
+ ,17.00
+ ,38.00
+ ,3.00
+ ,1.00
+ ,1.00)
+ ,dim=c(9
+ ,62)
+ ,dimnames=list(c('SWS'
+ ,'PS'
+ ,'L'
+ ,'Wb'
+ ,'Wbr'
+ ,'Tg'
+ ,'P'
+ ,'S'
+ ,'D
')
+ ,1:62))
> y <- array(NA,dim=c(9,62),dimnames=list(c('SWS','PS','L','Wb','Wbr','Tg','P','S','D
'),1:62))
> 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 = '9'
> #'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
> 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
D\r SWS PS L Wb Wbr Tg P S
1 3 -999.0 -999.0 38.6 6654.00 5712.00 645.0 3 5
2 3 6.3 2.0 4.5 1.00 6600.00 42.0 3 1
3 1 -999.0 -999.0 14.0 3.39 44.50 60.0 1 1
4 3 -999.0 -999.0 -999.0 0.92 5.70 25.0 5 2
5 4 2.1 1.8 69.0 2547.00 4603.00 624.0 3 5
6 4 9.1 0.7 27.0 10.55 179.50 180.0 4 4
7 1 15.8 3.9 19.0 0.02 0.30 35.0 1 1
8 4 5.2 1.0 30.4 160.00 169.00 392.0 4 5
9 1 10.9 3.6 28.0 3.30 25.60 63.0 1 2
10 1 8.3 1.4 50.0 52.16 440.00 230.0 1 1
11 4 11.0 1.5 7.0 0.43 6.40 112.0 5 4
12 5 3.2 0.7 30.0 465.00 423.00 281.0 5 5
13 2 7.6 2.7 -999.0 0.55 2.40 -999.0 2 1
14 5 -999.0 -999.0 40.0 187.10 419.00 365.0 5 5
15 1 6.3 2.1 3.5 0.08 1.20 42.0 1 1
16 2 8.6 0.0 50.0 3.00 25.00 28.0 2 2
17 2 6.6 4.1 6.0 0.79 3500.00 42.0 2 2
18 2 9.5 1.2 10.4 0.20 5.00 120.0 2 2
19 1 4.8 1.3 34.0 1.41 17.50 -999.0 1 2
20 1 12.0 6.1 7.0 60.00 81.00 -999.0 1 1
21 5 -999.0 0.3 28.0 529.00 680.00 400.0 5 5
22 5 3.3 0.5 20.0 27.66 115.00 148.0 5 5
23 2 11.0 3.4 3.9 0.12 1.00 16.0 3 1
24 1 -999.0 -999.0 39.3 207.00 406.00 252.0 1 4
25 1 4.7 1.5 41.0 85.00 325.00 310.0 1 3
26 1 -999.0 -999.0 16.2 36.33 119.50 63.0 1 1
27 3 10.4 3.4 9.0 0.10 4.00 28.0 5 1
28 4 7.4 0.8 7.6 1.04 5.50 68.0 5 3
29 5 2.1 0.8 46.0 521.00 655.00 336.0 5 5
30 1 -999.0 -999.0 22.4 100.00 157.00 100.0 1 1
31 4 -999.0 -999.0 16.3 35.00 56.00 33.0 3 5
32 4 7.7 1.4 2.6 0.01 0.14 21.5 5 2
33 1 17.9 2.0 24.0 0.01 0.25 50.0 1 1
34 1 6.1 1.9 100.0 62.00 1320.00 267.0 1 1
35 1 8.2 2.4 -999.0 0.12 3.00 30.0 2 1
36 3 8.4 2.8 -999.0 1.35 8.10 45.0 3 1
37 3 11.9 1.3 3.2 0.02 0.40 19.0 4 1
38 3 10.8 2.0 2.0 0.05 0.33 30.0 4 1
39 1 13.8 5.6 5.0 1.70 6.30 12.0 2 1
40 1 14.3 3.1 6.5 3.50 10.80 120.0 2 1
41 5 -999.0 1.0 23.6 250.00 490.00 440.0 5 5
42 2 15.2 1.8 12.0 0.48 15.50 140.0 2 2
43 4 10.0 0.9 20.2 10.00 115.00 170.0 4 4
44 2 11.9 1.8 13.0 1.62 11.40 17.0 2 1
45 4 6.5 1.9 27.0 192.00 180.00 115.0 4 4
46 5 7.5 0.9 18.0 2.50 12.10 31.0 5 5
47 2 -999.0 -999.0 13.7 4.29 39.20 63.0 2 2
48 3 10.6 2.6 4.7 0.28 1.90 21.0 3 1
49 1 7.4 2.4 9.8 4.24 50.40 52.0 1 1
50 2 8.4 1.2 29.0 6.80 179.00 164.0 2 3
51 2 5.7 0.9 7.0 0.75 12.30 225.0 2 2
52 3 4.9 0.5 6.0 3.60 21.00 225.0 3 2
53 5 -999.0 -999.0 17.0 14.83 98.20 150.0 5 5
54 5 3.2 0.6 20.0 55.50 175.00 151.0 5 5
55 2 -999.0 -999.0 12.7 1.40 12.50 90.0 2 2
56 2 8.1 2.2 3.5 0.06 1.00 -999.0 3 1
57 2 11.0 2.3 4.5 0.90 2.60 60.0 2 1
58 3 4.9 0.5 7.5 2.00 12.30 200.0 3 1
59 2 13.2 2.6 2.3 0.10 2.50 46.0 3 2
60 4 9.7 0.6 24.0 4.19 58.00 210.0 4 3
61 1 12.8 6.6 3.0 3.50 3.90 14.0 2 1
62 1 -999.0 -999.0 13.0 4.05 17.00 38.0 3 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) SWS PS L Wb Wbr
-1.016e-01 -6.096e-05 2.617e-04 7.327e-06 -1.387e-04 1.051e-04
Tg P S
1.263e-05 6.602e-01 3.456e-01
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.02586 -0.23864 0.08274 0.25298 0.78123
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.016e-01 1.289e-01 -0.788 0.434
SWS -6.096e-05 3.164e-04 -0.193 0.848
PS 2.617e-04 3.327e-04 0.787 0.435
L 7.327e-06 2.271e-04 0.032 0.974
Wb -1.387e-04 8.431e-05 -1.645 0.106
Wbr 1.051e-04 5.491e-05 1.914 0.061 .
Tg 1.263e-05 2.003e-04 0.063 0.950
P 6.602e-01 4.888e-02 13.507 <2e-16 ***
S 3.456e-01 5.022e-02 6.881 7e-09 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4144 on 53 degrees of freedom
Multiple R-squared: 0.9282, Adjusted R-squared: 0.9173
F-statistic: 85.59 on 8 and 53 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.39584810 0.79169620 0.6041519
[2,] 0.30018744 0.60037487 0.6998126
[3,] 0.25205549 0.50411098 0.7479445
[4,] 0.15026194 0.30052388 0.8497381
[5,] 0.08687055 0.17374110 0.9131294
[6,] 0.15194179 0.30388357 0.8480582
[7,] 0.10090008 0.20180016 0.8990999
[8,] 0.19132538 0.38265076 0.8086746
[9,] 0.13520683 0.27041367 0.8647932
[10,] 0.08637713 0.17275426 0.9136229
[11,] 0.05905021 0.11810042 0.9409498
[12,] 0.03601426 0.07202852 0.9639857
[13,] 0.11439384 0.22878767 0.8856062
[14,] 0.15150163 0.30300326 0.8484984
[15,] 0.13680317 0.27360635 0.8631968
[16,] 0.17406981 0.34813961 0.8259302
[17,] 0.13508337 0.27016674 0.8649166
[18,] 0.10278386 0.20556772 0.8972161
[19,] 0.08826477 0.17652954 0.9117352
[20,] 0.12196770 0.24393539 0.8780323
[21,] 0.09217732 0.18435464 0.9078227
[22,] 0.06587315 0.13174630 0.9341269
[23,] 0.04291999 0.08583998 0.9570800
[24,] 0.06468024 0.12936048 0.9353198
[25,] 0.14323366 0.28646731 0.8567663
[26,] 0.10216283 0.20432567 0.8978372
[27,] 0.06953643 0.13907287 0.9304636
[28,] 0.08522823 0.17045646 0.9147718
[29,] 0.11812504 0.23625009 0.8818750
[30,] 0.08484621 0.16969242 0.9151538
[31,] 0.05554393 0.11108786 0.9444561
[32,] 0.03400207 0.06800415 0.9659979
[33,] 0.03087491 0.06174982 0.9691251
[34,] 0.01873659 0.03747319 0.9812634
[35,] 0.01614232 0.03228464 0.9838577
[36,] 0.01525840 0.03051680 0.9847416
[37,] 0.05225659 0.10451319 0.9477434
[38,] 0.02817378 0.05634756 0.9718262
[39,] 0.02028331 0.04056663 0.9797167
> postscript(file="/var/www/rcomp/tmp/10qmf1293048052.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/www/rcomp/tmp/20qmf1293048052.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/www/rcomp/tmp/30qmf1293048052.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/www/rcomp/tmp/4ti411293048052.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/www/rcomp/tmp/5ti411293048052.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 = 62
Frequency = 1
1 2 3 4 5 6
-0.092002985 0.081090738 0.291328577 -0.683545287 0.253893345 0.058917925
7 8 9 10 11 12
0.095144128 -0.267835319 -0.253270961 0.053668568 -0.583605715 0.088917757
13 14 15 16 17 18
0.455108670 0.250221635 0.094975047 0.087607795 -0.278994736 0.088190038
19 20 21 22 23 24
-0.239077786 0.107327807 0.008310935 0.062428642 -0.225178111 -0.757744229
25 26 27 28 29 30
-0.622020656 0.287961451 -0.546173283 -0.237340126 0.071396734 0.292340262
31 32 33 34 35 36
0.592093740 0.109136798 0.095547155 -0.038559150 -0.557899823 0.781226993
37 38 39 40 41 42
0.115217059 0.114848123 -0.565652893 -0.566566837 -0.011082032 0.087051249
43 44 45 46 47 48
0.065799697 0.434556970 0.084387411 0.071397783 0.286177973 0.774865466
49 50 51 52 53 54
0.090196946 -0.275513232 0.086044248 0.425362711 0.262925073 0.059914424
55 56 57 58 59 60
0.288249581 -0.212222201 0.434715292 0.771931102 -0.570933429 0.416082820
61 62
-0.565484224 -1.025855654
> postscript(file="/var/www/rcomp/tmp/6ti411293048052.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 = 62
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.092002985 NA
1 0.081090738 -0.092002985
2 0.291328577 0.081090738
3 -0.683545287 0.291328577
4 0.253893345 -0.683545287
5 0.058917925 0.253893345
6 0.095144128 0.058917925
7 -0.267835319 0.095144128
8 -0.253270961 -0.267835319
9 0.053668568 -0.253270961
10 -0.583605715 0.053668568
11 0.088917757 -0.583605715
12 0.455108670 0.088917757
13 0.250221635 0.455108670
14 0.094975047 0.250221635
15 0.087607795 0.094975047
16 -0.278994736 0.087607795
17 0.088190038 -0.278994736
18 -0.239077786 0.088190038
19 0.107327807 -0.239077786
20 0.008310935 0.107327807
21 0.062428642 0.008310935
22 -0.225178111 0.062428642
23 -0.757744229 -0.225178111
24 -0.622020656 -0.757744229
25 0.287961451 -0.622020656
26 -0.546173283 0.287961451
27 -0.237340126 -0.546173283
28 0.071396734 -0.237340126
29 0.292340262 0.071396734
30 0.592093740 0.292340262
31 0.109136798 0.592093740
32 0.095547155 0.109136798
33 -0.038559150 0.095547155
34 -0.557899823 -0.038559150
35 0.781226993 -0.557899823
36 0.115217059 0.781226993
37 0.114848123 0.115217059
38 -0.565652893 0.114848123
39 -0.566566837 -0.565652893
40 -0.011082032 -0.566566837
41 0.087051249 -0.011082032
42 0.065799697 0.087051249
43 0.434556970 0.065799697
44 0.084387411 0.434556970
45 0.071397783 0.084387411
46 0.286177973 0.071397783
47 0.774865466 0.286177973
48 0.090196946 0.774865466
49 -0.275513232 0.090196946
50 0.086044248 -0.275513232
51 0.425362711 0.086044248
52 0.262925073 0.425362711
53 0.059914424 0.262925073
54 0.288249581 0.059914424
55 -0.212222201 0.288249581
56 0.434715292 -0.212222201
57 0.771931102 0.434715292
58 -0.570933429 0.771931102
59 0.416082820 -0.570933429
60 -0.565484224 0.416082820
61 -1.025855654 -0.565484224
62 NA -1.025855654
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.081090738 -0.092002985
[2,] 0.291328577 0.081090738
[3,] -0.683545287 0.291328577
[4,] 0.253893345 -0.683545287
[5,] 0.058917925 0.253893345
[6,] 0.095144128 0.058917925
[7,] -0.267835319 0.095144128
[8,] -0.253270961 -0.267835319
[9,] 0.053668568 -0.253270961
[10,] -0.583605715 0.053668568
[11,] 0.088917757 -0.583605715
[12,] 0.455108670 0.088917757
[13,] 0.250221635 0.455108670
[14,] 0.094975047 0.250221635
[15,] 0.087607795 0.094975047
[16,] -0.278994736 0.087607795
[17,] 0.088190038 -0.278994736
[18,] -0.239077786 0.088190038
[19,] 0.107327807 -0.239077786
[20,] 0.008310935 0.107327807
[21,] 0.062428642 0.008310935
[22,] -0.225178111 0.062428642
[23,] -0.757744229 -0.225178111
[24,] -0.622020656 -0.757744229
[25,] 0.287961451 -0.622020656
[26,] -0.546173283 0.287961451
[27,] -0.237340126 -0.546173283
[28,] 0.071396734 -0.237340126
[29,] 0.292340262 0.071396734
[30,] 0.592093740 0.292340262
[31,] 0.109136798 0.592093740
[32,] 0.095547155 0.109136798
[33,] -0.038559150 0.095547155
[34,] -0.557899823 -0.038559150
[35,] 0.781226993 -0.557899823
[36,] 0.115217059 0.781226993
[37,] 0.114848123 0.115217059
[38,] -0.565652893 0.114848123
[39,] -0.566566837 -0.565652893
[40,] -0.011082032 -0.566566837
[41,] 0.087051249 -0.011082032
[42,] 0.065799697 0.087051249
[43,] 0.434556970 0.065799697
[44,] 0.084387411 0.434556970
[45,] 0.071397783 0.084387411
[46,] 0.286177973 0.071397783
[47,] 0.774865466 0.286177973
[48,] 0.090196946 0.774865466
[49,] -0.275513232 0.090196946
[50,] 0.086044248 -0.275513232
[51,] 0.425362711 0.086044248
[52,] 0.262925073 0.425362711
[53,] 0.059914424 0.262925073
[54,] 0.288249581 0.059914424
[55,] -0.212222201 0.288249581
[56,] 0.434715292 -0.212222201
[57,] 0.771931102 0.434715292
[58,] -0.570933429 0.771931102
[59,] 0.416082820 -0.570933429
[60,] -0.565484224 0.416082820
[61,] -1.025855654 -0.565484224
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.081090738 -0.092002985
2 0.291328577 0.081090738
3 -0.683545287 0.291328577
4 0.253893345 -0.683545287
5 0.058917925 0.253893345
6 0.095144128 0.058917925
7 -0.267835319 0.095144128
8 -0.253270961 -0.267835319
9 0.053668568 -0.253270961
10 -0.583605715 0.053668568
11 0.088917757 -0.583605715
12 0.455108670 0.088917757
13 0.250221635 0.455108670
14 0.094975047 0.250221635
15 0.087607795 0.094975047
16 -0.278994736 0.087607795
17 0.088190038 -0.278994736
18 -0.239077786 0.088190038
19 0.107327807 -0.239077786
20 0.008310935 0.107327807
21 0.062428642 0.008310935
22 -0.225178111 0.062428642
23 -0.757744229 -0.225178111
24 -0.622020656 -0.757744229
25 0.287961451 -0.622020656
26 -0.546173283 0.287961451
27 -0.237340126 -0.546173283
28 0.071396734 -0.237340126
29 0.292340262 0.071396734
30 0.592093740 0.292340262
31 0.109136798 0.592093740
32 0.095547155 0.109136798
33 -0.038559150 0.095547155
34 -0.557899823 -0.038559150
35 0.781226993 -0.557899823
36 0.115217059 0.781226993
37 0.114848123 0.115217059
38 -0.565652893 0.114848123
39 -0.566566837 -0.565652893
40 -0.011082032 -0.566566837
41 0.087051249 -0.011082032
42 0.065799697 0.087051249
43 0.434556970 0.065799697
44 0.084387411 0.434556970
45 0.071397783 0.084387411
46 0.286177973 0.071397783
47 0.774865466 0.286177973
48 0.090196946 0.774865466
49 -0.275513232 0.090196946
50 0.086044248 -0.275513232
51 0.425362711 0.086044248
52 0.262925073 0.425362711
53 0.059914424 0.262925073
54 0.288249581 0.059914424
55 -0.212222201 0.288249581
56 0.434715292 -0.212222201
57 0.771931102 0.434715292
58 -0.570933429 0.771931102
59 0.416082820 -0.570933429
60 -0.565484224 0.416082820
61 -1.025855654 -0.565484224
> 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/rcomp/tmp/7l9l31293048052.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/www/rcomp/tmp/8e0261293048052.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/www/rcomp/tmp/9e0261293048052.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/www/rcomp/tmp/10prj91293048052.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/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/rcomp/tmp/11ss0f1293048052.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/rcomp/tmp/12ljhi1293048052.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/rcomp/tmp/13rkwu1293048052.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/rcomp/tmp/14kbdx1293048052.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/rcomp/tmp/15nuck1293048052.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/rcomp/tmp/162mst1293048052.tab")
+ }
>
> try(system("convert tmp/10qmf1293048052.ps tmp/10qmf1293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/20qmf1293048052.ps tmp/20qmf1293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/30qmf1293048052.ps tmp/30qmf1293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ti411293048052.ps tmp/4ti411293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ti411293048052.ps tmp/5ti411293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ti411293048052.ps tmp/6ti411293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/7l9l31293048052.ps tmp/7l9l31293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/8e0261293048052.ps tmp/8e0261293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/9e0261293048052.ps tmp/9e0261293048052.png",intern=TRUE))
character(0)
> try(system("convert tmp/10prj91293048052.ps tmp/10prj91293048052.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.150 1.370 4.519