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(900.1
+ ,880.4
+ ,849.4
+ ,819.3
+ ,785.8
+ ,937.2
+ ,900.1
+ ,880.4
+ ,849.4
+ ,819.3
+ ,948.9
+ ,937.2
+ ,900.1
+ ,880.4
+ ,849.4
+ ,952.6
+ ,948.9
+ ,937.2
+ ,900.1
+ ,880.4
+ ,947.3
+ ,952.6
+ ,948.9
+ ,937.2
+ ,900.1
+ ,974.2
+ ,947.3
+ ,952.6
+ ,948.9
+ ,937.2
+ ,1000.8
+ ,974.2
+ ,947.3
+ ,952.6
+ ,948.9
+ ,1032.8
+ ,1000.8
+ ,974.2
+ ,947.3
+ ,952.6
+ ,1050.7
+ ,1032.8
+ ,1000.8
+ ,974.2
+ ,947.3
+ ,1057.3
+ ,1050.7
+ ,1032.8
+ ,1000.8
+ ,974.2
+ ,1075.4
+ ,1057.3
+ ,1050.7
+ ,1032.8
+ ,1000.8
+ ,1118.4
+ ,1075.4
+ ,1057.3
+ ,1050.7
+ ,1032.8
+ ,1179.8
+ ,1118.4
+ ,1075.4
+ ,1057.3
+ ,1050.7
+ ,1227
+ ,1179.8
+ ,1118.4
+ ,1075.4
+ ,1057.3
+ ,1257.8
+ ,1227
+ ,1179.8
+ ,1118.4
+ ,1075.4
+ ,1251.5
+ ,1257.8
+ ,1227
+ ,1179.8
+ ,1118.4
+ ,1236.3
+ ,1251.5
+ ,1257.8
+ ,1227
+ ,1179.8
+ ,1170.6
+ ,1236.3
+ ,1251.5
+ ,1257.8
+ ,1227
+ ,1213.1
+ ,1170.6
+ ,1236.3
+ ,1251.5
+ ,1257.8
+ ,1265.5
+ ,1213.1
+ ,1170.6
+ ,1236.3
+ ,1251.5
+ ,1300.8
+ ,1265.5
+ ,1213.1
+ ,1170.6
+ ,1236.3
+ ,1348.4
+ ,1300.8
+ ,1265.5
+ ,1213.1
+ ,1170.6
+ ,1371.9
+ ,1348.4
+ ,1300.8
+ ,1265.5
+ ,1213.1
+ ,1403.3
+ ,1371.9
+ ,1348.4
+ ,1300.8
+ ,1265.5
+ ,1451.8
+ ,1403.3
+ ,1371.9
+ ,1348.4
+ ,1300.8
+ ,1474.2
+ ,1451.8
+ ,1403.3
+ ,1371.9
+ ,1348.4
+ ,1438.2
+ ,1474.2
+ ,1451.8
+ ,1403.3
+ ,1371.9
+ ,1513.6
+ ,1438.2
+ ,1474.2
+ ,1451.8
+ ,1403.3
+ ,1562.2
+ ,1513.6
+ ,1438.2
+ ,1474.2
+ ,1451.8
+ ,1546.2
+ ,1562.2
+ ,1513.6
+ ,1438.2
+ ,1474.2
+ ,1527.5
+ ,1546.2
+ ,1562.2
+ ,1513.6
+ ,1438.2
+ ,1418.7
+ ,1527.5
+ ,1546.2
+ ,1562.2
+ ,1513.6
+ ,1448.5
+ ,1418.7
+ ,1527.5
+ ,1546.2
+ ,1562.2
+ ,1492.1
+ ,1448.5
+ ,1418.7
+ ,1527.5
+ ,1546.2
+ ,1395.4
+ ,1492.1
+ ,1448.5
+ ,1418.7
+ ,1527.5
+ ,1403.7
+ ,1395.4
+ ,1492.1
+ ,1448.5
+ ,1418.7
+ ,1316.6
+ ,1403.7
+ ,1395.4
+ ,1492.1
+ ,1448.5
+ ,1274.5
+ ,1316.6
+ ,1403.7
+ ,1395.4
+ ,1492.1
+ ,1264.4
+ ,1274.5
+ ,1316.6
+ ,1403.7
+ ,1395.4
+ ,1323.9
+ ,1264.4
+ ,1274.5
+ ,1316.6
+ ,1403.7
+ ,1332.1
+ ,1323.9
+ ,1264.4
+ ,1274.5
+ ,1316.6
+ ,1250.2
+ ,1332.1
+ ,1323.9
+ ,1264.4
+ ,1274.5
+ ,1096.7
+ ,1250.2
+ ,1332.1
+ ,1323.9
+ ,1264.4
+ ,1080.8
+ ,1096.7
+ ,1250.2
+ ,1332.1
+ ,1323.9
+ ,1039.2
+ ,1080.8
+ ,1096.7
+ ,1250.2
+ ,1332.1
+ ,792
+ ,1039.2
+ ,1080.8
+ ,1096.7
+ ,1250.2
+ ,746.6
+ ,792
+ ,1039.2
+ ,1080.8
+ ,1096.7
+ ,688.8
+ ,746.6
+ ,792
+ ,1039.2
+ ,1080.8
+ ,715.8
+ ,688.8
+ ,746.6
+ ,792
+ ,1039.2
+ ,672.9
+ ,715.8
+ ,688.8
+ ,746.6
+ ,792
+ ,629.5
+ ,672.9
+ ,715.8
+ ,688.8
+ ,746.6
+ ,681.2
+ ,629.5
+ ,672.9
+ ,715.8
+ ,688.8
+ ,755.4
+ ,681.2
+ ,629.5
+ ,672.9
+ ,715.8
+ ,760.6
+ ,755.4
+ ,681.2
+ ,629.5
+ ,672.9
+ ,765.9
+ ,760.6
+ ,755.4
+ ,681.2
+ ,629.5
+ ,836.8
+ ,765.9
+ ,760.6
+ ,755.4
+ ,681.2
+ ,904.9
+ ,836.8
+ ,765.9
+ ,760.6
+ ,755.4)
+ ,dim=c(5
+ ,57)
+ ,dimnames=list(c('Y'
+ ,'Y1'
+ ,'Y2'
+ ,'Y3'
+ ,'Y4')
+ ,1:57))
> y <- array(NA,dim=c(5,57),dimnames=list(c('Y','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 Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 900.1 880.4 849.4 819.3 785.8 1 0 0 0 0 0 0 0 0 0 0 1
2 937.2 900.1 880.4 849.4 819.3 0 1 0 0 0 0 0 0 0 0 0 2
3 948.9 937.2 900.1 880.4 849.4 0 0 1 0 0 0 0 0 0 0 0 3
4 952.6 948.9 937.2 900.1 880.4 0 0 0 1 0 0 0 0 0 0 0 4
5 947.3 952.6 948.9 937.2 900.1 0 0 0 0 1 0 0 0 0 0 0 5
6 974.2 947.3 952.6 948.9 937.2 0 0 0 0 0 1 0 0 0 0 0 6
7 1000.8 974.2 947.3 952.6 948.9 0 0 0 0 0 0 1 0 0 0 0 7
8 1032.8 1000.8 974.2 947.3 952.6 0 0 0 0 0 0 0 1 0 0 0 8
9 1050.7 1032.8 1000.8 974.2 947.3 0 0 0 0 0 0 0 0 1 0 0 9
10 1057.3 1050.7 1032.8 1000.8 974.2 0 0 0 0 0 0 0 0 0 1 0 10
11 1075.4 1057.3 1050.7 1032.8 1000.8 0 0 0 0 0 0 0 0 0 0 1 11
12 1118.4 1075.4 1057.3 1050.7 1032.8 0 0 0 0 0 0 0 0 0 0 0 12
13 1179.8 1118.4 1075.4 1057.3 1050.7 1 0 0 0 0 0 0 0 0 0 0 13
14 1227.0 1179.8 1118.4 1075.4 1057.3 0 1 0 0 0 0 0 0 0 0 0 14
15 1257.8 1227.0 1179.8 1118.4 1075.4 0 0 1 0 0 0 0 0 0 0 0 15
16 1251.5 1257.8 1227.0 1179.8 1118.4 0 0 0 1 0 0 0 0 0 0 0 16
17 1236.3 1251.5 1257.8 1227.0 1179.8 0 0 0 0 1 0 0 0 0 0 0 17
18 1170.6 1236.3 1251.5 1257.8 1227.0 0 0 0 0 0 1 0 0 0 0 0 18
19 1213.1 1170.6 1236.3 1251.5 1257.8 0 0 0 0 0 0 1 0 0 0 0 19
20 1265.5 1213.1 1170.6 1236.3 1251.5 0 0 0 0 0 0 0 1 0 0 0 20
21 1300.8 1265.5 1213.1 1170.6 1236.3 0 0 0 0 0 0 0 0 1 0 0 21
22 1348.4 1300.8 1265.5 1213.1 1170.6 0 0 0 0 0 0 0 0 0 1 0 22
23 1371.9 1348.4 1300.8 1265.5 1213.1 0 0 0 0 0 0 0 0 0 0 1 23
24 1403.3 1371.9 1348.4 1300.8 1265.5 0 0 0 0 0 0 0 0 0 0 0 24
25 1451.8 1403.3 1371.9 1348.4 1300.8 1 0 0 0 0 0 0 0 0 0 0 25
26 1474.2 1451.8 1403.3 1371.9 1348.4 0 1 0 0 0 0 0 0 0 0 0 26
27 1438.2 1474.2 1451.8 1403.3 1371.9 0 0 1 0 0 0 0 0 0 0 0 27
28 1513.6 1438.2 1474.2 1451.8 1403.3 0 0 0 1 0 0 0 0 0 0 0 28
29 1562.2 1513.6 1438.2 1474.2 1451.8 0 0 0 0 1 0 0 0 0 0 0 29
30 1546.2 1562.2 1513.6 1438.2 1474.2 0 0 0 0 0 1 0 0 0 0 0 30
31 1527.5 1546.2 1562.2 1513.6 1438.2 0 0 0 0 0 0 1 0 0 0 0 31
32 1418.7 1527.5 1546.2 1562.2 1513.6 0 0 0 0 0 0 0 1 0 0 0 32
33 1448.5 1418.7 1527.5 1546.2 1562.2 0 0 0 0 0 0 0 0 1 0 0 33
34 1492.1 1448.5 1418.7 1527.5 1546.2 0 0 0 0 0 0 0 0 0 1 0 34
35 1395.4 1492.1 1448.5 1418.7 1527.5 0 0 0 0 0 0 0 0 0 0 1 35
36 1403.7 1395.4 1492.1 1448.5 1418.7 0 0 0 0 0 0 0 0 0 0 0 36
37 1316.6 1403.7 1395.4 1492.1 1448.5 1 0 0 0 0 0 0 0 0 0 0 37
38 1274.5 1316.6 1403.7 1395.4 1492.1 0 1 0 0 0 0 0 0 0 0 0 38
39 1264.4 1274.5 1316.6 1403.7 1395.4 0 0 1 0 0 0 0 0 0 0 0 39
40 1323.9 1264.4 1274.5 1316.6 1403.7 0 0 0 1 0 0 0 0 0 0 0 40
41 1332.1 1323.9 1264.4 1274.5 1316.6 0 0 0 0 1 0 0 0 0 0 0 41
42 1250.2 1332.1 1323.9 1264.4 1274.5 0 0 0 0 0 1 0 0 0 0 0 42
43 1096.7 1250.2 1332.1 1323.9 1264.4 0 0 0 0 0 0 1 0 0 0 0 43
44 1080.8 1096.7 1250.2 1332.1 1323.9 0 0 0 0 0 0 0 1 0 0 0 44
45 1039.2 1080.8 1096.7 1250.2 1332.1 0 0 0 0 0 0 0 0 1 0 0 45
46 792.0 1039.2 1080.8 1096.7 1250.2 0 0 0 0 0 0 0 0 0 1 0 46
47 746.6 792.0 1039.2 1080.8 1096.7 0 0 0 0 0 0 0 0 0 0 1 47
48 688.8 746.6 792.0 1039.2 1080.8 0 0 0 0 0 0 0 0 0 0 0 48
49 715.8 688.8 746.6 792.0 1039.2 1 0 0 0 0 0 0 0 0 0 0 49
50 672.9 715.8 688.8 746.6 792.0 0 1 0 0 0 0 0 0 0 0 0 50
51 629.5 672.9 715.8 688.8 746.6 0 0 1 0 0 0 0 0 0 0 0 51
52 681.2 629.5 672.9 715.8 688.8 0 0 0 1 0 0 0 0 0 0 0 52
53 755.4 681.2 629.5 672.9 715.8 0 0 0 0 1 0 0 0 0 0 0 53
54 760.6 755.4 681.2 629.5 672.9 0 0 0 0 0 1 0 0 0 0 0 54
55 765.9 760.6 755.4 681.2 629.5 0 0 0 0 0 0 1 0 0 0 0 55
56 836.8 765.9 760.6 755.4 681.2 0 0 0 0 0 0 0 1 0 0 0 56
57 904.9 836.8 765.9 760.6 755.4 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) Y1 Y2 Y3 Y4 M1
79.0512 1.2217 -0.1902 0.1011 -0.1776 -2.2514
M2 M3 M4 M5 M6 M7
-15.0136 -30.2560 19.8816 -2.2876 -46.4191 -34.5873
M8 M9 M10 M11 t
-4.8231 12.9111 -46.7887 -27.4272 -0.4472
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-172.49 -34.21 10.21 27.47 95.50
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 79.0512 49.9678 1.582 0.122
Y1 1.2217 0.1561 7.825 1.37e-09 ***
Y2 -0.1902 0.2477 -0.768 0.447
Y3 0.1011 0.2486 0.407 0.686
Y4 -0.1776 0.1615 -1.100 0.278
M1 -2.2514 40.1244 -0.056 0.956
M2 -15.0136 40.3927 -0.372 0.712
M3 -30.2560 39.9299 -0.758 0.453
M4 19.8816 39.6047 0.502 0.618
M5 -2.2876 40.2252 -0.057 0.955
M6 -46.4191 41.3460 -1.123 0.268
M7 -34.5873 40.3451 -0.857 0.396
M8 -4.8231 39.1841 -0.123 0.903
M9 12.9111 39.9483 0.323 0.748
M10 -46.7887 42.2515 -1.107 0.275
M11 -27.4272 42.2374 -0.649 0.520
t -0.4472 0.5558 -0.805 0.426
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 58.21 on 40 degrees of freedom
Multiple R-squared: 0.9661, Adjusted R-squared: 0.9525
F-statistic: 71.22 on 16 and 40 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,] 5.866430e-02 1.173286e-01 0.9413357
[2,] 1.810926e-02 3.621851e-02 0.9818907
[3,] 8.324878e-03 1.664976e-02 0.9916751
[4,] 2.277212e-03 4.554423e-03 0.9977228
[5,] 5.589880e-04 1.117976e-03 0.9994410
[6,] 1.379007e-04 2.758014e-04 0.9998621
[7,] 2.781542e-05 5.563084e-05 0.9999722
[8,] 5.126594e-05 1.025319e-04 0.9999487
[9,] 3.397628e-05 6.795256e-05 0.9999660
[10,] 6.020925e-05 1.204185e-04 0.9999398
[11,] 3.006802e-05 6.013604e-05 0.9999699
[12,] 8.825342e-06 1.765068e-05 0.9999912
[13,] 1.028359e-04 2.056719e-04 0.9998972
[14,] 3.859030e-05 7.718060e-05 0.9999614
[15,] 4.244405e-02 8.488811e-02 0.9575559
[16,] 2.878857e-01 5.757713e-01 0.7121143
[17,] 4.968646e-01 9.937292e-01 0.5031354
[18,] 4.485910e-01 8.971819e-01 0.5514090
> postscript(file="/var/www/html/rcomp/tmp/197w41258555729.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/2mxuw1258555729.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/3zgwo1258555729.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/4b3l91258555729.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/5nji71258555729.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
-33.514463 1.531883 -10.443665 -60.155895 -45.385341 38.679754
7 8 9 10 11 12
21.727334 -1.777240 -38.860107 14.194580 10.211943 9.249308
13 14 15 16 17 18
26.769772 19.688136 19.060480 -64.149081 -37.041961 -35.520802
19 20 21 22 23 24
79.077564 38.158573 4.179701 62.800515 18.199731 8.703399
25 26 27 28 29 30
27.468956 15.878089 -21.573068 53.053652 31.656599 22.820707
31 32 33 34 35 36
7.510501 -102.323120 49.805228 95.498456 -60.037121 25.375923
37 38 39 40 41 42
-86.673288 9.946096 32.385508 56.805844 1.793311 -40.685805
43 44 45 46 47 48
-111.761938 24.715262 -34.208314 -172.493551 31.625446 -43.328630
49 50 51 52 53 54
65.949023 -47.044204 -19.429256 14.445479 48.977392 14.706146
55 56 57
3.446539 41.226524 19.083492
> postscript(file="/var/www/html/rcomp/tmp/6pd451258555729.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 -33.514463 NA
1 1.531883 -33.514463
2 -10.443665 1.531883
3 -60.155895 -10.443665
4 -45.385341 -60.155895
5 38.679754 -45.385341
6 21.727334 38.679754
7 -1.777240 21.727334
8 -38.860107 -1.777240
9 14.194580 -38.860107
10 10.211943 14.194580
11 9.249308 10.211943
12 26.769772 9.249308
13 19.688136 26.769772
14 19.060480 19.688136
15 -64.149081 19.060480
16 -37.041961 -64.149081
17 -35.520802 -37.041961
18 79.077564 -35.520802
19 38.158573 79.077564
20 4.179701 38.158573
21 62.800515 4.179701
22 18.199731 62.800515
23 8.703399 18.199731
24 27.468956 8.703399
25 15.878089 27.468956
26 -21.573068 15.878089
27 53.053652 -21.573068
28 31.656599 53.053652
29 22.820707 31.656599
30 7.510501 22.820707
31 -102.323120 7.510501
32 49.805228 -102.323120
33 95.498456 49.805228
34 -60.037121 95.498456
35 25.375923 -60.037121
36 -86.673288 25.375923
37 9.946096 -86.673288
38 32.385508 9.946096
39 56.805844 32.385508
40 1.793311 56.805844
41 -40.685805 1.793311
42 -111.761938 -40.685805
43 24.715262 -111.761938
44 -34.208314 24.715262
45 -172.493551 -34.208314
46 31.625446 -172.493551
47 -43.328630 31.625446
48 65.949023 -43.328630
49 -47.044204 65.949023
50 -19.429256 -47.044204
51 14.445479 -19.429256
52 48.977392 14.445479
53 14.706146 48.977392
54 3.446539 14.706146
55 41.226524 3.446539
56 19.083492 41.226524
57 NA 19.083492
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.531883 -33.514463
[2,] -10.443665 1.531883
[3,] -60.155895 -10.443665
[4,] -45.385341 -60.155895
[5,] 38.679754 -45.385341
[6,] 21.727334 38.679754
[7,] -1.777240 21.727334
[8,] -38.860107 -1.777240
[9,] 14.194580 -38.860107
[10,] 10.211943 14.194580
[11,] 9.249308 10.211943
[12,] 26.769772 9.249308
[13,] 19.688136 26.769772
[14,] 19.060480 19.688136
[15,] -64.149081 19.060480
[16,] -37.041961 -64.149081
[17,] -35.520802 -37.041961
[18,] 79.077564 -35.520802
[19,] 38.158573 79.077564
[20,] 4.179701 38.158573
[21,] 62.800515 4.179701
[22,] 18.199731 62.800515
[23,] 8.703399 18.199731
[24,] 27.468956 8.703399
[25,] 15.878089 27.468956
[26,] -21.573068 15.878089
[27,] 53.053652 -21.573068
[28,] 31.656599 53.053652
[29,] 22.820707 31.656599
[30,] 7.510501 22.820707
[31,] -102.323120 7.510501
[32,] 49.805228 -102.323120
[33,] 95.498456 49.805228
[34,] -60.037121 95.498456
[35,] 25.375923 -60.037121
[36,] -86.673288 25.375923
[37,] 9.946096 -86.673288
[38,] 32.385508 9.946096
[39,] 56.805844 32.385508
[40,] 1.793311 56.805844
[41,] -40.685805 1.793311
[42,] -111.761938 -40.685805
[43,] 24.715262 -111.761938
[44,] -34.208314 24.715262
[45,] -172.493551 -34.208314
[46,] 31.625446 -172.493551
[47,] -43.328630 31.625446
[48,] 65.949023 -43.328630
[49,] -47.044204 65.949023
[50,] -19.429256 -47.044204
[51,] 14.445479 -19.429256
[52,] 48.977392 14.445479
[53,] 14.706146 48.977392
[54,] 3.446539 14.706146
[55,] 41.226524 3.446539
[56,] 19.083492 41.226524
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.531883 -33.514463
2 -10.443665 1.531883
3 -60.155895 -10.443665
4 -45.385341 -60.155895
5 38.679754 -45.385341
6 21.727334 38.679754
7 -1.777240 21.727334
8 -38.860107 -1.777240
9 14.194580 -38.860107
10 10.211943 14.194580
11 9.249308 10.211943
12 26.769772 9.249308
13 19.688136 26.769772
14 19.060480 19.688136
15 -64.149081 19.060480
16 -37.041961 -64.149081
17 -35.520802 -37.041961
18 79.077564 -35.520802
19 38.158573 79.077564
20 4.179701 38.158573
21 62.800515 4.179701
22 18.199731 62.800515
23 8.703399 18.199731
24 27.468956 8.703399
25 15.878089 27.468956
26 -21.573068 15.878089
27 53.053652 -21.573068
28 31.656599 53.053652
29 22.820707 31.656599
30 7.510501 22.820707
31 -102.323120 7.510501
32 49.805228 -102.323120
33 95.498456 49.805228
34 -60.037121 95.498456
35 25.375923 -60.037121
36 -86.673288 25.375923
37 9.946096 -86.673288
38 32.385508 9.946096
39 56.805844 32.385508
40 1.793311 56.805844
41 -40.685805 1.793311
42 -111.761938 -40.685805
43 24.715262 -111.761938
44 -34.208314 24.715262
45 -172.493551 -34.208314
46 31.625446 -172.493551
47 -43.328630 31.625446
48 65.949023 -43.328630
49 -47.044204 65.949023
50 -19.429256 -47.044204
51 14.445479 -19.429256
52 48.977392 14.445479
53 14.706146 48.977392
54 3.446539 14.706146
55 41.226524 3.446539
56 19.083492 41.226524
> 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/7rwnn1258555729.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/8r2v21258555729.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/9riuk1258555729.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/10eivw1258555729.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/116c411258555729.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/12nwxu1258555729.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/13zg6r1258555729.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/14sco61258555729.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/15bwwt1258555729.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/16w6ci1258555729.tab")
+ }
>
> system("convert tmp/197w41258555729.ps tmp/197w41258555729.png")
> system("convert tmp/2mxuw1258555729.ps tmp/2mxuw1258555729.png")
> system("convert tmp/3zgwo1258555729.ps tmp/3zgwo1258555729.png")
> system("convert tmp/4b3l91258555729.ps tmp/4b3l91258555729.png")
> system("convert tmp/5nji71258555729.ps tmp/5nji71258555729.png")
> system("convert tmp/6pd451258555729.ps tmp/6pd451258555729.png")
> system("convert tmp/7rwnn1258555729.ps tmp/7rwnn1258555729.png")
> system("convert tmp/8r2v21258555729.ps tmp/8r2v21258555729.png")
> system("convert tmp/9riuk1258555729.ps tmp/9riuk1258555729.png")
> system("convert tmp/10eivw1258555729.ps tmp/10eivw1258555729.png")
>
>
> proc.time()
user system elapsed
2.365 1.561 2.857