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(19
+ ,24.4
+ ,19
+ ,18
+ ,19
+ ,23
+ ,22
+ ,22.5
+ ,19
+ ,19
+ ,18
+ ,19
+ ,23
+ ,19.4
+ ,22
+ ,19
+ ,19
+ ,18
+ ,20
+ ,18.1
+ ,23
+ ,22
+ ,19
+ ,19
+ ,14
+ ,18.1
+ ,20
+ ,23
+ ,22
+ ,19
+ ,14
+ ,20.7
+ ,14
+ ,20
+ ,23
+ ,22
+ ,14
+ ,19.1
+ ,14
+ ,14
+ ,20
+ ,23
+ ,15
+ ,18.3
+ ,14
+ ,14
+ ,14
+ ,20
+ ,11
+ ,16.9
+ ,15
+ ,14
+ ,14
+ ,14
+ ,17
+ ,17.9
+ ,11
+ ,15
+ ,14
+ ,14
+ ,16
+ ,20.2
+ ,17
+ ,11
+ ,15
+ ,14
+ ,20
+ ,21.2
+ ,16
+ ,17
+ ,11
+ ,15
+ ,24
+ ,23.8
+ ,20
+ ,16
+ ,17
+ ,11
+ ,23
+ ,24
+ ,24
+ ,20
+ ,16
+ ,17
+ ,20
+ ,26.6
+ ,23
+ ,24
+ ,20
+ ,16
+ ,21
+ ,25.3
+ ,20
+ ,23
+ ,24
+ ,20
+ ,19
+ ,27.6
+ ,21
+ ,20
+ ,23
+ ,24
+ ,23
+ ,24.7
+ ,19
+ ,21
+ ,20
+ ,23
+ ,23
+ ,26.6
+ ,23
+ ,19
+ ,21
+ ,20
+ ,23
+ ,24.4
+ ,23
+ ,23
+ ,19
+ ,21
+ ,23
+ ,24.6
+ ,23
+ ,23
+ ,23
+ ,19
+ ,27
+ ,26
+ ,23
+ ,23
+ ,23
+ ,23
+ ,26
+ ,24.8
+ ,27
+ ,23
+ ,23
+ ,23
+ ,17
+ ,24
+ ,26
+ ,27
+ ,23
+ ,23
+ ,24
+ ,22.7
+ ,17
+ ,26
+ ,27
+ ,23
+ ,26
+ ,23
+ ,24
+ ,17
+ ,26
+ ,27
+ ,24
+ ,24.1
+ ,26
+ ,24
+ ,17
+ ,26
+ ,27
+ ,24
+ ,24
+ ,26
+ ,24
+ ,17
+ ,27
+ ,22.7
+ ,27
+ ,24
+ ,26
+ ,24
+ ,26
+ ,22.6
+ ,27
+ ,27
+ ,24
+ ,26
+ ,24
+ ,23.1
+ ,26
+ ,27
+ ,27
+ ,24
+ ,23
+ ,24.4
+ ,24
+ ,26
+ ,27
+ ,27
+ ,23
+ ,23
+ ,23
+ ,24
+ ,26
+ ,27
+ ,24
+ ,22
+ ,23
+ ,23
+ ,24
+ ,26
+ ,17
+ ,21.3
+ ,24
+ ,23
+ ,23
+ ,24
+ ,21
+ ,21.5
+ ,17
+ ,24
+ ,23
+ ,23
+ ,19
+ ,21.3
+ ,21
+ ,17
+ ,24
+ ,23
+ ,22
+ ,23.2
+ ,19
+ ,21
+ ,17
+ ,24
+ ,22
+ ,21.8
+ ,22
+ ,19
+ ,21
+ ,17
+ ,18
+ ,23.3
+ ,22
+ ,22
+ ,19
+ ,21
+ ,16
+ ,21
+ ,18
+ ,22
+ ,22
+ ,19
+ ,14
+ ,22.4
+ ,16
+ ,18
+ ,22
+ ,22
+ ,12
+ ,20.4
+ ,14
+ ,16
+ ,18
+ ,22
+ ,14
+ ,19.9
+ ,12
+ ,14
+ ,16
+ ,18
+ ,16
+ ,21.3
+ ,14
+ ,12
+ ,14
+ ,16
+ ,8
+ ,18.9
+ ,16
+ ,14
+ ,12
+ ,14
+ ,3
+ ,15.6
+ ,8
+ ,16
+ ,14
+ ,12
+ ,0
+ ,12.5
+ ,3
+ ,8
+ ,16
+ ,14
+ ,5
+ ,7.8
+ ,0
+ ,3
+ ,8
+ ,16
+ ,1
+ ,5.5
+ ,5
+ ,0
+ ,3
+ ,8
+ ,1
+ ,4
+ ,1
+ ,5
+ ,0
+ ,3
+ ,3
+ ,3.3
+ ,1
+ ,1
+ ,5
+ ,0
+ ,6
+ ,3.7
+ ,3
+ ,1
+ ,1
+ ,5
+ ,7
+ ,3.1
+ ,6
+ ,3
+ ,1
+ ,1
+ ,8
+ ,5
+ ,7
+ ,6
+ ,3
+ ,1
+ ,14
+ ,6.3
+ ,8
+ ,7
+ ,6
+ ,3
+ ,14
+ ,20
+ ,14
+ ,8
+ ,7
+ ,6)
+ ,dim=c(6
+ ,57)
+ ,dimnames=list(c('Y'
+ ,'X'
+ ,'Y(t-1)'
+ ,'Y(t-2)'
+ ,'Y(t-3)'
+ ,'Y(t-4)')
+ ,1:57))
> y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y(t-1)','Y(t-2)','Y(t-3)','Y(t-4)'),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 Y(t-1) Y(t-2) Y(t-3) Y(t-4) M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 19 24.4 19 18 19 23 1 0 0 0 0 0 0 0 0 0 0 1
2 22 22.5 19 19 18 19 0 1 0 0 0 0 0 0 0 0 0 2
3 23 19.4 22 19 19 18 0 0 1 0 0 0 0 0 0 0 0 3
4 20 18.1 23 22 19 19 0 0 0 1 0 0 0 0 0 0 0 4
5 14 18.1 20 23 22 19 0 0 0 0 1 0 0 0 0 0 0 5
6 14 20.7 14 20 23 22 0 0 0 0 0 1 0 0 0 0 0 6
7 14 19.1 14 14 20 23 0 0 0 0 0 0 1 0 0 0 0 7
8 15 18.3 14 14 14 20 0 0 0 0 0 0 0 1 0 0 0 8
9 11 16.9 15 14 14 14 0 0 0 0 0 0 0 0 1 0 0 9
10 17 17.9 11 15 14 14 0 0 0 0 0 0 0 0 0 1 0 10
11 16 20.2 17 11 15 14 0 0 0 0 0 0 0 0 0 0 1 11
12 20 21.2 16 17 11 15 0 0 0 0 0 0 0 0 0 0 0 12
13 24 23.8 20 16 17 11 1 0 0 0 0 0 0 0 0 0 0 13
14 23 24.0 24 20 16 17 0 1 0 0 0 0 0 0 0 0 0 14
15 20 26.6 23 24 20 16 0 0 1 0 0 0 0 0 0 0 0 15
16 21 25.3 20 23 24 20 0 0 0 1 0 0 0 0 0 0 0 16
17 19 27.6 21 20 23 24 0 0 0 0 1 0 0 0 0 0 0 17
18 23 24.7 19 21 20 23 0 0 0 0 0 1 0 0 0 0 0 18
19 23 26.6 23 19 21 20 0 0 0 0 0 0 1 0 0 0 0 19
20 23 24.4 23 23 19 21 0 0 0 0 0 0 0 1 0 0 0 20
21 23 24.6 23 23 23 19 0 0 0 0 0 0 0 0 1 0 0 21
22 27 26.0 23 23 23 23 0 0 0 0 0 0 0 0 0 1 0 22
23 26 24.8 27 23 23 23 0 0 0 0 0 0 0 0 0 0 1 23
24 17 24.0 26 27 23 23 0 0 0 0 0 0 0 0 0 0 0 24
25 24 22.7 17 26 27 23 1 0 0 0 0 0 0 0 0 0 0 25
26 26 23.0 24 17 26 27 0 1 0 0 0 0 0 0 0 0 0 26
27 24 24.1 26 24 17 26 0 0 1 0 0 0 0 0 0 0 0 27
28 27 24.0 24 26 24 17 0 0 0 1 0 0 0 0 0 0 0 28
29 27 22.7 27 24 26 24 0 0 0 0 1 0 0 0 0 0 0 29
30 26 22.6 27 27 24 26 0 0 0 0 0 1 0 0 0 0 0 30
31 24 23.1 26 27 27 24 0 0 0 0 0 0 1 0 0 0 0 31
32 23 24.4 24 26 27 27 0 0 0 0 0 0 0 1 0 0 0 32
33 23 23.0 23 24 26 27 0 0 0 0 0 0 0 0 1 0 0 33
34 24 22.0 23 23 24 26 0 0 0 0 0 0 0 0 0 1 0 34
35 17 21.3 24 23 23 24 0 0 0 0 0 0 0 0 0 0 1 35
36 21 21.5 17 24 23 23 0 0 0 0 0 0 0 0 0 0 0 36
37 19 21.3 21 17 24 23 1 0 0 0 0 0 0 0 0 0 0 37
38 22 23.2 19 21 17 24 0 1 0 0 0 0 0 0 0 0 0 38
39 22 21.8 22 19 21 17 0 0 1 0 0 0 0 0 0 0 0 39
40 18 23.3 22 22 19 21 0 0 0 1 0 0 0 0 0 0 0 40
41 16 21.0 18 22 22 19 0 0 0 0 1 0 0 0 0 0 0 41
42 14 22.4 16 18 22 22 0 0 0 0 0 1 0 0 0 0 0 42
43 12 20.4 14 16 18 22 0 0 0 0 0 0 1 0 0 0 0 43
44 14 19.9 12 14 16 18 0 0 0 0 0 0 0 1 0 0 0 44
45 16 21.3 14 12 14 16 0 0 0 0 0 0 0 0 1 0 0 45
46 8 18.9 16 14 12 14 0 0 0 0 0 0 0 0 0 1 0 46
47 3 15.6 8 16 14 12 0 0 0 0 0 0 0 0 0 0 1 47
48 0 12.5 3 8 16 14 0 0 0 0 0 0 0 0 0 0 0 48
49 5 7.8 0 3 8 16 1 0 0 0 0 0 0 0 0 0 0 49
50 1 5.5 5 0 3 8 0 1 0 0 0 0 0 0 0 0 0 50
51 1 4.0 1 5 0 3 0 0 1 0 0 0 0 0 0 0 0 51
52 3 3.3 1 1 5 0 0 0 0 1 0 0 0 0 0 0 0 52
53 6 3.7 3 1 1 5 0 0 0 0 1 0 0 0 0 0 0 53
54 7 3.1 6 3 1 1 0 0 0 0 0 1 0 0 0 0 0 54
55 8 5.0 7 6 3 1 0 0 0 0 0 0 1 0 0 0 0 55
56 14 6.3 8 7 6 3 0 0 0 0 0 0 0 1 0 0 0 56
57 14 20.0 14 8 7 6 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 `Y(t-1)` `Y(t-2)` `Y(t-3)` `Y(t-4)`
0.62534 0.13418 0.76399 0.07045 0.07822 -0.14700
M1 M2 M3 M4 M5 M6
3.86274 2.64053 0.87368 1.00749 0.22659 1.87144
M7 M8 M9 M10 M11 t
0.96486 3.12047 0.98894 2.26002 -1.84546 -0.02113
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-8.5403 -1.7919 0.4729 2.0154 5.1536
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.62534 3.09227 0.202 0.841
X 0.13418 0.18087 0.742 0.463
`Y(t-1)` 0.76399 0.16936 4.511 5.78e-05 ***
`Y(t-2)` 0.07045 0.20674 0.341 0.735
`Y(t-3)` 0.07822 0.20344 0.385 0.703
`Y(t-4)` -0.14700 0.16191 -0.908 0.370
M1 3.86274 2.44253 1.581 0.122
M2 2.64053 2.55431 1.034 0.308
M3 0.87368 2.45713 0.356 0.724
M4 1.00749 2.44392 0.412 0.682
M5 0.22659 2.42324 0.094 0.926
M6 1.87144 2.36880 0.790 0.434
M7 0.96486 2.42607 0.398 0.693
M8 3.12047 2.38082 1.311 0.198
M9 0.98894 2.48919 0.397 0.693
M10 2.26002 2.50530 0.902 0.373
M11 -1.84546 2.55418 -0.723 0.474
t -0.02113 0.03495 -0.605 0.549
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.48 on 39 degrees of freedom
Multiple R-squared: 0.8462, Adjusted R-squared: 0.7792
F-statistic: 12.62 on 17 and 39 DF, p-value: 6.128e-11
> 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.3730705 0.7461411 0.6269295
[2,] 0.3494747 0.6989493 0.6505253
[3,] 0.2720164 0.5440327 0.7279836
[4,] 0.7293197 0.5413607 0.2706803
[5,] 0.6953982 0.6092036 0.3046018
[6,] 0.6217227 0.7565547 0.3782773
[7,] 0.5299547 0.9400907 0.4700453
[8,] 0.4390548 0.8781095 0.5609452
[9,] 0.3830310 0.7660620 0.6169690
[10,] 0.2726054 0.5452108 0.7273946
[11,] 0.1789072 0.3578143 0.8210928
[12,] 0.1515897 0.3031794 0.8484103
[13,] 0.1985085 0.3970170 0.8014915
[14,] 0.1928820 0.3857640 0.8071180
[15,] 0.1589036 0.3178072 0.8410964
[16,] 0.1211535 0.2423071 0.8788465
> postscript(file="/var/www/html/rcomp/tmp/1d1d81258657352.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/22t341258657352.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/371nc1258657352.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/441m51258657352.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/5mew61258657352.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
-2.63011829 1.28794323 1.97466940 -1.79192013 -5.00302449 -1.81753709
7 8 9 10 11 12
0.12920627 -0.86958340 -4.17506471 3.42633728 1.86392436 4.70663716
13 14 15 16 17 18
0.47328332 -1.68775913 -3.22632305 0.47294431 -0.92007103 3.39053703
19 20 21 22 23 24
0.62900504 -1.18862458 0.33029901 3.48049077 3.71213051 -6.52264389
25 26 27 28 29 30
3.44366805 2.59902045 0.77532518 3.19259401 2.89050321 0.51930422
31 32 33 34 35 36
-0.38474875 -1.65423487 1.66937976 1.63350070 -2.12573633 5.15361817
37 38 39 40 41 42
-3.30224693 2.62693392 1.10978461 -2.67106216 -1.03311494 -2.59392264
43 44 45 46 47 48
-1.41607514 -0.24613537 2.19402650 -8.54032875 -3.45031854 -3.33761144
49 50 51 52 53 54
2.01541385 -4.82613847 -0.63345614 0.79744398 4.06570725 0.50161848
55 56 57
1.04261257 3.95857822 -0.01864056
> postscript(file="/var/www/html/rcomp/tmp/6mdtc1258657352.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 -2.63011829 NA
1 1.28794323 -2.63011829
2 1.97466940 1.28794323
3 -1.79192013 1.97466940
4 -5.00302449 -1.79192013
5 -1.81753709 -5.00302449
6 0.12920627 -1.81753709
7 -0.86958340 0.12920627
8 -4.17506471 -0.86958340
9 3.42633728 -4.17506471
10 1.86392436 3.42633728
11 4.70663716 1.86392436
12 0.47328332 4.70663716
13 -1.68775913 0.47328332
14 -3.22632305 -1.68775913
15 0.47294431 -3.22632305
16 -0.92007103 0.47294431
17 3.39053703 -0.92007103
18 0.62900504 3.39053703
19 -1.18862458 0.62900504
20 0.33029901 -1.18862458
21 3.48049077 0.33029901
22 3.71213051 3.48049077
23 -6.52264389 3.71213051
24 3.44366805 -6.52264389
25 2.59902045 3.44366805
26 0.77532518 2.59902045
27 3.19259401 0.77532518
28 2.89050321 3.19259401
29 0.51930422 2.89050321
30 -0.38474875 0.51930422
31 -1.65423487 -0.38474875
32 1.66937976 -1.65423487
33 1.63350070 1.66937976
34 -2.12573633 1.63350070
35 5.15361817 -2.12573633
36 -3.30224693 5.15361817
37 2.62693392 -3.30224693
38 1.10978461 2.62693392
39 -2.67106216 1.10978461
40 -1.03311494 -2.67106216
41 -2.59392264 -1.03311494
42 -1.41607514 -2.59392264
43 -0.24613537 -1.41607514
44 2.19402650 -0.24613537
45 -8.54032875 2.19402650
46 -3.45031854 -8.54032875
47 -3.33761144 -3.45031854
48 2.01541385 -3.33761144
49 -4.82613847 2.01541385
50 -0.63345614 -4.82613847
51 0.79744398 -0.63345614
52 4.06570725 0.79744398
53 0.50161848 4.06570725
54 1.04261257 0.50161848
55 3.95857822 1.04261257
56 -0.01864056 3.95857822
57 NA -0.01864056
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.28794323 -2.6301183
[2,] 1.97466940 1.2879432
[3,] -1.79192013 1.9746694
[4,] -5.00302449 -1.7919201
[5,] -1.81753709 -5.0030245
[6,] 0.12920627 -1.8175371
[7,] -0.86958340 0.1292063
[8,] -4.17506471 -0.8695834
[9,] 3.42633728 -4.1750647
[10,] 1.86392436 3.4263373
[11,] 4.70663716 1.8639244
[12,] 0.47328332 4.7066372
[13,] -1.68775913 0.4732833
[14,] -3.22632305 -1.6877591
[15,] 0.47294431 -3.2263231
[16,] -0.92007103 0.4729443
[17,] 3.39053703 -0.9200710
[18,] 0.62900504 3.3905370
[19,] -1.18862458 0.6290050
[20,] 0.33029901 -1.1886246
[21,] 3.48049077 0.3302990
[22,] 3.71213051 3.4804908
[23,] -6.52264389 3.7121305
[24,] 3.44366805 -6.5226439
[25,] 2.59902045 3.4436681
[26,] 0.77532518 2.5990205
[27,] 3.19259401 0.7753252
[28,] 2.89050321 3.1925940
[29,] 0.51930422 2.8905032
[30,] -0.38474875 0.5193042
[31,] -1.65423487 -0.3847487
[32,] 1.66937976 -1.6542349
[33,] 1.63350070 1.6693798
[34,] -2.12573633 1.6335007
[35,] 5.15361817 -2.1257363
[36,] -3.30224693 5.1536182
[37,] 2.62693392 -3.3022469
[38,] 1.10978461 2.6269339
[39,] -2.67106216 1.1097846
[40,] -1.03311494 -2.6710622
[41,] -2.59392264 -1.0331149
[42,] -1.41607514 -2.5939226
[43,] -0.24613537 -1.4160751
[44,] 2.19402650 -0.2461354
[45,] -8.54032875 2.1940265
[46,] -3.45031854 -8.5403287
[47,] -3.33761144 -3.4503185
[48,] 2.01541385 -3.3376114
[49,] -4.82613847 2.0154138
[50,] -0.63345614 -4.8261385
[51,] 0.79744398 -0.6334561
[52,] 4.06570725 0.7974440
[53,] 0.50161848 4.0657073
[54,] 1.04261257 0.5016185
[55,] 3.95857822 1.0426126
[56,] -0.01864056 3.9585782
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.28794323 -2.6301183
2 1.97466940 1.2879432
3 -1.79192013 1.9746694
4 -5.00302449 -1.7919201
5 -1.81753709 -5.0030245
6 0.12920627 -1.8175371
7 -0.86958340 0.1292063
8 -4.17506471 -0.8695834
9 3.42633728 -4.1750647
10 1.86392436 3.4263373
11 4.70663716 1.8639244
12 0.47328332 4.7066372
13 -1.68775913 0.4732833
14 -3.22632305 -1.6877591
15 0.47294431 -3.2263231
16 -0.92007103 0.4729443
17 3.39053703 -0.9200710
18 0.62900504 3.3905370
19 -1.18862458 0.6290050
20 0.33029901 -1.1886246
21 3.48049077 0.3302990
22 3.71213051 3.4804908
23 -6.52264389 3.7121305
24 3.44366805 -6.5226439
25 2.59902045 3.4436681
26 0.77532518 2.5990205
27 3.19259401 0.7753252
28 2.89050321 3.1925940
29 0.51930422 2.8905032
30 -0.38474875 0.5193042
31 -1.65423487 -0.3847487
32 1.66937976 -1.6542349
33 1.63350070 1.6693798
34 -2.12573633 1.6335007
35 5.15361817 -2.1257363
36 -3.30224693 5.1536182
37 2.62693392 -3.3022469
38 1.10978461 2.6269339
39 -2.67106216 1.1097846
40 -1.03311494 -2.6710622
41 -2.59392264 -1.0331149
42 -1.41607514 -2.5939226
43 -0.24613537 -1.4160751
44 2.19402650 -0.2461354
45 -8.54032875 2.1940265
46 -3.45031854 -8.5403287
47 -3.33761144 -3.4503185
48 2.01541385 -3.3376114
49 -4.82613847 2.0154138
50 -0.63345614 -4.8261385
51 0.79744398 -0.6334561
52 4.06570725 0.7974440
53 0.50161848 4.0657073
54 1.04261257 0.5016185
55 3.95857822 1.0426126
56 -0.01864056 3.9585782
> 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/70plc1258657352.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/8n91l1258657352.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/9o41y1258657352.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/10qs1q1258657352.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/1158ez1258657352.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/1254og1258657352.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/13glhl1258657352.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/140phm1258657352.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/15vukp1258657352.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/16u5fe1258657352.tab")
+ }
>
> system("convert tmp/1d1d81258657352.ps tmp/1d1d81258657352.png")
> system("convert tmp/22t341258657352.ps tmp/22t341258657352.png")
> system("convert tmp/371nc1258657352.ps tmp/371nc1258657352.png")
> system("convert tmp/441m51258657352.ps tmp/441m51258657352.png")
> system("convert tmp/5mew61258657352.ps tmp/5mew61258657352.png")
> system("convert tmp/6mdtc1258657352.ps tmp/6mdtc1258657352.png")
> system("convert tmp/70plc1258657352.ps tmp/70plc1258657352.png")
> system("convert tmp/8n91l1258657352.ps tmp/8n91l1258657352.png")
> system("convert tmp/9o41y1258657352.ps tmp/9o41y1258657352.png")
> system("convert tmp/10qs1q1258657352.ps tmp/10qs1q1258657352.png")
>
>
> proc.time()
user system elapsed
2.401 1.600 2.810