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(83.7
+ ,0
+ ,137.5
+ ,114.6
+ ,111.3
+ ,115.6
+ ,106.0
+ ,0
+ ,83.7
+ ,137.5
+ ,114.6
+ ,111.3
+ ,123.4
+ ,0
+ ,106.0
+ ,83.7
+ ,137.5
+ ,114.6
+ ,126.5
+ ,0
+ ,123.4
+ ,106.0
+ ,83.7
+ ,137.5
+ ,120.0
+ ,0
+ ,126.5
+ ,123.4
+ ,106.0
+ ,83.7
+ ,141.6
+ ,0
+ ,120.0
+ ,126.5
+ ,123.4
+ ,106.0
+ ,90.5
+ ,0
+ ,141.6
+ ,120.0
+ ,126.5
+ ,123.4
+ ,96.5
+ ,0
+ ,90.5
+ ,141.6
+ ,120.0
+ ,126.5
+ ,113.5
+ ,0
+ ,96.5
+ ,90.5
+ ,141.6
+ ,120.0
+ ,120.1
+ ,0
+ ,113.5
+ ,96.5
+ ,90.5
+ ,141.6
+ ,123.9
+ ,0
+ ,120.1
+ ,113.5
+ ,96.5
+ ,90.5
+ ,144.4
+ ,0
+ ,123.9
+ ,120.1
+ ,113.5
+ ,96.5
+ ,90.8
+ ,0
+ ,144.4
+ ,123.9
+ ,120.1
+ ,113.5
+ ,114.2
+ ,0
+ ,90.8
+ ,144.4
+ ,123.9
+ ,120.1
+ ,138.1
+ ,0
+ ,114.2
+ ,90.8
+ ,144.4
+ ,123.9
+ ,135.0
+ ,0
+ ,138.1
+ ,114.2
+ ,90.8
+ ,144.4
+ ,131.3
+ ,0
+ ,135.0
+ ,138.1
+ ,114.2
+ ,90.8
+ ,144.6
+ ,0
+ ,131.3
+ ,135.0
+ ,138.1
+ ,114.2
+ ,101.7
+ ,0
+ ,144.6
+ ,131.3
+ ,135.0
+ ,138.1
+ ,108.7
+ ,0
+ ,101.7
+ ,144.6
+ ,131.3
+ ,135.0
+ ,135.3
+ ,0
+ ,108.7
+ ,101.7
+ ,144.6
+ ,131.3
+ ,124.3
+ ,0
+ ,135.3
+ ,108.7
+ ,101.7
+ ,144.6
+ ,138.3
+ ,0
+ ,124.3
+ ,135.3
+ ,108.7
+ ,101.7
+ ,158.2
+ ,0
+ ,138.3
+ ,124.3
+ ,135.3
+ ,108.7
+ ,93.5
+ ,0
+ ,158.2
+ ,138.3
+ ,124.3
+ ,135.3
+ ,124.8
+ ,0
+ ,93.5
+ ,158.2
+ ,138.3
+ ,124.3
+ ,154.4
+ ,0
+ ,124.8
+ ,93.5
+ ,158.2
+ ,138.3
+ ,152.8
+ ,0
+ ,154.4
+ ,124.8
+ ,93.5
+ ,158.2
+ ,148.9
+ ,0
+ ,152.8
+ ,154.4
+ ,124.8
+ ,93.5
+ ,170.3
+ ,0
+ ,148.9
+ ,152.8
+ ,154.4
+ ,124.8
+ ,124.8
+ ,0
+ ,170.3
+ ,148.9
+ ,152.8
+ ,154.4
+ ,134.4
+ ,0
+ ,124.8
+ ,170.3
+ ,148.9
+ ,152.8
+ ,154.0
+ ,0
+ ,134.4
+ ,124.8
+ ,170.3
+ ,148.9
+ ,147.9
+ ,0
+ ,154.0
+ ,134.4
+ ,124.8
+ ,170.3
+ ,168.1
+ ,0
+ ,147.9
+ ,154.0
+ ,134.4
+ ,124.8
+ ,175.7
+ ,0
+ ,168.1
+ ,147.9
+ ,154.0
+ ,134.4
+ ,116.7
+ ,0
+ ,175.7
+ ,168.1
+ ,147.9
+ ,154.0
+ ,140.8
+ ,0
+ ,116.7
+ ,175.7
+ ,168.1
+ ,147.9
+ ,164.2
+ ,0
+ ,140.8
+ ,116.7
+ ,175.7
+ ,168.1
+ ,173.8
+ ,0
+ ,164.2
+ ,140.8
+ ,116.7
+ ,175.7
+ ,167.8
+ ,0
+ ,173.8
+ ,164.2
+ ,140.8
+ ,116.7
+ ,166.6
+ ,0
+ ,167.8
+ ,173.8
+ ,164.2
+ ,140.8
+ ,135.1
+ ,1
+ ,166.6
+ ,167.8
+ ,173.8
+ ,164.2
+ ,158.1
+ ,1
+ ,135.1
+ ,166.6
+ ,167.8
+ ,173.8
+ ,151.8
+ ,1
+ ,158.1
+ ,135.1
+ ,166.6
+ ,167.8
+ ,166.7
+ ,1
+ ,151.8
+ ,158.1
+ ,135.1
+ ,166.6
+ ,165.3
+ ,1
+ ,166.7
+ ,151.8
+ ,158.1
+ ,135.1
+ ,187.0
+ ,1
+ ,165.3
+ ,166.7
+ ,151.8
+ ,158.1
+ ,125.2
+ ,1
+ ,187.0
+ ,165.3
+ ,166.7
+ ,151.8
+ ,144.4
+ ,1
+ ,125.2
+ ,187.0
+ ,165.3
+ ,166.7
+ ,181.7
+ ,1
+ ,144.4
+ ,125.2
+ ,187.0
+ ,165.3
+ ,175.9
+ ,1
+ ,181.7
+ ,144.4
+ ,125.2
+ ,187.0
+ ,166.3
+ ,1
+ ,175.9
+ ,181.7
+ ,144.4
+ ,125.2
+ ,181.5
+ ,1
+ ,166.3
+ ,175.9
+ ,181.7
+ ,144.4
+ ,121.8
+ ,1
+ ,181.5
+ ,166.3
+ ,175.9
+ ,181.7
+ ,134.8
+ ,1
+ ,121.8
+ ,181.5
+ ,166.3
+ ,175.9
+ ,162.9
+ ,1
+ ,134.8
+ ,121.8
+ ,181.5
+ ,166.3)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57))
> 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
Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 83.7 0 137.5 114.6 111.3 115.6 1 0 0 0 0 0 0 0 0 0 0 1
2 106.0 0 83.7 137.5 114.6 111.3 0 1 0 0 0 0 0 0 0 0 0 2
3 123.4 0 106.0 83.7 137.5 114.6 0 0 1 0 0 0 0 0 0 0 0 3
4 126.5 0 123.4 106.0 83.7 137.5 0 0 0 1 0 0 0 0 0 0 0 4
5 120.0 0 126.5 123.4 106.0 83.7 0 0 0 0 1 0 0 0 0 0 0 5
6 141.6 0 120.0 126.5 123.4 106.0 0 0 0 0 0 1 0 0 0 0 0 6
7 90.5 0 141.6 120.0 126.5 123.4 0 0 0 0 0 0 1 0 0 0 0 7
8 96.5 0 90.5 141.6 120.0 126.5 0 0 0 0 0 0 0 1 0 0 0 8
9 113.5 0 96.5 90.5 141.6 120.0 0 0 0 0 0 0 0 0 1 0 0 9
10 120.1 0 113.5 96.5 90.5 141.6 0 0 0 0 0 0 0 0 0 1 0 10
11 123.9 0 120.1 113.5 96.5 90.5 0 0 0 0 0 0 0 0 0 0 1 11
12 144.4 0 123.9 120.1 113.5 96.5 0 0 0 0 0 0 0 0 0 0 0 12
13 90.8 0 144.4 123.9 120.1 113.5 1 0 0 0 0 0 0 0 0 0 0 13
14 114.2 0 90.8 144.4 123.9 120.1 0 1 0 0 0 0 0 0 0 0 0 14
15 138.1 0 114.2 90.8 144.4 123.9 0 0 1 0 0 0 0 0 0 0 0 15
16 135.0 0 138.1 114.2 90.8 144.4 0 0 0 1 0 0 0 0 0 0 0 16
17 131.3 0 135.0 138.1 114.2 90.8 0 0 0 0 1 0 0 0 0 0 0 17
18 144.6 0 131.3 135.0 138.1 114.2 0 0 0 0 0 1 0 0 0 0 0 18
19 101.7 0 144.6 131.3 135.0 138.1 0 0 0 0 0 0 1 0 0 0 0 19
20 108.7 0 101.7 144.6 131.3 135.0 0 0 0 0 0 0 0 1 0 0 0 20
21 135.3 0 108.7 101.7 144.6 131.3 0 0 0 0 0 0 0 0 1 0 0 21
22 124.3 0 135.3 108.7 101.7 144.6 0 0 0 0 0 0 0 0 0 1 0 22
23 138.3 0 124.3 135.3 108.7 101.7 0 0 0 0 0 0 0 0 0 0 1 23
24 158.2 0 138.3 124.3 135.3 108.7 0 0 0 0 0 0 0 0 0 0 0 24
25 93.5 0 158.2 138.3 124.3 135.3 1 0 0 0 0 0 0 0 0 0 0 25
26 124.8 0 93.5 158.2 138.3 124.3 0 1 0 0 0 0 0 0 0 0 0 26
27 154.4 0 124.8 93.5 158.2 138.3 0 0 1 0 0 0 0 0 0 0 0 27
28 152.8 0 154.4 124.8 93.5 158.2 0 0 0 1 0 0 0 0 0 0 0 28
29 148.9 0 152.8 154.4 124.8 93.5 0 0 0 0 1 0 0 0 0 0 0 29
30 170.3 0 148.9 152.8 154.4 124.8 0 0 0 0 0 1 0 0 0 0 0 30
31 124.8 0 170.3 148.9 152.8 154.4 0 0 0 0 0 0 1 0 0 0 0 31
32 134.4 0 124.8 170.3 148.9 152.8 0 0 0 0 0 0 0 1 0 0 0 32
33 154.0 0 134.4 124.8 170.3 148.9 0 0 0 0 0 0 0 0 1 0 0 33
34 147.9 0 154.0 134.4 124.8 170.3 0 0 0 0 0 0 0 0 0 1 0 34
35 168.1 0 147.9 154.0 134.4 124.8 0 0 0 0 0 0 0 0 0 0 1 35
36 175.7 0 168.1 147.9 154.0 134.4 0 0 0 0 0 0 0 0 0 0 0 36
37 116.7 0 175.7 168.1 147.9 154.0 1 0 0 0 0 0 0 0 0 0 0 37
38 140.8 0 116.7 175.7 168.1 147.9 0 1 0 0 0 0 0 0 0 0 0 38
39 164.2 0 140.8 116.7 175.7 168.1 0 0 1 0 0 0 0 0 0 0 0 39
40 173.8 0 164.2 140.8 116.7 175.7 0 0 0 1 0 0 0 0 0 0 0 40
41 167.8 0 173.8 164.2 140.8 116.7 0 0 0 0 1 0 0 0 0 0 0 41
42 166.6 0 167.8 173.8 164.2 140.8 0 0 0 0 0 1 0 0 0 0 0 42
43 135.1 1 166.6 167.8 173.8 164.2 0 0 0 0 0 0 1 0 0 0 0 43
44 158.1 1 135.1 166.6 167.8 173.8 0 0 0 0 0 0 0 1 0 0 0 44
45 151.8 1 158.1 135.1 166.6 167.8 0 0 0 0 0 0 0 0 1 0 0 45
46 166.7 1 151.8 158.1 135.1 166.6 0 0 0 0 0 0 0 0 0 1 0 46
47 165.3 1 166.7 151.8 158.1 135.1 0 0 0 0 0 0 0 0 0 0 1 47
48 187.0 1 165.3 166.7 151.8 158.1 0 0 0 0 0 0 0 0 0 0 0 48
49 125.2 1 187.0 165.3 166.7 151.8 1 0 0 0 0 0 0 0 0 0 0 49
50 144.4 1 125.2 187.0 165.3 166.7 0 1 0 0 0 0 0 0 0 0 0 50
51 181.7 1 144.4 125.2 187.0 165.3 0 0 1 0 0 0 0 0 0 0 0 51
52 175.9 1 181.7 144.4 125.2 187.0 0 0 0 1 0 0 0 0 0 0 0 52
53 166.3 1 175.9 181.7 144.4 125.2 0 0 0 0 1 0 0 0 0 0 0 53
54 181.5 1 166.3 175.9 181.7 144.4 0 0 0 0 0 1 0 0 0 0 0 54
55 121.8 1 181.5 166.3 175.9 181.7 0 0 0 0 0 0 1 0 0 0 0 55
56 134.8 1 121.8 181.5 166.3 175.9 0 0 0 0 0 0 0 1 0 0 0 56
57 162.9 1 134.8 121.8 181.5 166.3 0 0 0 0 0 0 0 0 1 0 0 57
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 Y2 Y3 Y4
47.64528 -2.61493 0.16833 0.17849 0.40768 0.05327
M1 M2 M3 M4 M5 M6
-64.45953 -37.30428 -12.75972 1.64489 -15.96065 -13.19691
M7 M8 M9 M10 M11 t
-61.90775 -42.73798 -25.09675 -12.92618 -9.07613 0.20574
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-14.26320 -3.98907 -0.07722 3.96691 16.61026
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 47.64528 24.11534 1.976 0.055292 .
X -2.61493 3.34165 -0.783 0.438631
Y1 0.16833 0.16444 1.024 0.312314
Y2 0.17849 0.15959 1.118 0.270227
Y3 0.40768 0.17398 2.343 0.024313 *
Y4 0.05327 0.18155 0.293 0.770747
M1 -64.45953 5.42963 -11.872 1.60e-14 ***
M2 -37.30428 10.93956 -3.410 0.001523 **
M3 -12.75972 10.60204 -1.204 0.236032
M4 1.64489 10.57292 0.156 0.877170
M5 -15.96065 7.05189 -2.263 0.029259 *
M6 -13.19691 5.49835 -2.400 0.021260 *
M7 -61.90775 6.50401 -9.518 1.02e-11 ***
M8 -42.73798 10.68772 -3.999 0.000275 ***
M9 -25.09675 9.77228 -2.568 0.014169 *
M10 -12.92618 9.37763 -1.378 0.175934
M11 -9.07613 5.46663 -1.660 0.104879
t 0.20574 0.27365 0.752 0.456671
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 6.768 on 39 degrees of freedom
Multiple R-squared: 0.9528, Adjusted R-squared: 0.9323
F-statistic: 46.33 on 17 and 39 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.08303767 0.16607533 0.9169623
[2,] 0.02819550 0.05639100 0.9718045
[3,] 0.02566529 0.05133058 0.9743347
[4,] 0.05320780 0.10641559 0.9467922
[5,] 0.16631700 0.33263400 0.8336830
[6,] 0.09418014 0.18836028 0.9058199
[7,] 0.06519179 0.13038357 0.9348082
[8,] 0.06139627 0.12279254 0.9386037
[9,] 0.18982637 0.37965274 0.8101736
[10,] 0.34310060 0.68620120 0.6568994
[11,] 0.24276043 0.48552087 0.7572396
[12,] 0.19955048 0.39910097 0.8004495
[13,] 0.12336170 0.24672340 0.8766383
[14,] 0.36007866 0.72015733 0.6399213
[15,] 0.33862233 0.67724465 0.6613777
[16,] 0.33884877 0.67769754 0.6611512
> postscript(file="/var/www/html/rcomp/tmp/1c2pa1258643311.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/2jz1u1258643311.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/3j17f1258643311.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/4cpuv1258643311.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/5neu81258643311.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 = 57
Frequency = 1
1 2 3 4 5 6
5.17522255 3.96690829 -7.04630438 -4.75269288 -3.70549437 7.18425989
7 8 9 10 11 12
-0.07722264 -6.22148720 -7.41740604 2.55542169 -1.56939963 0.58087224
13 14 15 16 17 18
3.50927470 3.01113731 -0.77114440 -5.92170483 -2.65010805 -2.13358716
19 20 21 22 23 24
1.88365833 -3.97070094 6.03603514 -6.28640928 0.19342514 -0.79893237
25 26 27 28 29 30
-4.02635940 2.13036915 4.40067385 2.93778599 2.11018658 7.74801085
31 32 33 34 35 36
6.92228479 2.66147811 2.40306682 -3.67666741 8.50628693 -3.98906713
37 38 39 40 41 42
-2.17733513 -4.77337501 -3.82429106 6.57307323 5.49839823 -10.19814047
43 44 45 46 47 48
5.53447455 16.61026217 -4.97717538 7.40765501 -7.13031243 4.20712726
49 50 51 52 53 54
-2.48080272 -4.33503974 7.24106600 1.16353849 -1.25298238 -2.60054311
55 56 57
-14.26319503 -9.07955215 3.95547946
> postscript(file="/var/www/html/rcomp/tmp/6hdpx1258643311.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 5.17522255 NA
1 3.96690829 5.17522255
2 -7.04630438 3.96690829
3 -4.75269288 -7.04630438
4 -3.70549437 -4.75269288
5 7.18425989 -3.70549437
6 -0.07722264 7.18425989
7 -6.22148720 -0.07722264
8 -7.41740604 -6.22148720
9 2.55542169 -7.41740604
10 -1.56939963 2.55542169
11 0.58087224 -1.56939963
12 3.50927470 0.58087224
13 3.01113731 3.50927470
14 -0.77114440 3.01113731
15 -5.92170483 -0.77114440
16 -2.65010805 -5.92170483
17 -2.13358716 -2.65010805
18 1.88365833 -2.13358716
19 -3.97070094 1.88365833
20 6.03603514 -3.97070094
21 -6.28640928 6.03603514
22 0.19342514 -6.28640928
23 -0.79893237 0.19342514
24 -4.02635940 -0.79893237
25 2.13036915 -4.02635940
26 4.40067385 2.13036915
27 2.93778599 4.40067385
28 2.11018658 2.93778599
29 7.74801085 2.11018658
30 6.92228479 7.74801085
31 2.66147811 6.92228479
32 2.40306682 2.66147811
33 -3.67666741 2.40306682
34 8.50628693 -3.67666741
35 -3.98906713 8.50628693
36 -2.17733513 -3.98906713
37 -4.77337501 -2.17733513
38 -3.82429106 -4.77337501
39 6.57307323 -3.82429106
40 5.49839823 6.57307323
41 -10.19814047 5.49839823
42 5.53447455 -10.19814047
43 16.61026217 5.53447455
44 -4.97717538 16.61026217
45 7.40765501 -4.97717538
46 -7.13031243 7.40765501
47 4.20712726 -7.13031243
48 -2.48080272 4.20712726
49 -4.33503974 -2.48080272
50 7.24106600 -4.33503974
51 1.16353849 7.24106600
52 -1.25298238 1.16353849
53 -2.60054311 -1.25298238
54 -14.26319503 -2.60054311
55 -9.07955215 -14.26319503
56 3.95547946 -9.07955215
57 NA 3.95547946
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 3.96690829 5.17522255
[2,] -7.04630438 3.96690829
[3,] -4.75269288 -7.04630438
[4,] -3.70549437 -4.75269288
[5,] 7.18425989 -3.70549437
[6,] -0.07722264 7.18425989
[7,] -6.22148720 -0.07722264
[8,] -7.41740604 -6.22148720
[9,] 2.55542169 -7.41740604
[10,] -1.56939963 2.55542169
[11,] 0.58087224 -1.56939963
[12,] 3.50927470 0.58087224
[13,] 3.01113731 3.50927470
[14,] -0.77114440 3.01113731
[15,] -5.92170483 -0.77114440
[16,] -2.65010805 -5.92170483
[17,] -2.13358716 -2.65010805
[18,] 1.88365833 -2.13358716
[19,] -3.97070094 1.88365833
[20,] 6.03603514 -3.97070094
[21,] -6.28640928 6.03603514
[22,] 0.19342514 -6.28640928
[23,] -0.79893237 0.19342514
[24,] -4.02635940 -0.79893237
[25,] 2.13036915 -4.02635940
[26,] 4.40067385 2.13036915
[27,] 2.93778599 4.40067385
[28,] 2.11018658 2.93778599
[29,] 7.74801085 2.11018658
[30,] 6.92228479 7.74801085
[31,] 2.66147811 6.92228479
[32,] 2.40306682 2.66147811
[33,] -3.67666741 2.40306682
[34,] 8.50628693 -3.67666741
[35,] -3.98906713 8.50628693
[36,] -2.17733513 -3.98906713
[37,] -4.77337501 -2.17733513
[38,] -3.82429106 -4.77337501
[39,] 6.57307323 -3.82429106
[40,] 5.49839823 6.57307323
[41,] -10.19814047 5.49839823
[42,] 5.53447455 -10.19814047
[43,] 16.61026217 5.53447455
[44,] -4.97717538 16.61026217
[45,] 7.40765501 -4.97717538
[46,] -7.13031243 7.40765501
[47,] 4.20712726 -7.13031243
[48,] -2.48080272 4.20712726
[49,] -4.33503974 -2.48080272
[50,] 7.24106600 -4.33503974
[51,] 1.16353849 7.24106600
[52,] -1.25298238 1.16353849
[53,] -2.60054311 -1.25298238
[54,] -14.26319503 -2.60054311
[55,] -9.07955215 -14.26319503
[56,] 3.95547946 -9.07955215
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 3.96690829 5.17522255
2 -7.04630438 3.96690829
3 -4.75269288 -7.04630438
4 -3.70549437 -4.75269288
5 7.18425989 -3.70549437
6 -0.07722264 7.18425989
7 -6.22148720 -0.07722264
8 -7.41740604 -6.22148720
9 2.55542169 -7.41740604
10 -1.56939963 2.55542169
11 0.58087224 -1.56939963
12 3.50927470 0.58087224
13 3.01113731 3.50927470
14 -0.77114440 3.01113731
15 -5.92170483 -0.77114440
16 -2.65010805 -5.92170483
17 -2.13358716 -2.65010805
18 1.88365833 -2.13358716
19 -3.97070094 1.88365833
20 6.03603514 -3.97070094
21 -6.28640928 6.03603514
22 0.19342514 -6.28640928
23 -0.79893237 0.19342514
24 -4.02635940 -0.79893237
25 2.13036915 -4.02635940
26 4.40067385 2.13036915
27 2.93778599 4.40067385
28 2.11018658 2.93778599
29 7.74801085 2.11018658
30 6.92228479 7.74801085
31 2.66147811 6.92228479
32 2.40306682 2.66147811
33 -3.67666741 2.40306682
34 8.50628693 -3.67666741
35 -3.98906713 8.50628693
36 -2.17733513 -3.98906713
37 -4.77337501 -2.17733513
38 -3.82429106 -4.77337501
39 6.57307323 -3.82429106
40 5.49839823 6.57307323
41 -10.19814047 5.49839823
42 5.53447455 -10.19814047
43 16.61026217 5.53447455
44 -4.97717538 16.61026217
45 7.40765501 -4.97717538
46 -7.13031243 7.40765501
47 4.20712726 -7.13031243
48 -2.48080272 4.20712726
49 -4.33503974 -2.48080272
50 7.24106600 -4.33503974
51 1.16353849 7.24106600
52 -1.25298238 1.16353849
53 -2.60054311 -1.25298238
54 -14.26319503 -2.60054311
55 -9.07955215 -14.26319503
56 3.95547946 -9.07955215
> 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/7l5me1258643311.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/83nxs1258643311.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/9c1e31258643311.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/10lk2c1258643311.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/11ixjr1258643311.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/12txi31258643311.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/13u6q51258643311.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/14uv8a1258643311.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/15ymel1258643312.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/16nqjf1258643312.tab")
+ }
> system("convert tmp/1c2pa1258643311.ps tmp/1c2pa1258643311.png")
> system("convert tmp/2jz1u1258643311.ps tmp/2jz1u1258643311.png")
> system("convert tmp/3j17f1258643311.ps tmp/3j17f1258643311.png")
> system("convert tmp/4cpuv1258643311.ps tmp/4cpuv1258643311.png")
> system("convert tmp/5neu81258643311.ps tmp/5neu81258643311.png")
> system("convert tmp/6hdpx1258643311.ps tmp/6hdpx1258643311.png")
> system("convert tmp/7l5me1258643311.ps tmp/7l5me1258643311.png")
> system("convert tmp/83nxs1258643311.ps tmp/83nxs1258643311.png")
> system("convert tmp/9c1e31258643311.ps tmp/9c1e31258643311.png")
> system("convert tmp/10lk2c1258643311.ps tmp/10lk2c1258643311.png")
>
>
> proc.time()
user system elapsed
2.368 1.553 2.806