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(103.86
+ ,93.6
+ ,104.08
+ ,107.47
+ ,104.2
+ ,103.86
+ ,111.1
+ ,95.3
+ ,107.47
+ ,117.33
+ ,102.7
+ ,111.1
+ ,119.04
+ ,103.1
+ ,117.33
+ ,123.68
+ ,100
+ ,119.04
+ ,125.9
+ ,107.2
+ ,123.68
+ ,124.54
+ ,107
+ ,125.9
+ ,119.39
+ ,119
+ ,124.54
+ ,118.8
+ ,110.4
+ ,119.39
+ ,114.81
+ ,101.7
+ ,118.8
+ ,117.9
+ ,102.4
+ ,114.81
+ ,120.53
+ ,98.8
+ ,117.9
+ ,125.15
+ ,105.6
+ ,120.53
+ ,126.49
+ ,104.4
+ ,125.15
+ ,131.85
+ ,106.3
+ ,126.49
+ ,127.4
+ ,107.2
+ ,131.85
+ ,131.08
+ ,108.5
+ ,127.4
+ ,122.37
+ ,106.9
+ ,131.08
+ ,124.34
+ ,114.2
+ ,122.37
+ ,119.61
+ ,125.9
+ ,124.34
+ ,119.97
+ ,110.6
+ ,119.61
+ ,116.46
+ ,110.5
+ ,119.97
+ ,117.03
+ ,106.7
+ ,116.46
+ ,120.96
+ ,104.7
+ ,117.03
+ ,124.71
+ ,107.4
+ ,120.96
+ ,127.08
+ ,109.8
+ ,124.71
+ ,131.91
+ ,103.4
+ ,127.08
+ ,137.69
+ ,114.8
+ ,131.91
+ ,142.46
+ ,114.3
+ ,137.69
+ ,144.32
+ ,109.6
+ ,142.46
+ ,138.06
+ ,118.3
+ ,144.32
+ ,124.45
+ ,127.3
+ ,138.06
+ ,126.71
+ ,112.3
+ ,124.45
+ ,121.83
+ ,114.9
+ ,126.71
+ ,122.51
+ ,108.2
+ ,121.83
+ ,125.48
+ ,105.4
+ ,122.51
+ ,127.77
+ ,122.1
+ ,125.48
+ ,128.03
+ ,113.5
+ ,127.77
+ ,132.84
+ ,110
+ ,128.03
+ ,133.41
+ ,125.3
+ ,132.84
+ ,139.99
+ ,114.3
+ ,133.41
+ ,138.53
+ ,115.6
+ ,139.99
+ ,136.12
+ ,127.1
+ ,138.53
+ ,124.75
+ ,123
+ ,136.12
+ ,122.88
+ ,122.2
+ ,124.75
+ ,121.46
+ ,126.4
+ ,122.88
+ ,118.4
+ ,112.7
+ ,121.46
+ ,122.45
+ ,105.8
+ ,118.4
+ ,128.94
+ ,120.9
+ ,122.45
+ ,133.25
+ ,116.3
+ ,128.94
+ ,137.94
+ ,115.7
+ ,133.25
+ ,140.04
+ ,127.9
+ ,137.94
+ ,130.74
+ ,108.3
+ ,140.04
+ ,131.55
+ ,121.1
+ ,130.74
+ ,129.47
+ ,128.6
+ ,131.55
+ ,125.45
+ ,123.1
+ ,129.47
+ ,127.87
+ ,127.7
+ ,125.45
+ ,124.68
+ ,126.6
+ ,127.87)
+ ,dim=c(3
+ ,59)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y1')
+ ,1:59))
> y <- array(NA,dim=c(3,59),dimnames=list(c('Y','X','Y1'),1:59))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 103.86 93.6 104.08 1 0 0 0 0 0 0 0 0 0 0 1
2 107.47 104.2 103.86 0 1 0 0 0 0 0 0 0 0 0 2
3 111.10 95.3 107.47 0 0 1 0 0 0 0 0 0 0 0 3
4 117.33 102.7 111.10 0 0 0 1 0 0 0 0 0 0 0 4
5 119.04 103.1 117.33 0 0 0 0 1 0 0 0 0 0 0 5
6 123.68 100.0 119.04 0 0 0 0 0 1 0 0 0 0 0 6
7 125.90 107.2 123.68 0 0 0 0 0 0 1 0 0 0 0 7
8 124.54 107.0 125.90 0 0 0 0 0 0 0 1 0 0 0 8
9 119.39 119.0 124.54 0 0 0 0 0 0 0 0 1 0 0 9
10 118.80 110.4 119.39 0 0 0 0 0 0 0 0 0 1 0 10
11 114.81 101.7 118.80 0 0 0 0 0 0 0 0 0 0 1 11
12 117.90 102.4 114.81 0 0 0 0 0 0 0 0 0 0 0 12
13 120.53 98.8 117.90 1 0 0 0 0 0 0 0 0 0 0 13
14 125.15 105.6 120.53 0 1 0 0 0 0 0 0 0 0 0 14
15 126.49 104.4 125.15 0 0 1 0 0 0 0 0 0 0 0 15
16 131.85 106.3 126.49 0 0 0 1 0 0 0 0 0 0 0 16
17 127.40 107.2 131.85 0 0 0 0 1 0 0 0 0 0 0 17
18 131.08 108.5 127.40 0 0 0 0 0 1 0 0 0 0 0 18
19 122.37 106.9 131.08 0 0 0 0 0 0 1 0 0 0 0 19
20 124.34 114.2 122.37 0 0 0 0 0 0 0 1 0 0 0 20
21 119.61 125.9 124.34 0 0 0 0 0 0 0 0 1 0 0 21
22 119.97 110.6 119.61 0 0 0 0 0 0 0 0 0 1 0 22
23 116.46 110.5 119.97 0 0 0 0 0 0 0 0 0 0 1 23
24 117.03 106.7 116.46 0 0 0 0 0 0 0 0 0 0 0 24
25 120.96 104.7 117.03 1 0 0 0 0 0 0 0 0 0 0 25
26 124.71 107.4 120.96 0 1 0 0 0 0 0 0 0 0 0 26
27 127.08 109.8 124.71 0 0 1 0 0 0 0 0 0 0 0 27
28 131.91 103.4 127.08 0 0 0 1 0 0 0 0 0 0 0 28
29 137.69 114.8 131.91 0 0 0 0 1 0 0 0 0 0 0 29
30 142.46 114.3 137.69 0 0 0 0 0 1 0 0 0 0 0 30
31 144.32 109.6 142.46 0 0 0 0 0 0 1 0 0 0 0 31
32 138.06 118.3 144.32 0 0 0 0 0 0 0 1 0 0 0 32
33 124.45 127.3 138.06 0 0 0 0 0 0 0 0 1 0 0 33
34 126.71 112.3 124.45 0 0 0 0 0 0 0 0 0 1 0 34
35 121.83 114.9 126.71 0 0 0 0 0 0 0 0 0 0 1 35
36 122.51 108.2 121.83 0 0 0 0 0 0 0 0 0 0 0 36
37 125.48 105.4 122.51 1 0 0 0 0 0 0 0 0 0 0 37
38 127.77 122.1 125.48 0 1 0 0 0 0 0 0 0 0 0 38
39 128.03 113.5 127.77 0 0 1 0 0 0 0 0 0 0 0 39
40 132.84 110.0 128.03 0 0 0 1 0 0 0 0 0 0 0 40
41 133.41 125.3 132.84 0 0 0 0 1 0 0 0 0 0 0 41
42 139.99 114.3 133.41 0 0 0 0 0 1 0 0 0 0 0 42
43 138.53 115.6 139.99 0 0 0 0 0 0 1 0 0 0 0 43
44 136.12 127.1 138.53 0 0 0 0 0 0 0 1 0 0 0 44
45 124.75 123.0 136.12 0 0 0 0 0 0 0 0 1 0 0 45
46 122.88 122.2 124.75 0 0 0 0 0 0 0 0 0 1 0 46
47 121.46 126.4 122.88 0 0 0 0 0 0 0 0 0 0 1 47
48 118.40 112.7 121.46 0 0 0 0 0 0 0 0 0 0 0 48
49 122.45 105.8 118.40 1 0 0 0 0 0 0 0 0 0 0 49
50 128.94 120.9 122.45 0 1 0 0 0 0 0 0 0 0 0 50
51 133.25 116.3 128.94 0 0 1 0 0 0 0 0 0 0 0 51
52 137.94 115.7 133.25 0 0 0 1 0 0 0 0 0 0 0 52
53 140.04 127.9 137.94 0 0 0 0 1 0 0 0 0 0 0 53
54 130.74 108.3 140.04 0 0 0 0 0 1 0 0 0 0 0 54
55 131.55 121.1 130.74 0 0 0 0 0 0 1 0 0 0 0 55
56 129.47 128.6 131.55 0 0 0 0 0 0 0 1 0 0 0 56
57 125.45 123.1 129.47 0 0 0 0 0 0 0 0 1 0 0 57
58 127.87 127.7 125.45 0 0 0 0 0 0 0 0 0 1 0 58
59 124.68 126.6 127.87 0 0 0 0 0 0 0 0 0 0 1 59
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X Y1 M1 M2 M3
4.10695 0.21839 0.77703 2.90012 2.73605 2.83169
M4 M5 M6 M7 M8 M9
6.24423 1.62929 4.27991 0.98420 -1.71621 -8.89833
M10 M11 t
-0.78006 -4.41660 -0.02701
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-8.6548 -1.2894 0.1868 1.2152 5.4353
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.10695 14.38542 0.285 0.77661
X 0.21839 0.11246 1.942 0.05857 .
Y1 0.77703 0.08677 8.955 1.79e-11 ***
M1 2.90012 2.06592 1.404 0.16740
M2 2.73605 2.11892 1.291 0.20336
M3 2.83169 2.06033 1.374 0.17628
M4 6.24423 2.10202 2.971 0.00480 **
M5 1.62929 2.44312 0.667 0.50833
M6 4.27991 2.30196 1.859 0.06969 .
M7 0.98420 2.41687 0.407 0.68582
M8 -1.71621 2.60214 -0.660 0.51299
M9 -8.89833 2.78219 -3.198 0.00256 **
M10 -0.78006 2.20314 -0.354 0.72498
M11 -4.41660 2.16634 -2.039 0.04751 *
t -0.02701 0.05067 -0.533 0.59671
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 2.993 on 44 degrees of freedom
Multiple R-squared: 0.9003, Adjusted R-squared: 0.8685
F-statistic: 28.37 on 14 and 44 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.4101169 0.8202338 0.5898831
[2,] 0.6686107 0.6627786 0.3313893
[3,] 0.7262114 0.5475772 0.2737886
[4,] 0.6010862 0.7978277 0.3989138
[5,] 0.5614649 0.8770702 0.4385351
[6,] 0.4545750 0.9091499 0.5454250
[7,] 0.3542014 0.7084029 0.6457986
[8,] 0.3091016 0.6182032 0.6908984
[9,] 0.2401477 0.4802955 0.7598523
[10,] 0.1725539 0.3451078 0.8274461
[11,] 0.1263815 0.2527630 0.8736185
[12,] 0.1825399 0.3650799 0.8174601
[13,] 0.1575795 0.3151591 0.8424205
[14,] 0.2990179 0.5980358 0.7009821
[15,] 0.3159556 0.6319112 0.6840444
[16,] 0.4397491 0.8794983 0.5602509
[17,] 0.4475988 0.8951975 0.5524012
[18,] 0.3981651 0.7963302 0.6018349
[19,] 0.4447295 0.8894591 0.5552705
[20,] 0.3283961 0.6567923 0.6716039
[21,] 0.3574902 0.7149805 0.6425098
[22,] 0.3015709 0.6031418 0.6984291
[23,] 0.2111971 0.4223942 0.7888029
[24,] 0.1334698 0.2669396 0.8665302
> postscript(file="/var/www/html/rcomp/tmp/118y51258761692.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/2r5eq1258761692.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/3e8zm1258761692.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/4ivyr1258761692.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/5xiev1258761692.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 = 59
Frequency = 1
1 2 3 4 5 6
-4.43428704 -2.77716178 -0.07722792 -1.66943306 -0.24573435 1.11892812
7 8 9 10 11 12
1.48384680 1.16994353 1.66519615 -1.13623371 0.89572320 2.54361152
13 14 15 16 17 18
0.68567372 1.96813220 -0.08830916 0.43000908 -3.73946945 0.49079672
19 20 21 22 23 24
-7.40653586 2.46459908 0.85785829 0.14326462 0.03892035 -0.22342695
25 26 27 28 29 30
0.82733222 1.12503606 -0.01158030 0.98900413 5.16829446 2.93264095
31 32 33 34 35 36
5.43534362 -1.44246765 -4.94460974 3.07530556 -0.46503859 1.08046546
37 38 39 40 41 42
1.26046045 -2.21329633 -1.92319901 0.06359787 -1.80327806 4.11245078
43 44 45 46 47 48
0.57841121 -0.48114288 -1.87398829 -2.82570634 -0.04633550 -3.40065003
49 50 51 52 53 54
1.66082066 1.89728986 2.10031640 0.18682198 0.62018739 -8.65481657
55 56 57 58 59
-0.09106577 -1.71093208 4.29554359 0.74336987 -0.42326946
> postscript(file="/var/www/html/rcomp/tmp/6j2q81258761692.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 = 59
Frequency = 1
lag(myerror, k = 1) myerror
0 -4.43428704 NA
1 -2.77716178 -4.43428704
2 -0.07722792 -2.77716178
3 -1.66943306 -0.07722792
4 -0.24573435 -1.66943306
5 1.11892812 -0.24573435
6 1.48384680 1.11892812
7 1.16994353 1.48384680
8 1.66519615 1.16994353
9 -1.13623371 1.66519615
10 0.89572320 -1.13623371
11 2.54361152 0.89572320
12 0.68567372 2.54361152
13 1.96813220 0.68567372
14 -0.08830916 1.96813220
15 0.43000908 -0.08830916
16 -3.73946945 0.43000908
17 0.49079672 -3.73946945
18 -7.40653586 0.49079672
19 2.46459908 -7.40653586
20 0.85785829 2.46459908
21 0.14326462 0.85785829
22 0.03892035 0.14326462
23 -0.22342695 0.03892035
24 0.82733222 -0.22342695
25 1.12503606 0.82733222
26 -0.01158030 1.12503606
27 0.98900413 -0.01158030
28 5.16829446 0.98900413
29 2.93264095 5.16829446
30 5.43534362 2.93264095
31 -1.44246765 5.43534362
32 -4.94460974 -1.44246765
33 3.07530556 -4.94460974
34 -0.46503859 3.07530556
35 1.08046546 -0.46503859
36 1.26046045 1.08046546
37 -2.21329633 1.26046045
38 -1.92319901 -2.21329633
39 0.06359787 -1.92319901
40 -1.80327806 0.06359787
41 4.11245078 -1.80327806
42 0.57841121 4.11245078
43 -0.48114288 0.57841121
44 -1.87398829 -0.48114288
45 -2.82570634 -1.87398829
46 -0.04633550 -2.82570634
47 -3.40065003 -0.04633550
48 1.66082066 -3.40065003
49 1.89728986 1.66082066
50 2.10031640 1.89728986
51 0.18682198 2.10031640
52 0.62018739 0.18682198
53 -8.65481657 0.62018739
54 -0.09106577 -8.65481657
55 -1.71093208 -0.09106577
56 4.29554359 -1.71093208
57 0.74336987 4.29554359
58 -0.42326946 0.74336987
59 NA -0.42326946
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -2.77716178 -4.43428704
[2,] -0.07722792 -2.77716178
[3,] -1.66943306 -0.07722792
[4,] -0.24573435 -1.66943306
[5,] 1.11892812 -0.24573435
[6,] 1.48384680 1.11892812
[7,] 1.16994353 1.48384680
[8,] 1.66519615 1.16994353
[9,] -1.13623371 1.66519615
[10,] 0.89572320 -1.13623371
[11,] 2.54361152 0.89572320
[12,] 0.68567372 2.54361152
[13,] 1.96813220 0.68567372
[14,] -0.08830916 1.96813220
[15,] 0.43000908 -0.08830916
[16,] -3.73946945 0.43000908
[17,] 0.49079672 -3.73946945
[18,] -7.40653586 0.49079672
[19,] 2.46459908 -7.40653586
[20,] 0.85785829 2.46459908
[21,] 0.14326462 0.85785829
[22,] 0.03892035 0.14326462
[23,] -0.22342695 0.03892035
[24,] 0.82733222 -0.22342695
[25,] 1.12503606 0.82733222
[26,] -0.01158030 1.12503606
[27,] 0.98900413 -0.01158030
[28,] 5.16829446 0.98900413
[29,] 2.93264095 5.16829446
[30,] 5.43534362 2.93264095
[31,] -1.44246765 5.43534362
[32,] -4.94460974 -1.44246765
[33,] 3.07530556 -4.94460974
[34,] -0.46503859 3.07530556
[35,] 1.08046546 -0.46503859
[36,] 1.26046045 1.08046546
[37,] -2.21329633 1.26046045
[38,] -1.92319901 -2.21329633
[39,] 0.06359787 -1.92319901
[40,] -1.80327806 0.06359787
[41,] 4.11245078 -1.80327806
[42,] 0.57841121 4.11245078
[43,] -0.48114288 0.57841121
[44,] -1.87398829 -0.48114288
[45,] -2.82570634 -1.87398829
[46,] -0.04633550 -2.82570634
[47,] -3.40065003 -0.04633550
[48,] 1.66082066 -3.40065003
[49,] 1.89728986 1.66082066
[50,] 2.10031640 1.89728986
[51,] 0.18682198 2.10031640
[52,] 0.62018739 0.18682198
[53,] -8.65481657 0.62018739
[54,] -0.09106577 -8.65481657
[55,] -1.71093208 -0.09106577
[56,] 4.29554359 -1.71093208
[57,] 0.74336987 4.29554359
[58,] -0.42326946 0.74336987
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -2.77716178 -4.43428704
2 -0.07722792 -2.77716178
3 -1.66943306 -0.07722792
4 -0.24573435 -1.66943306
5 1.11892812 -0.24573435
6 1.48384680 1.11892812
7 1.16994353 1.48384680
8 1.66519615 1.16994353
9 -1.13623371 1.66519615
10 0.89572320 -1.13623371
11 2.54361152 0.89572320
12 0.68567372 2.54361152
13 1.96813220 0.68567372
14 -0.08830916 1.96813220
15 0.43000908 -0.08830916
16 -3.73946945 0.43000908
17 0.49079672 -3.73946945
18 -7.40653586 0.49079672
19 2.46459908 -7.40653586
20 0.85785829 2.46459908
21 0.14326462 0.85785829
22 0.03892035 0.14326462
23 -0.22342695 0.03892035
24 0.82733222 -0.22342695
25 1.12503606 0.82733222
26 -0.01158030 1.12503606
27 0.98900413 -0.01158030
28 5.16829446 0.98900413
29 2.93264095 5.16829446
30 5.43534362 2.93264095
31 -1.44246765 5.43534362
32 -4.94460974 -1.44246765
33 3.07530556 -4.94460974
34 -0.46503859 3.07530556
35 1.08046546 -0.46503859
36 1.26046045 1.08046546
37 -2.21329633 1.26046045
38 -1.92319901 -2.21329633
39 0.06359787 -1.92319901
40 -1.80327806 0.06359787
41 4.11245078 -1.80327806
42 0.57841121 4.11245078
43 -0.48114288 0.57841121
44 -1.87398829 -0.48114288
45 -2.82570634 -1.87398829
46 -0.04633550 -2.82570634
47 -3.40065003 -0.04633550
48 1.66082066 -3.40065003
49 1.89728986 1.66082066
50 2.10031640 1.89728986
51 0.18682198 2.10031640
52 0.62018739 0.18682198
53 -8.65481657 0.62018739
54 -0.09106577 -8.65481657
55 -1.71093208 -0.09106577
56 4.29554359 -1.71093208
57 0.74336987 4.29554359
58 -0.42326946 0.74336987
> 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/7fyq51258761692.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/8z06k1258761692.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/9bnjt1258761692.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/10u20i1258761692.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/11vpki1258761692.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/12dn2u1258761692.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/131qus1258761692.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/14fgee1258761692.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/151y9f1258761692.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/168nrz1258761692.tab")
+ }
>
> system("convert tmp/118y51258761692.ps tmp/118y51258761692.png")
> system("convert tmp/2r5eq1258761692.ps tmp/2r5eq1258761692.png")
> system("convert tmp/3e8zm1258761692.ps tmp/3e8zm1258761692.png")
> system("convert tmp/4ivyr1258761692.ps tmp/4ivyr1258761692.png")
> system("convert tmp/5xiev1258761692.ps tmp/5xiev1258761692.png")
> system("convert tmp/6j2q81258761692.ps tmp/6j2q81258761692.png")
> system("convert tmp/7fyq51258761692.ps tmp/7fyq51258761692.png")
> system("convert tmp/8z06k1258761692.ps tmp/8z06k1258761692.png")
> system("convert tmp/9bnjt1258761692.ps tmp/9bnjt1258761692.png")
> system("convert tmp/10u20i1258761692.ps tmp/10u20i1258761692.png")
>
>
> proc.time()
user system elapsed
2.411 1.569 2.874