R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(14.5,14.8,14.3,14.7,15.3,16,14.4,15.4,13.7,15,14.2,15.5,13.5,15.1,11.9,11.7,14.6,16.3,15.6,16.7,14.1,15,14.9,14.9,14.2,14.6,14.6,15.3,17.2,17.9,15.4,16.4,14.3,15.4,17.5,17.9,14.5,15.9,14.4,13.9,16.6,17.8,16.7,17.9,16.6,17.4,16.9,16.7,15.7,16,16.4,16.6,18.4,19.1,16.9,17.8,16.5,17.2,18.3,18.6,15.1,16.3,15.7,15.1,18.1,19.2,16.8,17.7,18.9,19.1,19,18,18.1,17.5,17.8,17.8,21.5,21.1,17.1,17.2,18.7,19.4,19,19.8,16.4,17.6,16.9,16.2,18.6,19.5,19.3,19.9,19.4,20,17.6,17.3,18.6,18.9,18.1,18.6,20.4,21.4,18.1,18.6,19.6,19.8,19.9,20.8,19.2,19.6,17.8,17.7,19.2,19.8,22,22.2,21.1,20.7,19.5,17.9,22.2,20.9,20.9,21.2,22.2,21.4,23.5,23,21.5,21.3,24.3,23.9,22.8,22.4,20.3,18.3,23.7,22.8,23.3,22.3,19.6,17.8,18,16.4,17.3,16,16.8,16.4,18.2,17.7,16.5,16.6,16,16.2,18.4,18.3),dim=c(2,78),dimnames=list(c('Y','X'),1:78))
> y <- array(NA,dim=c(2,78),dimnames=list(c('Y','X'),1:78))
> 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
Y X M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 14.5 14.8 1 0 0 0 0 0 0 0 0 0 0
2 14.3 14.7 0 1 0 0 0 0 0 0 0 0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 0
67 22.8 22.4 0 0 0 0 0 0 1 0 0 0 0
68 20.3 18.3 0 0 0 0 0 0 0 1 0 0 0
69 23.7 22.8 0 0 0 0 0 0 0 0 1 0 0
70 23.3 22.3 0 0 0 0 0 0 0 0 0 1 0
71 19.6 17.8 0 0 0 0 0 0 0 0 0 0 1
72 18.0 16.4 0 0 0 0 0 0 0 0 0 0 0
73 17.3 16.0 1 0 0 0 0 0 0 0 0 0 0
74 16.8 16.4 0 1 0 0 0 0 0 0 0 0 0
75 18.2 17.7 0 0 1 0 0 0 0 0 0 0 0
76 16.5 16.6 0 0 0 1 0 0 0 0 0 0 0
77 16.0 16.2 0 0 0 0 1 0 0 0 0 0 0
78 18.4 18.3 0 0 0 0 0 1 0 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
-2.2910 1.1823 -0.5284 -1.0922 -1.4138 -1.4067
M5 M6 M7 M8 M9 M10
-1.5171 -1.6762 -1.8565 0.1521 -1.9814 -1.7542
M11
-1.1007
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.19579 -0.29109 -0.09884 0.25157 1.94721
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.29102 0.57716 -3.969 0.000183 ***
X 1.18227 0.03117 37.935 < 2e-16 ***
M1 -0.52840 0.32478 -1.627 0.108586
M2 -1.09216 0.32496 -3.361 0.001305 **
M3 -1.41385 0.33300 -4.246 7.07e-05 ***
M4 -1.40673 0.32623 -4.312 5.61e-05 ***
M5 -1.51707 0.32595 -4.654 1.65e-05 ***
M6 -1.67620 0.33320 -5.031 4.11e-06 ***
M7 -1.85649 0.33832 -5.487 7.21e-07 ***
M8 0.15215 0.33977 0.448 0.655795
M9 -1.98138 0.34500 -5.743 2.66e-07 ***
M10 -1.75421 0.34651 -5.063 3.64e-06 ***
M11 -1.10067 0.34011 -3.236 0.001907 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.5837 on 65 degrees of freedom
Multiple R-squared: 0.9614, Adjusted R-squared: 0.9542
F-statistic: 134.8 on 12 and 65 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,] 9.732493e-03 1.946499e-02 0.990267507
[2,] 3.168137e-03 6.336275e-03 0.996831863
[3,] 1.414626e-02 2.829251e-02 0.985853745
[4,] 4.372359e-03 8.744719e-03 0.995627641
[5,] 1.306299e-03 2.612597e-03 0.998693701
[6,] 4.778106e-04 9.556213e-04 0.999522189
[7,] 2.533114e-04 5.066229e-04 0.999746689
[8,] 1.262050e-04 2.524100e-04 0.999873795
[9,] 3.998241e-05 7.996483e-05 0.999960018
[10,] 1.372236e-05 2.744472e-05 0.999986278
[11,] 4.046885e-06 8.093770e-06 0.999995953
[12,] 2.456054e-06 4.912108e-06 0.999997544
[13,] 8.361754e-07 1.672351e-06 0.999999164
[14,] 3.942833e-07 7.885665e-07 0.999999606
[15,] 2.161293e-07 4.322585e-07 0.999999784
[16,] 7.793342e-08 1.558668e-07 0.999999922
[17,] 2.010290e-08 4.020580e-08 0.999999980
[18,] 6.038591e-09 1.207718e-08 0.999999994
[19,] 2.423243e-09 4.846485e-09 0.999999998
[20,] 1.092335e-09 2.184670e-09 0.999999999
[21,] 3.427119e-09 6.854237e-09 0.999999997
[22,] 6.685986e-09 1.337197e-08 0.999999993
[23,] 1.767020e-09 3.534039e-09 0.999999998
[24,] 1.594243e-09 3.188487e-09 0.999999998
[25,] 1.167945e-08 2.335890e-08 0.999999988
[26,] 1.023233e-08 2.046466e-08 0.999999990
[27,] 2.214949e-08 4.429897e-08 0.999999978
[28,] 1.233563e-08 2.467126e-08 0.999999988
[29,] 4.633606e-09 9.267213e-09 0.999999995
[30,] 2.521945e-09 5.043889e-09 0.999999997
[31,] 1.248342e-09 2.496683e-09 0.999999999
[32,] 7.946866e-09 1.589373e-08 0.999999992
[33,] 1.187279e-08 2.374558e-08 0.999999988
[34,] 3.259619e-07 6.519237e-07 0.999999674
[35,] 4.264733e-07 8.529466e-07 0.999999574
[36,] 4.446545e-05 8.893091e-05 0.999955535
[37,] 2.871189e-05 5.742379e-05 0.999971288
[38,] 1.702325e-05 3.404650e-05 0.999982977
[39,] 6.352800e-05 1.270560e-04 0.999936472
[40,] 6.989444e-05 1.397889e-04 0.999930106
[41,] 3.263359e-03 6.526717e-03 0.996736641
[42,] 2.049709e-02 4.099418e-02 0.979502912
[43,] 6.820102e-02 1.364020e-01 0.931798985
[44,] 6.203298e-01 7.593403e-01 0.379670174
[45,] 5.752399e-01 8.495202e-01 0.424760120
[46,] 4.819903e-01 9.639805e-01 0.518009748
[47,] 9.915505e-01 1.689891e-02 0.008449453
> postscript(file="/var/www/html/rcomp/tmp/1b8sq1258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/29t7p1258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/3ynk51258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/4dn2g1258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/5jsv51258794649.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 = 78
Frequency = 1
1 2 3 4 5 6
-0.178237918 0.303749498 0.088484024 -0.109270060 -0.226016487 -0.158028389
7 8 9 10 11 12
-0.204822808 0.206269259 -0.398663482 -0.098747015 -0.242420624 -0.424861501
13 14 15 16 17 18
-0.241783155 -0.105614790 -0.257836220 -0.291543873 -0.098926013 0.304514460
19 20 21 22 23 24
-0.150641859 0.105266870 -0.172074202 -0.417475590 -0.579877775 -0.552954365
25 26 27 28 29 30
-0.396966493 0.157429254 -0.476564795 -0.446727211 -0.027018876 0.276922791
31 32 33 34 35 36
-0.023551384 -0.013461705 -0.327257540 -0.081020828 -0.289743257 0.010089679
37 38 39 40 41 42
0.229622787 0.138700678 0.258887579 0.462637077 -0.428021264 -0.441805784
43 44 45 46 47 48
-0.260507341 -0.113962899 -0.181939683 -0.182023216 -0.853789688 -0.562318652
49 50 51 52 53 54
-0.925560551 -0.507118372 -1.195794565 -0.192546261 -0.000930789 -0.724079597
55 56 57 58 59 60
0.174945034 -0.987373618 0.063378173 -0.201252985 0.018618643 0.628317060
61 62 63 64 65 66
0.309891824 -0.781030285 0.604205435 0.005448963 0.125658492 0.010871583
67 68 69 70 71 72
0.464578358 0.803262094 1.016556734 0.980519633 1.947212700 0.901727779
73 74 75 76 77 78
1.203033507 0.793884016 0.978618542 0.572001365 0.655254937 0.731604935
> postscript(file="/var/www/html/rcomp/tmp/6g2vf1258794649.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 = 78
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.178237918 NA
1 0.303749498 -0.178237918
2 0.088484024 0.303749498
3 -0.109270060 0.088484024
4 -0.226016487 -0.109270060
5 -0.158028389 -0.226016487
6 -0.204822808 -0.158028389
7 0.206269259 -0.204822808
8 -0.398663482 0.206269259
9 -0.098747015 -0.398663482
10 -0.242420624 -0.098747015
11 -0.424861501 -0.242420624
12 -0.241783155 -0.424861501
13 -0.105614790 -0.241783155
14 -0.257836220 -0.105614790
15 -0.291543873 -0.257836220
16 -0.098926013 -0.291543873
17 0.304514460 -0.098926013
18 -0.150641859 0.304514460
19 0.105266870 -0.150641859
20 -0.172074202 0.105266870
21 -0.417475590 -0.172074202
22 -0.579877775 -0.417475590
23 -0.552954365 -0.579877775
24 -0.396966493 -0.552954365
25 0.157429254 -0.396966493
26 -0.476564795 0.157429254
27 -0.446727211 -0.476564795
28 -0.027018876 -0.446727211
29 0.276922791 -0.027018876
30 -0.023551384 0.276922791
31 -0.013461705 -0.023551384
32 -0.327257540 -0.013461705
33 -0.081020828 -0.327257540
34 -0.289743257 -0.081020828
35 0.010089679 -0.289743257
36 0.229622787 0.010089679
37 0.138700678 0.229622787
38 0.258887579 0.138700678
39 0.462637077 0.258887579
40 -0.428021264 0.462637077
41 -0.441805784 -0.428021264
42 -0.260507341 -0.441805784
43 -0.113962899 -0.260507341
44 -0.181939683 -0.113962899
45 -0.182023216 -0.181939683
46 -0.853789688 -0.182023216
47 -0.562318652 -0.853789688
48 -0.925560551 -0.562318652
49 -0.507118372 -0.925560551
50 -1.195794565 -0.507118372
51 -0.192546261 -1.195794565
52 -0.000930789 -0.192546261
53 -0.724079597 -0.000930789
54 0.174945034 -0.724079597
55 -0.987373618 0.174945034
56 0.063378173 -0.987373618
57 -0.201252985 0.063378173
58 0.018618643 -0.201252985
59 0.628317060 0.018618643
60 0.309891824 0.628317060
61 -0.781030285 0.309891824
62 0.604205435 -0.781030285
63 0.005448963 0.604205435
64 0.125658492 0.005448963
65 0.010871583 0.125658492
66 0.464578358 0.010871583
67 0.803262094 0.464578358
68 1.016556734 0.803262094
69 0.980519633 1.016556734
70 1.947212700 0.980519633
71 0.901727779 1.947212700
72 1.203033507 0.901727779
73 0.793884016 1.203033507
74 0.978618542 0.793884016
75 0.572001365 0.978618542
76 0.655254937 0.572001365
77 0.731604935 0.655254937
78 NA 0.731604935
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 0.303749498 -0.178237918
[2,] 0.088484024 0.303749498
[3,] -0.109270060 0.088484024
[4,] -0.226016487 -0.109270060
[5,] -0.158028389 -0.226016487
[6,] -0.204822808 -0.158028389
[7,] 0.206269259 -0.204822808
[8,] -0.398663482 0.206269259
[9,] -0.098747015 -0.398663482
[10,] -0.242420624 -0.098747015
[11,] -0.424861501 -0.242420624
[12,] -0.241783155 -0.424861501
[13,] -0.105614790 -0.241783155
[14,] -0.257836220 -0.105614790
[15,] -0.291543873 -0.257836220
[16,] -0.098926013 -0.291543873
[17,] 0.304514460 -0.098926013
[18,] -0.150641859 0.304514460
[19,] 0.105266870 -0.150641859
[20,] -0.172074202 0.105266870
[21,] -0.417475590 -0.172074202
[22,] -0.579877775 -0.417475590
[23,] -0.552954365 -0.579877775
[24,] -0.396966493 -0.552954365
[25,] 0.157429254 -0.396966493
[26,] -0.476564795 0.157429254
[27,] -0.446727211 -0.476564795
[28,] -0.027018876 -0.446727211
[29,] 0.276922791 -0.027018876
[30,] -0.023551384 0.276922791
[31,] -0.013461705 -0.023551384
[32,] -0.327257540 -0.013461705
[33,] -0.081020828 -0.327257540
[34,] -0.289743257 -0.081020828
[35,] 0.010089679 -0.289743257
[36,] 0.229622787 0.010089679
[37,] 0.138700678 0.229622787
[38,] 0.258887579 0.138700678
[39,] 0.462637077 0.258887579
[40,] -0.428021264 0.462637077
[41,] -0.441805784 -0.428021264
[42,] -0.260507341 -0.441805784
[43,] -0.113962899 -0.260507341
[44,] -0.181939683 -0.113962899
[45,] -0.182023216 -0.181939683
[46,] -0.853789688 -0.182023216
[47,] -0.562318652 -0.853789688
[48,] -0.925560551 -0.562318652
[49,] -0.507118372 -0.925560551
[50,] -1.195794565 -0.507118372
[51,] -0.192546261 -1.195794565
[52,] -0.000930789 -0.192546261
[53,] -0.724079597 -0.000930789
[54,] 0.174945034 -0.724079597
[55,] -0.987373618 0.174945034
[56,] 0.063378173 -0.987373618
[57,] -0.201252985 0.063378173
[58,] 0.018618643 -0.201252985
[59,] 0.628317060 0.018618643
[60,] 0.309891824 0.628317060
[61,] -0.781030285 0.309891824
[62,] 0.604205435 -0.781030285
[63,] 0.005448963 0.604205435
[64,] 0.125658492 0.005448963
[65,] 0.010871583 0.125658492
[66,] 0.464578358 0.010871583
[67,] 0.803262094 0.464578358
[68,] 1.016556734 0.803262094
[69,] 0.980519633 1.016556734
[70,] 1.947212700 0.980519633
[71,] 0.901727779 1.947212700
[72,] 1.203033507 0.901727779
[73,] 0.793884016 1.203033507
[74,] 0.978618542 0.793884016
[75,] 0.572001365 0.978618542
[76,] 0.655254937 0.572001365
[77,] 0.731604935 0.655254937
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 0.303749498 -0.178237918
2 0.088484024 0.303749498
3 -0.109270060 0.088484024
4 -0.226016487 -0.109270060
5 -0.158028389 -0.226016487
6 -0.204822808 -0.158028389
7 0.206269259 -0.204822808
8 -0.398663482 0.206269259
9 -0.098747015 -0.398663482
10 -0.242420624 -0.098747015
11 -0.424861501 -0.242420624
12 -0.241783155 -0.424861501
13 -0.105614790 -0.241783155
14 -0.257836220 -0.105614790
15 -0.291543873 -0.257836220
16 -0.098926013 -0.291543873
17 0.304514460 -0.098926013
18 -0.150641859 0.304514460
19 0.105266870 -0.150641859
20 -0.172074202 0.105266870
21 -0.417475590 -0.172074202
22 -0.579877775 -0.417475590
23 -0.552954365 -0.579877775
24 -0.396966493 -0.552954365
25 0.157429254 -0.396966493
26 -0.476564795 0.157429254
27 -0.446727211 -0.476564795
28 -0.027018876 -0.446727211
29 0.276922791 -0.027018876
30 -0.023551384 0.276922791
31 -0.013461705 -0.023551384
32 -0.327257540 -0.013461705
33 -0.081020828 -0.327257540
34 -0.289743257 -0.081020828
35 0.010089679 -0.289743257
36 0.229622787 0.010089679
37 0.138700678 0.229622787
38 0.258887579 0.138700678
39 0.462637077 0.258887579
40 -0.428021264 0.462637077
41 -0.441805784 -0.428021264
42 -0.260507341 -0.441805784
43 -0.113962899 -0.260507341
44 -0.181939683 -0.113962899
45 -0.182023216 -0.181939683
46 -0.853789688 -0.182023216
47 -0.562318652 -0.853789688
48 -0.925560551 -0.562318652
49 -0.507118372 -0.925560551
50 -1.195794565 -0.507118372
51 -0.192546261 -1.195794565
52 -0.000930789 -0.192546261
53 -0.724079597 -0.000930789
54 0.174945034 -0.724079597
55 -0.987373618 0.174945034
56 0.063378173 -0.987373618
57 -0.201252985 0.063378173
58 0.018618643 -0.201252985
59 0.628317060 0.018618643
60 0.309891824 0.628317060
61 -0.781030285 0.309891824
62 0.604205435 -0.781030285
63 0.005448963 0.604205435
64 0.125658492 0.005448963
65 0.010871583 0.125658492
66 0.464578358 0.010871583
67 0.803262094 0.464578358
68 1.016556734 0.803262094
69 0.980519633 1.016556734
70 1.947212700 0.980519633
71 0.901727779 1.947212700
72 1.203033507 0.901727779
73 0.793884016 1.203033507
74 0.978618542 0.793884016
75 0.572001365 0.978618542
76 0.655254937 0.572001365
77 0.731604935 0.655254937
> plot(z,main=paste('Residual Lag plot, lowess, and regression line'), ylab='values of Residuals', xlab='lagged values of Residuals')
> lines(lowess(z))
> abline(lm(z))
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/7yi9d1258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8yg0x1258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9xoh31258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10yr1t1258794649.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11f7p31258794649.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a,hyperlink('http://www.xycoon.com/ols1.htm','Multiple Linear Regression - Ordinary Least Squares',''), 6, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a,'Variable',header=TRUE)
> a<-table.element(a,'Parameter',header=TRUE)
> a<-table.element(a,'S.D.',header=TRUE)
> a<-table.element(a,'T-STAT
H0: parameter = 0',header=TRUE)
> a<-table.element(a,'2-tail p-value',header=TRUE)
> a<-table.element(a,'1-tail p-value',header=TRUE)
> a<-table.row.end(a)
> for (i in 1:k){
+ a<-table.row.start(a)
+ a<-table.element(a,rownames(mysum$coefficients)[i],header=TRUE)
+ a<-table.element(a,mysum$coefficients[i,1])
+ a<-table.element(a, round(mysum$coefficients[i,2],6))
+ a<-table.element(a, round(mysum$coefficients[i,3],4))
+ a<-table.element(a, round(mysum$coefficients[i,4],6))
+ a<-table.element(a, round(mysum$coefficients[i,4]/2,6))
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/12y1s21258794649.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Regression Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple R',1,TRUE)
> a<-table.element(a, sqrt(mysum$r.squared))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'R-squared',1,TRUE)
> a<-table.element(a, mysum$r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Adjusted R-squared',1,TRUE)
> a<-table.element(a, mysum$adj.r.squared)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (value)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[1])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[2])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
> a<-table.element(a, mysum$fstatistic[3])
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'p-value',1,TRUE)
> a<-table.element(a, 1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]))
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Residual Statistics', 2, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Residual Standard Deviation',1,TRUE)
> a<-table.element(a, mysum$sigma)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
> a<-table.element(a, sum(myerror*myerror))
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/13xl1i1258794649.tab")
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Actuals, Interpolation, and Residuals', 4, TRUE)
> a<-table.row.end(a)
> a<-table.row.start(a)
> a<-table.element(a, 'Time or Index', 1, TRUE)
> a<-table.element(a, 'Actuals', 1, TRUE)
> a<-table.element(a, 'Interpolation
Forecast', 1, TRUE)
> a<-table.element(a, 'Residuals
Prediction Error', 1, TRUE)
> a<-table.row.end(a)
> for (i in 1:n) {
+ a<-table.row.start(a)
+ a<-table.element(a,i, 1, TRUE)
+ a<-table.element(a,x[i])
+ a<-table.element(a,x[i]-mysum$resid[i])
+ a<-table.element(a,mysum$resid[i])
+ a<-table.row.end(a)
+ }
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/14v58s1258794649.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/150xy61258794649.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/16kf9c1258794649.tab")
+ }
>
> system("convert tmp/1b8sq1258794649.ps tmp/1b8sq1258794649.png")
> system("convert tmp/29t7p1258794649.ps tmp/29t7p1258794649.png")
> system("convert tmp/3ynk51258794649.ps tmp/3ynk51258794649.png")
> system("convert tmp/4dn2g1258794649.ps tmp/4dn2g1258794649.png")
> system("convert tmp/5jsv51258794649.ps tmp/5jsv51258794649.png")
> system("convert tmp/6g2vf1258794649.ps tmp/6g2vf1258794649.png")
> system("convert tmp/7yi9d1258794649.ps tmp/7yi9d1258794649.png")
> system("convert tmp/8yg0x1258794649.ps tmp/8yg0x1258794649.png")
> system("convert tmp/9xoh31258794649.ps tmp/9xoh31258794649.png")
> system("convert tmp/10yr1t1258794649.ps tmp/10yr1t1258794649.png")
>
>
> proc.time()
user system elapsed
2.649 1.600 3.692