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(1.6
+ ,0.55
+ ,1.6
+ ,1.6
+ ,1.59
+ ,1.58
+ ,1.6
+ ,0.56
+ ,1.6
+ ,1.6
+ ,1.6
+ ,1.59
+ ,1.61
+ ,0.56
+ ,1.6
+ ,1.6
+ ,1.6
+ ,1.6
+ ,1.61
+ ,0.56
+ ,1.61
+ ,1.6
+ ,1.6
+ ,1.6
+ ,1.62
+ ,0.56
+ ,1.61
+ ,1.61
+ ,1.6
+ ,1.6
+ ,1.63
+ ,0.56
+ ,1.62
+ ,1.61
+ ,1.61
+ ,1.6
+ ,1.63
+ ,0.55
+ ,1.63
+ ,1.62
+ ,1.61
+ ,1.61
+ ,1.63
+ ,0.56
+ ,1.63
+ ,1.63
+ ,1.62
+ ,1.61
+ ,1.63
+ ,0.55
+ ,1.63
+ ,1.63
+ ,1.63
+ ,1.62
+ ,1.63
+ ,0.55
+ ,1.63
+ ,1.63
+ ,1.63
+ ,1.63
+ ,1.64
+ ,0.56
+ ,1.63
+ ,1.63
+ ,1.63
+ ,1.63
+ ,1.64
+ ,0.55
+ ,1.64
+ ,1.63
+ ,1.63
+ ,1.63
+ ,1.64
+ ,0.55
+ ,1.64
+ ,1.64
+ ,1.63
+ ,1.63
+ ,1.65
+ ,0.55
+ ,1.64
+ ,1.64
+ ,1.64
+ ,1.63
+ ,1.65
+ ,0.55
+ ,1.65
+ ,1.64
+ ,1.64
+ ,1.64
+ ,1.65
+ ,0.53
+ ,1.65
+ ,1.65
+ ,1.64
+ ,1.64
+ ,1.65
+ ,0.53
+ ,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A,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 1.60 0.55 1.60 1.60 1.59 1.58 1 0 0 0 0 0 0 0 0 0 0 1
2 1.60 0.56 1.60 1.60 1.60 1.59 0 1 0 0 0 0 0 0 0 0 0 2
3 1.61 0.56 1.60 1.60 1.60 1.60 0 0 1 0 0 0 0 0 0 0 0 3
4 1.61 0.56 1.61 1.60 1.60 1.60 0 0 0 1 0 0 0 0 0 0 0 4
5 1.62 0.56 1.61 1.61 1.60 1.60 0 0 0 0 1 0 0 0 0 0 0 5
6 1.63 0.56 1.62 1.61 1.61 1.60 0 0 0 0 0 1 0 0 0 0 0 6
7 1.63 0.55 1.63 1.62 1.61 1.61 0 0 0 0 0 0 1 0 0 0 0 7
8 1.63 0.56 1.63 1.63 1.62 1.61 0 0 0 0 0 0 0 1 0 0 0 8
9 1.63 0.55 1.63 1.63 1.63 1.62 0 0 0 0 0 0 0 0 1 0 0 9
10 1.63 0.55 1.63 1.63 1.63 1.63 0 0 0 0 0 0 0 0 0 1 0 10
11 1.64 0.56 1.63 1.63 1.63 1.63 0 0 0 0 0 0 0 0 0 0 1 11
12 1.64 0.55 1.64 1.63 1.63 1.63 0 0 0 0 0 0 0 0 0 0 0 12
13 1.64 0.55 1.64 1.64 1.63 1.63 1 0 0 0 0 0 0 0 0 0 0 13
14 1.65 0.55 1.64 1.64 1.64 1.63 0 1 0 0 0 0 0 0 0 0 0 14
15 1.65 0.55 1.65 1.64 1.64 1.64 0 0 1 0 0 0 0 0 0 0 0 15
16 1.65 0.53 1.65 1.65 1.64 1.64 0 0 0 1 0 0 0 0 0 0 0 16
17 1.65 0.53 1.65 1.65 1.65 1.64 0 0 0 0 1 0 0 0 0 0 0 17
18 1.65 0.53 1.65 1.65 1.65 1.65 0 0 0 0 0 1 0 0 0 0 0 18
19 1.66 0.53 1.65 1.65 1.65 1.65 0 0 0 0 0 0 1 0 0 0 0 19
20 1.67 0.54 1.66 1.65 1.65 1.65 0 0 0 0 0 0 0 1 0 0 0 20
21 1.68 0.54 1.67 1.66 1.65 1.65 0 0 0 0 0 0 0 0 1 0 0 21
22 1.68 0.54 1.68 1.67 1.66 1.65 0 0 0 0 0 0 0 0 0 1 0 22
23 1.68 0.55 1.68 1.68 1.67 1.66 0 0 0 0 0 0 0 0 0 0 1 23
24 1.68 0.55 1.68 1.68 1.68 1.67 0 0 0 0 0 0 0 0 0 0 0 24
25 1.69 0.54 1.68 1.68 1.68 1.68 1 0 0 0 0 0 0 0 0 0 0 25
26 1.70 0.55 1.69 1.68 1.68 1.68 0 1 0 0 0 0 0 0 0 0 0 26
27 1.70 0.56 1.70 1.69 1.68 1.68 0 0 1 0 0 0 0 0 0 0 0 27
28 1.71 0.58 1.70 1.70 1.69 1.68 0 0 0 1 0 0 0 0 0 0 0 28
29 1.73 0.59 1.71 1.70 1.70 1.69 0 0 0 0 1 0 0 0 0 0 0 29
30 1.73 0.60 1.73 1.71 1.70 1.70 0 0 0 0 0 1 0 0 0 0 0 30
31 1.73 0.60 1.73 1.73 1.71 1.70 0 0 0 0 0 0 1 0 0 0 0 31
32 1.74 0.60 1.73 1.73 1.73 1.71 0 0 0 0 0 0 0 1 0 0 0 32
33 1.74 0.59 1.74 1.73 1.73 1.73 0 0 0 0 0 0 0 0 1 0 0 33
34 1.74 0.60 1.74 1.74 1.73 1.73 0 0 0 0 0 0 0 0 0 1 0 34
35 1.75 0.60 1.74 1.74 1.74 1.73 0 0 0 0 0 0 0 0 0 0 1 35
36 1.78 0.62 1.75 1.74 1.74 1.74 0 0 0 0 0 0 0 0 0 0 0 36
37 1.82 0.65 1.78 1.75 1.74 1.74 1 0 0 0 0 0 0 0 0 0 0 37
38 1.83 0.68 1.82 1.78 1.75 1.74 0 1 0 0 0 0 0 0 0 0 0 38
39 1.84 0.73 1.83 1.82 1.78 1.75 0 0 1 0 0 0 0 0 0 0 0 39
40 1.85 0.78 1.84 1.83 1.82 1.78 0 0 0 1 0 0 0 0 0 0 0 40
41 1.86 0.78 1.85 1.84 1.83 1.82 0 0 0 0 1 0 0 0 0 0 0 41
42 1.86 0.82 1.86 1.85 1.84 1.83 0 0 0 0 0 1 0 0 0 0 0 42
43 1.87 0.82 1.86 1.86 1.85 1.84 0 0 0 0 0 0 1 0 0 0 0 43
44 1.87 0.81 1.87 1.86 1.86 1.85 0 0 0 0 0 0 0 1 0 0 0 44
45 1.87 0.83 1.87 1.87 1.86 1.86 0 0 0 0 0 0 0 0 1 0 0 45
46 1.87 0.85 1.87 1.87 1.87 1.86 0 0 0 0 0 0 0 0 0 1 0 46
47 1.87 0.86 1.87 1.87 1.87 1.87 0 0 0 0 0 0 0 0 0 0 1 47
48 1.87 0.85 1.87 1.87 1.87 1.87 0 0 0 0 0 0 0 0 0 0 0 48
49 1.87 0.85 1.87 1.87 1.87 1.87 1 0 0 0 0 0 0 0 0 0 0 49
50 1.88 0.82 1.87 1.87 1.87 1.87 0 1 0 0 0 0 0 0 0 0 0 50
51 1.88 0.80 1.88 1.87 1.87 1.87 0 0 1 0 0 0 0 0 0 0 0 51
52 1.87 0.81 1.88 1.88 1.87 1.87 0 0 0 1 0 0 0 0 0 0 0 52
53 1.87 0.80 1.87 1.88 1.88 1.87 0 0 0 0 1 0 0 0 0 0 0 53
54 1.87 0.80 1.87 1.87 1.88 1.88 0 0 0 0 0 1 0 0 0 0 0 54
55 1.87 0.80 1.87 1.87 1.87 1.88 0 0 0 0 0 0 1 0 0 0 0 55
56 1.87 0.80 1.87 1.87 1.87 1.87 0 0 0 0 0 0 0 1 0 0 0 56
57 1.87 0.79 1.87 1.87 1.87 1.87 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
0.3730410 0.0731322 1.4286129 -0.7940162 0.4413340 -0.3346070
M1 M2 M3 M4 M5 M6
0.0035822 -0.0012779 -0.0030587 -0.0047711 0.0022964 -0.0064310
M7 M8 M9 M10 M11 t
0.0005992 -0.0036016 -0.0032663 -0.0046961 0.0001401 0.0010667
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.0088738 -0.0049010 -0.0000618 0.0037854 0.0190253
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.3730410 0.2481064 1.504 0.14075
X 0.0731322 0.0708758 1.032 0.30851
Y1 1.4286129 0.1562046 9.146 3.01e-11 ***
Y2 -0.7940162 0.2684369 -2.958 0.00524 **
Y3 0.4413340 0.2643739 1.669 0.10306
Y4 -0.3346070 0.1610399 -2.078 0.04436 *
M1 0.0035822 0.0050449 0.710 0.48188
M2 -0.0012779 0.0050224 -0.254 0.80050
M3 -0.0030587 0.0051162 -0.598 0.55339
M4 -0.0047711 0.0051142 -0.933 0.35661
M5 0.0022964 0.0050259 0.457 0.65026
M6 -0.0064310 0.0049596 -1.297 0.20236
M7 0.0005992 0.0051814 0.116 0.90852
M8 -0.0036016 0.0049821 -0.723 0.47405
M9 -0.0032663 0.0050120 -0.652 0.51842
M10 -0.0046961 0.0053142 -0.884 0.38228
M11 0.0001401 0.0052784 0.027 0.97896
t 0.0010667 0.0006451 1.654 0.10622
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.007344 on 39 degrees of freedom
Multiple R-squared: 0.9964, Adjusted R-squared: 0.9948
F-statistic: 626.9 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.205748964 0.411497929 0.7942510
[2,] 0.155010020 0.310020040 0.8449900
[3,] 0.103805505 0.207611009 0.8961945
[4,] 0.072149606 0.144299213 0.9278504
[5,] 0.105339142 0.210678284 0.8946609
[6,] 0.056588198 0.113176395 0.9434118
[7,] 0.043015360 0.086030720 0.9569846
[8,] 0.024427670 0.048855339 0.9755723
[9,] 0.013523384 0.027046769 0.9864766
[10,] 0.011142266 0.022284533 0.9888577
[11,] 0.008419711 0.016839421 0.9915803
[12,] 0.004538124 0.009076248 0.9954619
[13,] 0.013913541 0.027827082 0.9860865
[14,] 0.022820556 0.045641111 0.9771794
[15,] 0.070768816 0.141537631 0.9292312
[16,] 0.877724233 0.244551535 0.1222758
> postscript(file="/var/www/html/rcomp/tmp/1jjx41258718336.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/2jq5c1258718336.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/36f171258718336.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/4dza11258718336.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/5sp3e1258718336.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.309570e-03 -4.314811e-03 9.745421e-03 -3.895101e-03 5.910824e-03
6 7 8 9 10
4.872028e-03 -5.493475e-03 4.361665e-04 -1.301847e-03 2.407305e-03
11 12 13 14 15
5.773069e-03 -8.708373e-03 -5.417159e-03 3.962852e-03 -6.263046e-03
16 17 18 19 20
3.785369e-03 -8.762208e-03 2.244535e-03 4.147607e-03 2.264298e-03
21 22 23 24 25
4.516265e-03 -5.879961e-03 -5.641306e-03 -7.635212e-03 1.793233e-03
26 27 28 29 30
5.691327e-04 -5.793995e-03 6.915789e-03 2.696830e-03 -7.659845e-03
31 32 33 34 35
-4.289790e-03 3.363741e-03 -4.900991e-03 2.670930e-03 2.354676e-03
36 37 38 39 40
1.902534e-02 1.726420e-02 -8.873793e-03 5.764324e-03 -1.207800e-03
41 42 43 44 45
3.282935e-03 6.050812e-04 9.381045e-03 -2.106891e-03 6.314631e-03
46 47 48 49 50
8.017270e-04 -2.486439e-03 -2.681752e-03 -7.330699e-03 8.656619e-03
51 52 53 54 55
-3.452703e-03 -5.598256e-03 -3.128381e-03 -6.179951e-05 -3.745387e-03
56 57
-3.957315e-03 -4.628058e-03
> postscript(file="/var/www/html/rcomp/tmp/6i96e1258718336.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 -6.309570e-03 NA
1 -4.314811e-03 -6.309570e-03
2 9.745421e-03 -4.314811e-03
3 -3.895101e-03 9.745421e-03
4 5.910824e-03 -3.895101e-03
5 4.872028e-03 5.910824e-03
6 -5.493475e-03 4.872028e-03
7 4.361665e-04 -5.493475e-03
8 -1.301847e-03 4.361665e-04
9 2.407305e-03 -1.301847e-03
10 5.773069e-03 2.407305e-03
11 -8.708373e-03 5.773069e-03
12 -5.417159e-03 -8.708373e-03
13 3.962852e-03 -5.417159e-03
14 -6.263046e-03 3.962852e-03
15 3.785369e-03 -6.263046e-03
16 -8.762208e-03 3.785369e-03
17 2.244535e-03 -8.762208e-03
18 4.147607e-03 2.244535e-03
19 2.264298e-03 4.147607e-03
20 4.516265e-03 2.264298e-03
21 -5.879961e-03 4.516265e-03
22 -5.641306e-03 -5.879961e-03
23 -7.635212e-03 -5.641306e-03
24 1.793233e-03 -7.635212e-03
25 5.691327e-04 1.793233e-03
26 -5.793995e-03 5.691327e-04
27 6.915789e-03 -5.793995e-03
28 2.696830e-03 6.915789e-03
29 -7.659845e-03 2.696830e-03
30 -4.289790e-03 -7.659845e-03
31 3.363741e-03 -4.289790e-03
32 -4.900991e-03 3.363741e-03
33 2.670930e-03 -4.900991e-03
34 2.354676e-03 2.670930e-03
35 1.902534e-02 2.354676e-03
36 1.726420e-02 1.902534e-02
37 -8.873793e-03 1.726420e-02
38 5.764324e-03 -8.873793e-03
39 -1.207800e-03 5.764324e-03
40 3.282935e-03 -1.207800e-03
41 6.050812e-04 3.282935e-03
42 9.381045e-03 6.050812e-04
43 -2.106891e-03 9.381045e-03
44 6.314631e-03 -2.106891e-03
45 8.017270e-04 6.314631e-03
46 -2.486439e-03 8.017270e-04
47 -2.681752e-03 -2.486439e-03
48 -7.330699e-03 -2.681752e-03
49 8.656619e-03 -7.330699e-03
50 -3.452703e-03 8.656619e-03
51 -5.598256e-03 -3.452703e-03
52 -3.128381e-03 -5.598256e-03
53 -6.179951e-05 -3.128381e-03
54 -3.745387e-03 -6.179951e-05
55 -3.957315e-03 -3.745387e-03
56 -4.628058e-03 -3.957315e-03
57 NA -4.628058e-03
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -4.314811e-03 -6.309570e-03
[2,] 9.745421e-03 -4.314811e-03
[3,] -3.895101e-03 9.745421e-03
[4,] 5.910824e-03 -3.895101e-03
[5,] 4.872028e-03 5.910824e-03
[6,] -5.493475e-03 4.872028e-03
[7,] 4.361665e-04 -5.493475e-03
[8,] -1.301847e-03 4.361665e-04
[9,] 2.407305e-03 -1.301847e-03
[10,] 5.773069e-03 2.407305e-03
[11,] -8.708373e-03 5.773069e-03
[12,] -5.417159e-03 -8.708373e-03
[13,] 3.962852e-03 -5.417159e-03
[14,] -6.263046e-03 3.962852e-03
[15,] 3.785369e-03 -6.263046e-03
[16,] -8.762208e-03 3.785369e-03
[17,] 2.244535e-03 -8.762208e-03
[18,] 4.147607e-03 2.244535e-03
[19,] 2.264298e-03 4.147607e-03
[20,] 4.516265e-03 2.264298e-03
[21,] -5.879961e-03 4.516265e-03
[22,] -5.641306e-03 -5.879961e-03
[23,] -7.635212e-03 -5.641306e-03
[24,] 1.793233e-03 -7.635212e-03
[25,] 5.691327e-04 1.793233e-03
[26,] -5.793995e-03 5.691327e-04
[27,] 6.915789e-03 -5.793995e-03
[28,] 2.696830e-03 6.915789e-03
[29,] -7.659845e-03 2.696830e-03
[30,] -4.289790e-03 -7.659845e-03
[31,] 3.363741e-03 -4.289790e-03
[32,] -4.900991e-03 3.363741e-03
[33,] 2.670930e-03 -4.900991e-03
[34,] 2.354676e-03 2.670930e-03
[35,] 1.902534e-02 2.354676e-03
[36,] 1.726420e-02 1.902534e-02
[37,] -8.873793e-03 1.726420e-02
[38,] 5.764324e-03 -8.873793e-03
[39,] -1.207800e-03 5.764324e-03
[40,] 3.282935e-03 -1.207800e-03
[41,] 6.050812e-04 3.282935e-03
[42,] 9.381045e-03 6.050812e-04
[43,] -2.106891e-03 9.381045e-03
[44,] 6.314631e-03 -2.106891e-03
[45,] 8.017270e-04 6.314631e-03
[46,] -2.486439e-03 8.017270e-04
[47,] -2.681752e-03 -2.486439e-03
[48,] -7.330699e-03 -2.681752e-03
[49,] 8.656619e-03 -7.330699e-03
[50,] -3.452703e-03 8.656619e-03
[51,] -5.598256e-03 -3.452703e-03
[52,] -3.128381e-03 -5.598256e-03
[53,] -6.179951e-05 -3.128381e-03
[54,] -3.745387e-03 -6.179951e-05
[55,] -3.957315e-03 -3.745387e-03
[56,] -4.628058e-03 -3.957315e-03
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -4.314811e-03 -6.309570e-03
2 9.745421e-03 -4.314811e-03
3 -3.895101e-03 9.745421e-03
4 5.910824e-03 -3.895101e-03
5 4.872028e-03 5.910824e-03
6 -5.493475e-03 4.872028e-03
7 4.361665e-04 -5.493475e-03
8 -1.301847e-03 4.361665e-04
9 2.407305e-03 -1.301847e-03
10 5.773069e-03 2.407305e-03
11 -8.708373e-03 5.773069e-03
12 -5.417159e-03 -8.708373e-03
13 3.962852e-03 -5.417159e-03
14 -6.263046e-03 3.962852e-03
15 3.785369e-03 -6.263046e-03
16 -8.762208e-03 3.785369e-03
17 2.244535e-03 -8.762208e-03
18 4.147607e-03 2.244535e-03
19 2.264298e-03 4.147607e-03
20 4.516265e-03 2.264298e-03
21 -5.879961e-03 4.516265e-03
22 -5.641306e-03 -5.879961e-03
23 -7.635212e-03 -5.641306e-03
24 1.793233e-03 -7.635212e-03
25 5.691327e-04 1.793233e-03
26 -5.793995e-03 5.691327e-04
27 6.915789e-03 -5.793995e-03
28 2.696830e-03 6.915789e-03
29 -7.659845e-03 2.696830e-03
30 -4.289790e-03 -7.659845e-03
31 3.363741e-03 -4.289790e-03
32 -4.900991e-03 3.363741e-03
33 2.670930e-03 -4.900991e-03
34 2.354676e-03 2.670930e-03
35 1.902534e-02 2.354676e-03
36 1.726420e-02 1.902534e-02
37 -8.873793e-03 1.726420e-02
38 5.764324e-03 -8.873793e-03
39 -1.207800e-03 5.764324e-03
40 3.282935e-03 -1.207800e-03
41 6.050812e-04 3.282935e-03
42 9.381045e-03 6.050812e-04
43 -2.106891e-03 9.381045e-03
44 6.314631e-03 -2.106891e-03
45 8.017270e-04 6.314631e-03
46 -2.486439e-03 8.017270e-04
47 -2.681752e-03 -2.486439e-03
48 -7.330699e-03 -2.681752e-03
49 8.656619e-03 -7.330699e-03
50 -3.452703e-03 8.656619e-03
51 -5.598256e-03 -3.452703e-03
52 -3.128381e-03 -5.598256e-03
53 -6.179951e-05 -3.128381e-03
54 -3.745387e-03 -6.179951e-05
55 -3.957315e-03 -3.745387e-03
56 -4.628058e-03 -3.957315e-03
> 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/7oi7t1258718336.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/83lij1258718336.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/9hl3q1258718336.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/10f0ms1258718336.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/11gtvm1258718336.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/12d5jr1258718336.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/13jv1e1258718336.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/14m34b1258718336.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/15q5ok1258718336.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/16rf0e1258718336.tab")
+ }
>
> system("convert tmp/1jjx41258718336.ps tmp/1jjx41258718336.png")
> system("convert tmp/2jq5c1258718336.ps tmp/2jq5c1258718336.png")
> system("convert tmp/36f171258718336.ps tmp/36f171258718336.png")
> system("convert tmp/4dza11258718336.ps tmp/4dza11258718336.png")
> system("convert tmp/5sp3e1258718336.ps tmp/5sp3e1258718336.png")
> system("convert tmp/6i96e1258718336.ps tmp/6i96e1258718336.png")
> system("convert tmp/7oi7t1258718336.ps tmp/7oi7t1258718336.png")
> system("convert tmp/83lij1258718336.ps tmp/83lij1258718336.png")
> system("convert tmp/9hl3q1258718336.ps tmp/9hl3q1258718336.png")
> system("convert tmp/10f0ms1258718336.ps tmp/10f0ms1258718336.png")
>
>
> proc.time()
user system elapsed
2.300 1.585 2.726