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(100.6
+ ,33.5
+ ,107.1
+ ,107
+ ,111.9
+ ,115.6
+ ,99.2
+ ,31.5
+ ,100.6
+ ,107.1
+ ,107
+ ,111.9
+ ,108.4
+ ,31.2
+ ,99.2
+ ,100.6
+ ,107.1
+ ,107
+ ,103
+ ,27
+ ,108.4
+ ,99.2
+ ,100.6
+ ,107.1
+ ,99.8
+ ,26.7
+ ,103
+ ,108.4
+ ,99.2
+ ,100.6
+ ,115
+ ,26.5
+ ,99.8
+ ,103
+ ,108.4
+ ,99.2
+ ,90.8
+ ,26
+ ,115
+ ,99.8
+ ,103
+ ,108.4
+ ,95.9
+ ,27.2
+ ,90.8
+ ,115
+ ,99.8
+ ,103
+ ,114.4
+ ,30.5
+ ,95.9
+ ,90.8
+ ,115
+ ,99.8
+ ,108.2
+ ,33.7
+ ,114.4
+ ,95.9
+ ,90.8
+ ,115
+ ,112.6
+ ,34.2
+ ,108.2
+ ,114.4
+ ,95.9
+ ,90.8
+ ,109.1
+ ,36.7
+ ,112.6
+ ,108.2
+ ,114.4
+ ,95.9
+ ,105
+ ,36.2
+ ,109.1
+ ,112.6
+ ,108.2
+ ,114.4
+ ,105
+ ,38.5
+ ,105
+ ,109.1
+ ,112.6
+ ,108.2
+ ,118.5
+ ,40
+ ,105
+ ,105
+ ,109.1
+ ,112.6
+ ,103.7
+ ,42.5
+ ,118.5
+ ,105
+ ,105
+ ,109.1
+ ,112.5
+ ,43.5
+ ,103.7
+ ,118.5
+ ,105
+ ,105
+ ,116.6
+ ,43.3
+ ,112.5
+ ,103.7
+ ,118.5
+ ,105
+ ,96.6
+ ,45.5
+ ,116.6
+ ,112.5
+ ,103.7
+ ,118.5
+ ,101.9
+ ,44.3
+ ,96.6
+ ,116.6
+ ,112.5
+ ,103.7
+ ,116.5
+ ,43
+ ,101.9
+ ,96.6
+ ,116.6
+ ,112.5
+ ,119.3
+ ,43.5
+ ,116.5
+ ,101.9
+ ,96.6
+ ,116.6
+ ,115.4
+ ,41.5
+ ,119.3
+ ,116.5
+ ,101.9
+ ,96.6
+ ,108.5
+ ,42.5
+ ,115.4
+ ,119.3
+ ,116.5
+ ,101.9
+ ,111.5
+ ,41.3
+ ,108.5
+ ,115.4
+ ,119.3
+ ,116.5
+ ,108.8
+ ,39.5
+ ,111.5
+ ,108.5
+ ,115.4
+ ,119.3
+ ,121.8
+ ,38.5
+ ,108.8
+ ,111.5
+ ,108.5
+ ,115.4
+ ,109.6
+ ,41
+ ,121.8
+ ,108.8
+ ,111.5
+ ,108.5
+ ,112.2
+ ,44.5
+ ,109.6
+ ,121.8
+ ,108.8
+ ,111.5
+ ,119.6
+ ,46
+ ,112.2
+ ,109.6
+ ,121.8
+ ,108.8
+ ,104.1
+ ,44
+ ,119.6
+ ,112.2
+ ,109.6
+ ,121.8
+ ,105.3
+ ,41.5
+ ,104.1
+ ,119.6
+ ,112.2
+ ,109.6
+ ,115
+ ,41.3
+ ,105.3
+ ,104.1
+ ,119.6
+ ,112.2
+ ,124.1
+ ,38
+ ,115
+ ,105.3
+ ,104.1
+ ,119.6
+ ,116.8
+ ,38
+ ,124.1
+ ,115
+ ,105.3
+ ,104.1
+ ,107.5
+ ,36.2
+ ,116.8
+ ,124.1
+ ,115
+ ,105.3
+ ,115.6
+ ,38.7
+ ,107.5
+ ,116.8
+ ,124.1
+ ,115
+ ,116.2
+ ,38.7
+ ,115.6
+ ,107.5
+ ,116.8
+ ,124.1
+ ,116.3
+ ,39.2
+ ,116.2
+ ,115.6
+ ,107.5
+ ,116.8
+ ,119
+ ,35.7
+ ,116.3
+ ,116.2
+ ,115.6
+ ,107.5
+ ,111.9
+ ,36.5
+ ,119
+ ,116.3
+ ,116.2
+ ,115.6
+ ,118.6
+ ,36.7
+ ,111.9
+ ,119
+ ,116.3
+ ,116.2
+ ,106.9
+ ,34.7
+ ,118.6
+ ,111.9
+ ,119
+ ,116.3
+ ,103.2
+ ,35
+ ,106.9
+ ,118.6
+ ,111.9
+ ,119
+ ,118.6
+ ,28.2
+ ,103.2
+ ,106.9
+ ,118.6
+ ,111.9
+ ,118.7
+ ,23.7
+ ,118.6
+ ,103.2
+ ,106.9
+ ,118.6
+ ,102.8
+ ,15
+ ,118.7
+ ,118.6
+ ,103.2
+ ,106.9
+ ,100.6
+ ,8.7
+ ,102.8
+ ,118.7
+ ,118.6
+ ,103.2
+ ,94.9
+ ,11
+ ,100.6
+ ,102.8
+ ,118.7
+ ,118.6
+ ,94.5
+ ,7.5
+ ,94.9
+ ,100.6
+ ,102.8
+ ,118.7
+ ,102.9
+ ,5.7
+ ,94.5
+ ,94.9
+ ,100.6
+ ,102.8
+ ,95.3
+ ,9.3
+ ,102.9
+ ,94.5
+ ,94.9
+ ,100.6
+ ,92.5
+ ,10.2
+ ,95.3
+ ,102.9
+ ,94.5
+ ,94.9
+ ,102.7
+ ,15.7
+ ,92.5
+ ,95.3
+ ,102.9
+ ,94.5
+ ,91.5
+ ,18.1
+ ,102.7
+ ,92.5
+ ,95.3
+ ,102.9
+ ,89.5
+ ,20.8
+ ,91.5
+ ,102.7
+ ,92.5
+ ,95.3)
+ ,dim=c(6
+ ,56)
+ ,dimnames=list(c('Ipzb'
+ ,'Cvn'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:56))
> y <- array(NA,dim=c(6,56),dimnames=list(c('Ipzb','Cvn','Y1','Y2','Y3','Y4'),1:56))
> 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
Ipzb Cvn Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 100.6 33.5 107.1 107.0 111.9 115.6 1 0 0 0 0 0 0 0 0 0 0 1
2 99.2 31.5 100.6 107.1 107.0 111.9 0 1 0 0 0 0 0 0 0 0 0 2
3 108.4 31.2 99.2 100.6 107.1 107.0 0 0 1 0 0 0 0 0 0 0 0 3
4 103.0 27.0 108.4 99.2 100.6 107.1 0 0 0 1 0 0 0 0 0 0 0 4
5 99.8 26.7 103.0 108.4 99.2 100.6 0 0 0 0 1 0 0 0 0 0 0 5
6 115.0 26.5 99.8 103.0 108.4 99.2 0 0 0 0 0 1 0 0 0 0 0 6
7 90.8 26.0 115.0 99.8 103.0 108.4 0 0 0 0 0 0 1 0 0 0 0 7
8 95.9 27.2 90.8 115.0 99.8 103.0 0 0 0 0 0 0 0 1 0 0 0 8
9 114.4 30.5 95.9 90.8 115.0 99.8 0 0 0 0 0 0 0 0 1 0 0 9
10 108.2 33.7 114.4 95.9 90.8 115.0 0 0 0 0 0 0 0 0 0 1 0 10
11 112.6 34.2 108.2 114.4 95.9 90.8 0 0 0 0 0 0 0 0 0 0 1 11
12 109.1 36.7 112.6 108.2 114.4 95.9 0 0 0 0 0 0 0 0 0 0 0 12
13 105.0 36.2 109.1 112.6 108.2 114.4 1 0 0 0 0 0 0 0 0 0 0 13
14 105.0 38.5 105.0 109.1 112.6 108.2 0 1 0 0 0 0 0 0 0 0 0 14
15 118.5 40.0 105.0 105.0 109.1 112.6 0 0 1 0 0 0 0 0 0 0 0 15
16 103.7 42.5 118.5 105.0 105.0 109.1 0 0 0 1 0 0 0 0 0 0 0 16
17 112.5 43.5 103.7 118.5 105.0 105.0 0 0 0 0 1 0 0 0 0 0 0 17
18 116.6 43.3 112.5 103.7 118.5 105.0 0 0 0 0 0 1 0 0 0 0 0 18
19 96.6 45.5 116.6 112.5 103.7 118.5 0 0 0 0 0 0 1 0 0 0 0 19
20 101.9 44.3 96.6 116.6 112.5 103.7 0 0 0 0 0 0 0 1 0 0 0 20
21 116.5 43.0 101.9 96.6 116.6 112.5 0 0 0 0 0 0 0 0 1 0 0 21
22 119.3 43.5 116.5 101.9 96.6 116.6 0 0 0 0 0 0 0 0 0 1 0 22
23 115.4 41.5 119.3 116.5 101.9 96.6 0 0 0 0 0 0 0 0 0 0 1 23
24 108.5 42.5 115.4 119.3 116.5 101.9 0 0 0 0 0 0 0 0 0 0 0 24
25 111.5 41.3 108.5 115.4 119.3 116.5 1 0 0 0 0 0 0 0 0 0 0 25
26 108.8 39.5 111.5 108.5 115.4 119.3 0 1 0 0 0 0 0 0 0 0 0 26
27 121.8 38.5 108.8 111.5 108.5 115.4 0 0 1 0 0 0 0 0 0 0 0 27
28 109.6 41.0 121.8 108.8 111.5 108.5 0 0 0 1 0 0 0 0 0 0 0 28
29 112.2 44.5 109.6 121.8 108.8 111.5 0 0 0 0 1 0 0 0 0 0 0 29
30 119.6 46.0 112.2 109.6 121.8 108.8 0 0 0 0 0 1 0 0 0 0 0 30
31 104.1 44.0 119.6 112.2 109.6 121.8 0 0 0 0 0 0 1 0 0 0 0 31
32 105.3 41.5 104.1 119.6 112.2 109.6 0 0 0 0 0 0 0 1 0 0 0 32
33 115.0 41.3 105.3 104.1 119.6 112.2 0 0 0 0 0 0 0 0 1 0 0 33
34 124.1 38.0 115.0 105.3 104.1 119.6 0 0 0 0 0 0 0 0 0 1 0 34
35 116.8 38.0 124.1 115.0 105.3 104.1 0 0 0 0 0 0 0 0 0 0 1 35
36 107.5 36.2 116.8 124.1 115.0 105.3 0 0 0 0 0 0 0 0 0 0 0 36
37 115.6 38.7 107.5 116.8 124.1 115.0 1 0 0 0 0 0 0 0 0 0 0 37
38 116.2 38.7 115.6 107.5 116.8 124.1 0 1 0 0 0 0 0 0 0 0 0 38
39 116.3 39.2 116.2 115.6 107.5 116.8 0 0 1 0 0 0 0 0 0 0 0 39
40 119.0 35.7 116.3 116.2 115.6 107.5 0 0 0 1 0 0 0 0 0 0 0 40
41 111.9 36.5 119.0 116.3 116.2 115.6 0 0 0 0 1 0 0 0 0 0 0 41
42 118.6 36.7 111.9 119.0 116.3 116.2 0 0 0 0 0 1 0 0 0 0 0 42
43 106.9 34.7 118.6 111.9 119.0 116.3 0 0 0 0 0 0 1 0 0 0 0 43
44 103.2 35.0 106.9 118.6 111.9 119.0 0 0 0 0 0 0 0 1 0 0 0 44
45 118.6 28.2 103.2 106.9 118.6 111.9 0 0 0 0 0 0 0 0 1 0 0 45
46 118.7 23.7 118.6 103.2 106.9 118.6 0 0 0 0 0 0 0 0 0 1 0 46
47 102.8 15.0 118.7 118.6 103.2 106.9 0 0 0 0 0 0 0 0 0 0 1 47
48 100.6 8.7 102.8 118.7 118.6 103.2 0 0 0 0 0 0 0 0 0 0 0 48
49 94.9 11.0 100.6 102.8 118.7 118.6 1 0 0 0 0 0 0 0 0 0 0 49
50 94.5 7.5 94.9 100.6 102.8 118.7 0 1 0 0 0 0 0 0 0 0 0 50
51 102.9 5.7 94.5 94.9 100.6 102.8 0 0 1 0 0 0 0 0 0 0 0 51
52 95.3 9.3 102.9 94.5 94.9 100.6 0 0 0 1 0 0 0 0 0 0 0 52
53 92.5 10.2 95.3 102.9 94.5 94.9 0 0 0 0 1 0 0 0 0 0 0 53
54 102.7 15.7 92.5 95.3 102.9 94.5 0 0 0 0 0 1 0 0 0 0 0 54
55 91.5 18.1 102.7 92.5 95.3 102.9 0 0 0 0 0 0 1 0 0 0 0 55
56 89.5 20.8 91.5 102.7 92.5 95.3 0 0 0 0 0 0 0 1 0 0 0 56
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Cvn Y1 Y2 Y3 Y4
37.97506 0.35753 -0.09722 0.21067 0.47171 -0.13087
M1 M2 M3 M4 M5 M6
1.65160 4.63924 14.96930 8.32261 5.13880 10.57303
M7 M8 M9 M10 M11 t
-0.42494 -3.60595 11.35181 23.61351 12.59209 0.06611
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-4.7012 -1.9130 0.2836 2.0664 6.9746
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 37.97506 13.72346 2.767 0.008687 **
Cvn 0.35753 0.08781 4.072 0.000228 ***
Y1 -0.09722 0.16469 -0.590 0.558458
Y2 0.21067 0.12872 1.637 0.109947
Y3 0.47171 0.11861 3.977 0.000302 ***
Y4 -0.13087 0.14891 -0.879 0.384992
M1 1.65160 3.92617 0.421 0.676370
M2 4.63924 4.30983 1.076 0.288520
M3 14.96930 3.83804 3.900 0.000379 ***
M4 8.32261 3.12185 2.666 0.011212 *
M5 5.13880 2.93558 1.751 0.088099 .
M6 10.57303 3.22602 3.277 0.002244 **
M7 -0.42494 3.68264 -0.115 0.908743
M8 -3.60595 3.74980 -0.962 0.342311
M9 11.35181 4.79950 2.365 0.023227 *
M10 23.61351 4.66452 5.062 1.09e-05 ***
M11 12.59209 3.19512 3.941 0.000336 ***
t 0.06611 0.03815 1.733 0.091241 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.324 on 38 degrees of freedom
Multiple R-squared: 0.9047, Adjusted R-squared: 0.8621
F-statistic: 21.23 on 17 and 38 DF, p-value: 2.393e-14
> 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.4637905 0.9275810 0.5362095
[2,] 0.3586807 0.7173615 0.6413193
[3,] 0.3362951 0.6725902 0.6637049
[4,] 0.5876014 0.8247972 0.4123986
[5,] 0.6260523 0.7478954 0.3739477
[6,] 0.5080864 0.9838272 0.4919136
[7,] 0.6612360 0.6775281 0.3387640
[8,] 0.5509283 0.8981435 0.4490717
[9,] 0.4247529 0.8495059 0.5752471
[10,] 0.3967147 0.7934294 0.6032853
[11,] 0.3078515 0.6157031 0.6921485
[12,] 0.2766973 0.5533945 0.7233027
[13,] 0.6321536 0.7356928 0.3678464
[14,] 0.5696356 0.8607288 0.4303644
[15,] 0.4013140 0.8026280 0.5986860
> postscript(file="/var/www/html/rcomp/tmp/1996f1258728794.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/2j8s11258728794.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/3x51t1258728794.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/43mez1258728794.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/57c311258728794.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 = 56
Frequency = 1
1 2 3 4 5 6 7
-0.8547245 -3.4192991 -3.9633859 2.9874194 0.3588992 6.4336344 -0.7525193
8 9 10 11 12 13 14
2.2810399 2.5826990 -2.9603364 2.1431532 3.9500921 2.3896281 -4.0346260
15 16 17 18 19 20 21
1.6235009 -4.7012358 2.0393517 -1.6840208 -4.2459466 -4.2982202 -0.3108852
22 23 24 25 26 27 28
0.2562321 0.1055032 -1.7884500 0.6635901 -0.4951869 4.3160473 -2.6825876
29 30 31 32 33 34 35
-0.4748890 -2.7740976 1.0007198 0.3203866 -4.7002543 2.2220032 2.1239693
36 37 38 39 40 41 42
-1.0519119 2.0471888 6.9746314 -1.7168754 3.6604136 0.4105674 0.3109658
43 44 45 46 47 48 49
1.1445352 1.6056273 2.4284406 0.4821011 -4.3726256 -1.1097302 -4.2456825
50 51 52 53 54 55 56
0.9744805 -0.2592868 0.7359903 -2.3339293 -2.2864817 2.8532109 0.0911664
> postscript(file="/var/www/html/rcomp/tmp/63srb1258728794.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 = 56
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.8547245 NA
1 -3.4192991 -0.8547245
2 -3.9633859 -3.4192991
3 2.9874194 -3.9633859
4 0.3588992 2.9874194
5 6.4336344 0.3588992
6 -0.7525193 6.4336344
7 2.2810399 -0.7525193
8 2.5826990 2.2810399
9 -2.9603364 2.5826990
10 2.1431532 -2.9603364
11 3.9500921 2.1431532
12 2.3896281 3.9500921
13 -4.0346260 2.3896281
14 1.6235009 -4.0346260
15 -4.7012358 1.6235009
16 2.0393517 -4.7012358
17 -1.6840208 2.0393517
18 -4.2459466 -1.6840208
19 -4.2982202 -4.2459466
20 -0.3108852 -4.2982202
21 0.2562321 -0.3108852
22 0.1055032 0.2562321
23 -1.7884500 0.1055032
24 0.6635901 -1.7884500
25 -0.4951869 0.6635901
26 4.3160473 -0.4951869
27 -2.6825876 4.3160473
28 -0.4748890 -2.6825876
29 -2.7740976 -0.4748890
30 1.0007198 -2.7740976
31 0.3203866 1.0007198
32 -4.7002543 0.3203866
33 2.2220032 -4.7002543
34 2.1239693 2.2220032
35 -1.0519119 2.1239693
36 2.0471888 -1.0519119
37 6.9746314 2.0471888
38 -1.7168754 6.9746314
39 3.6604136 -1.7168754
40 0.4105674 3.6604136
41 0.3109658 0.4105674
42 1.1445352 0.3109658
43 1.6056273 1.1445352
44 2.4284406 1.6056273
45 0.4821011 2.4284406
46 -4.3726256 0.4821011
47 -1.1097302 -4.3726256
48 -4.2456825 -1.1097302
49 0.9744805 -4.2456825
50 -0.2592868 0.9744805
51 0.7359903 -0.2592868
52 -2.3339293 0.7359903
53 -2.2864817 -2.3339293
54 2.8532109 -2.2864817
55 0.0911664 2.8532109
56 NA 0.0911664
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -3.4192991 -0.8547245
[2,] -3.9633859 -3.4192991
[3,] 2.9874194 -3.9633859
[4,] 0.3588992 2.9874194
[5,] 6.4336344 0.3588992
[6,] -0.7525193 6.4336344
[7,] 2.2810399 -0.7525193
[8,] 2.5826990 2.2810399
[9,] -2.9603364 2.5826990
[10,] 2.1431532 -2.9603364
[11,] 3.9500921 2.1431532
[12,] 2.3896281 3.9500921
[13,] -4.0346260 2.3896281
[14,] 1.6235009 -4.0346260
[15,] -4.7012358 1.6235009
[16,] 2.0393517 -4.7012358
[17,] -1.6840208 2.0393517
[18,] -4.2459466 -1.6840208
[19,] -4.2982202 -4.2459466
[20,] -0.3108852 -4.2982202
[21,] 0.2562321 -0.3108852
[22,] 0.1055032 0.2562321
[23,] -1.7884500 0.1055032
[24,] 0.6635901 -1.7884500
[25,] -0.4951869 0.6635901
[26,] 4.3160473 -0.4951869
[27,] -2.6825876 4.3160473
[28,] -0.4748890 -2.6825876
[29,] -2.7740976 -0.4748890
[30,] 1.0007198 -2.7740976
[31,] 0.3203866 1.0007198
[32,] -4.7002543 0.3203866
[33,] 2.2220032 -4.7002543
[34,] 2.1239693 2.2220032
[35,] -1.0519119 2.1239693
[36,] 2.0471888 -1.0519119
[37,] 6.9746314 2.0471888
[38,] -1.7168754 6.9746314
[39,] 3.6604136 -1.7168754
[40,] 0.4105674 3.6604136
[41,] 0.3109658 0.4105674
[42,] 1.1445352 0.3109658
[43,] 1.6056273 1.1445352
[44,] 2.4284406 1.6056273
[45,] 0.4821011 2.4284406
[46,] -4.3726256 0.4821011
[47,] -1.1097302 -4.3726256
[48,] -4.2456825 -1.1097302
[49,] 0.9744805 -4.2456825
[50,] -0.2592868 0.9744805
[51,] 0.7359903 -0.2592868
[52,] -2.3339293 0.7359903
[53,] -2.2864817 -2.3339293
[54,] 2.8532109 -2.2864817
[55,] 0.0911664 2.8532109
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -3.4192991 -0.8547245
2 -3.9633859 -3.4192991
3 2.9874194 -3.9633859
4 0.3588992 2.9874194
5 6.4336344 0.3588992
6 -0.7525193 6.4336344
7 2.2810399 -0.7525193
8 2.5826990 2.2810399
9 -2.9603364 2.5826990
10 2.1431532 -2.9603364
11 3.9500921 2.1431532
12 2.3896281 3.9500921
13 -4.0346260 2.3896281
14 1.6235009 -4.0346260
15 -4.7012358 1.6235009
16 2.0393517 -4.7012358
17 -1.6840208 2.0393517
18 -4.2459466 -1.6840208
19 -4.2982202 -4.2459466
20 -0.3108852 -4.2982202
21 0.2562321 -0.3108852
22 0.1055032 0.2562321
23 -1.7884500 0.1055032
24 0.6635901 -1.7884500
25 -0.4951869 0.6635901
26 4.3160473 -0.4951869
27 -2.6825876 4.3160473
28 -0.4748890 -2.6825876
29 -2.7740976 -0.4748890
30 1.0007198 -2.7740976
31 0.3203866 1.0007198
32 -4.7002543 0.3203866
33 2.2220032 -4.7002543
34 2.1239693 2.2220032
35 -1.0519119 2.1239693
36 2.0471888 -1.0519119
37 6.9746314 2.0471888
38 -1.7168754 6.9746314
39 3.6604136 -1.7168754
40 0.4105674 3.6604136
41 0.3109658 0.4105674
42 1.1445352 0.3109658
43 1.6056273 1.1445352
44 2.4284406 1.6056273
45 0.4821011 2.4284406
46 -4.3726256 0.4821011
47 -1.1097302 -4.3726256
48 -4.2456825 -1.1097302
49 0.9744805 -4.2456825
50 -0.2592868 0.9744805
51 0.7359903 -0.2592868
52 -2.3339293 0.7359903
53 -2.2864817 -2.3339293
54 2.8532109 -2.2864817
55 0.0911664 2.8532109
> 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/7mfe01258728794.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/888qw1258728794.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/9gno91258728794.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/10mq001258728794.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/11qy341258728794.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/128cmh1258728794.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/13sc0v1258728794.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/14wye31258728794.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/15dfcj1258728794.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/164jok1258728794.tab")
+ }
>
> system("convert tmp/1996f1258728794.ps tmp/1996f1258728794.png")
> system("convert tmp/2j8s11258728794.ps tmp/2j8s11258728794.png")
> system("convert tmp/3x51t1258728794.ps tmp/3x51t1258728794.png")
> system("convert tmp/43mez1258728794.ps tmp/43mez1258728794.png")
> system("convert tmp/57c311258728794.ps tmp/57c311258728794.png")
> system("convert tmp/63srb1258728794.ps tmp/63srb1258728794.png")
> system("convert tmp/7mfe01258728794.ps tmp/7mfe01258728794.png")
> system("convert tmp/888qw1258728794.ps tmp/888qw1258728794.png")
> system("convert tmp/9gno91258728794.ps tmp/9gno91258728794.png")
> system("convert tmp/10mq001258728794.ps tmp/10mq001258728794.png")
>
>
> proc.time()
user system elapsed
2.353 1.587 2.787