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(2360,8.1,2214,7.4,2825,7.3,2355,7.7,2333,8,3016,8,2155,7.7,2172,6.9,2150,6.6,2533,6.9,2058,7.5,2160,7.9,2260,7.7,2498,6.5,2695,6.1,2799,6.4,2947,6.8,2930,7.1,2318,7.3,2540,7.2,2570,7,2669,7,2450,7,2842,7.3,3440,7.5,2678,7.2,2981,7.7,2260,8,2844,7.9,2546,8,2456,8,2295,7.9,2379,7.9,2479,8,2057,8.1,2280,8.1,2351,8.2,2276,8,2548,8.3,2311,8.5,2201,8.6,2725,8.7,2408,8.7,2139,8.5,1898,8.4,2537,8.5,2069,8.7,2063,8.7,2524,8.6,2437,7.9,2189,8.1,2793,8.2,2074,8.5,2622,8.6,2278,8.5,2144,8.3,2427,8.2,2139,8.7,1828,9.3,2072,9.3,1800,8.8,1758,7.4,2246,7.2,1987,7.5,1868,8.3,2514,8.8,2121,8.9),dim=c(2,67),dimnames=list(c('Y','X'),1:67))
> y <- array(NA,dim=c(2,67),dimnames=list(c('Y','X'),1:67))
> for (i in 1:dim(x)[1])
+ {
+ for (j in 1:dim(x)[2])
+ {
+ y[i,j] <- as.numeric(x[i,j])
+ }
+ }
> par3 = 'No 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11
1 2360 8.1 1 0 0 0 0 0 0 0 0 0 0
2 2214 7.4 0 1 0 0 0 0 0 0 0 0 0
3 2825 7.3 0 0 1 0 0 0 0 0 0 0 0
4 2355 7.7 0 0 0 1 0 0 0 0 0 0 0
5 2333 8.0 0 0 0 0 1 0 0 0 0 0 0
6 3016 8.0 0 0 0 0 0 1 0 0 0 0 0
7 2155 7.7 0 0 0 0 0 0 1 0 0 0 0
8 2172 6.9 0 0 0 0 0 0 0 1 0 0 0
9 2150 6.6 0 0 0 0 0 0 0 0 1 0 0
10 2533 6.9 0 0 0 0 0 0 0 0 0 1 0
11 2058 7.5 0 0 0 0 0 0 0 0 0 0 1
12 2160 7.9 0 0 0 0 0 0 0 0 0 0 0
13 2260 7.7 1 0 0 0 0 0 0 0 0 0 0
14 2498 6.5 0 1 0 0 0 0 0 0 0 0 0
15 2695 6.1 0 0 1 0 0 0 0 0 0 0 0
16 2799 6.4 0 0 0 1 0 0 0 0 0 0 0
17 2947 6.8 0 0 0 0 1 0 0 0 0 0 0
18 2930 7.1 0 0 0 0 0 1 0 0 0 0 0
19 2318 7.3 0 0 0 0 0 0 1 0 0 0 0
20 2540 7.2 0 0 0 0 0 0 0 1 0 0 0
21 2570 7.0 0 0 0 0 0 0 0 0 1 0 0
22 2669 7.0 0 0 0 0 0 0 0 0 0 1 0
23 2450 7.0 0 0 0 0 0 0 0 0 0 0 1
24 2842 7.3 0 0 0 0 0 0 0 0 0 0 0
25 3440 7.5 1 0 0 0 0 0 0 0 0 0 0
26 2678 7.2 0 1 0 0 0 0 0 0 0 0 0
27 2981 7.7 0 0 1 0 0 0 0 0 0 0 0
28 2260 8.0 0 0 0 1 0 0 0 0 0 0 0
29 2844 7.9 0 0 0 0 1 0 0 0 0 0 0
30 2546 8.0 0 0 0 0 0 1 0 0 0 0 0
31 2456 8.0 0 0 0 0 0 0 1 0 0 0 0
32 2295 7.9 0 0 0 0 0 0 0 1 0 0 0
33 2379 7.9 0 0 0 0 0 0 0 0 1 0 0
34 2479 8.0 0 0 0 0 0 0 0 0 0 1 0
35 2057 8.1 0 0 0 0 0 0 0 0 0 0 1
36 2280 8.1 0 0 0 0 0 0 0 0 0 0 0
37 2351 8.2 1 0 0 0 0 0 0 0 0 0 0
38 2276 8.0 0 1 0 0 0 0 0 0 0 0 0
39 2548 8.3 0 0 1 0 0 0 0 0 0 0 0
40 2311 8.5 0 0 0 1 0 0 0 0 0 0 0
41 2201 8.6 0 0 0 0 1 0 0 0 0 0 0
42 2725 8.7 0 0 0 0 0 1 0 0 0 0 0
43 2408 8.7 0 0 0 0 0 0 1 0 0 0 0
44 2139 8.5 0 0 0 0 0 0 0 1 0 0 0
45 1898 8.4 0 0 0 0 0 0 0 0 1 0 0
46 2537 8.5 0 0 0 0 0 0 0 0 0 1 0
47 2069 8.7 0 0 0 0 0 0 0 0 0 0 1
48 2063 8.7 0 0 0 0 0 0 0 0 0 0 0
49 2524 8.6 1 0 0 0 0 0 0 0 0 0 0
50 2437 7.9 0 1 0 0 0 0 0 0 0 0 0
51 2189 8.1 0 0 1 0 0 0 0 0 0 0 0
52 2793 8.2 0 0 0 1 0 0 0 0 0 0 0
53 2074 8.5 0 0 0 0 1 0 0 0 0 0 0
54 2622 8.6 0 0 0 0 0 1 0 0 0 0 0
55 2278 8.5 0 0 0 0 0 0 1 0 0 0 0
56 2144 8.3 0 0 0 0 0 0 0 1 0 0 0
57 2427 8.2 0 0 0 0 0 0 0 0 1 0 0
58 2139 8.7 0 0 0 0 0 0 0 0 0 1 0
59 1828 9.3 0 0 0 0 0 0 0 0 0 0 1
60 2072 9.3 0 0 0 0 0 0 0 0 0 0 0
61 1800 8.8 1 0 0 0 0 0 0 0 0 0 0
62 1758 7.4 0 1 0 0 0 0 0 0 0 0 0
63 2246 7.2 0 0 1 0 0 0 0 0 0 0 0
64 1987 7.5 0 0 0 1 0 0 0 0 0 0 0
65 1868 8.3 0 0 0 0 1 0 0 0 0 0 0
66 2514 8.8 0 0 0 0 0 1 0 0 0 0 0
67 2121 8.9 0 0 0 0 0 0 1 0 0 0 0
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) X M1 M2 M3 M4
4034.67 -212.02 149.11 -155.57 125.53 18.90
M5 M6 M7 M8 M9 M10
42.84 429.38 -10.32 -131.41 -134.29 94.71
M11
-220.68
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-552.17 -152.22 -14.22 150.56 846.35
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4034.67 453.02 8.906 3.5e-12 ***
X -212.02 52.76 -4.019 0.000183 ***
M1 149.11 167.76 0.889 0.378027
M2 -155.57 173.69 -0.896 0.374398
M3 125.53 173.02 0.726 0.471253
M4 18.90 170.09 0.111 0.911920
M5 42.84 168.15 0.255 0.799855
M6 429.38 167.69 2.561 0.013278 *
M7 -10.32 167.71 -0.062 0.951153
M8 -131.41 177.09 -0.742 0.461269
M9 -134.29 178.34 -0.753 0.454709
M10 94.71 176.64 0.536 0.594041
M11 -220.68 175.27 -1.259 0.213405
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 276.9 on 54 degrees of freedom
Multiple R-squared: 0.415, Adjusted R-squared: 0.285
F-statistic: 3.192 on 12 and 54 DF, p-value: 0.001677
> 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.2435858 0.4871715 0.75641424
[2,] 0.2556021 0.5112041 0.74439795
[3,] 0.2063557 0.4127115 0.79364427
[4,] 0.1273338 0.2546676 0.87266618
[5,] 0.1555391 0.3110782 0.84446090
[6,] 0.2002475 0.4004949 0.79975253
[7,] 0.1377893 0.2755786 0.86221068
[8,] 0.1134575 0.2269149 0.88654255
[9,] 0.1658874 0.3317748 0.83411261
[10,] 0.7751845 0.4496309 0.22481547
[11,] 0.7925698 0.4148604 0.20743018
[12,] 0.8672374 0.2655252 0.13276262
[13,] 0.8169035 0.3661931 0.18309654
[14,] 0.9112635 0.1774729 0.08873647
[15,] 0.8904231 0.2191538 0.10957688
[16,] 0.8694689 0.2610621 0.13053105
[17,] 0.8239190 0.3521621 0.17608103
[18,] 0.7862892 0.4274215 0.21371075
[19,] 0.7242284 0.5515432 0.27577159
[20,] 0.6538830 0.6922340 0.34611700
[21,] 0.6114798 0.7770405 0.38852023
[22,] 0.5776352 0.8447295 0.42236477
[23,] 0.4930460 0.9860921 0.50695396
[24,] 0.4304617 0.8609235 0.56953825
[25,] 0.3530466 0.7060932 0.64695341
[26,] 0.3130727 0.6261453 0.68692734
[27,] 0.2447453 0.4894907 0.75525466
[28,] 0.2073729 0.4147458 0.79262712
[29,] 0.1430582 0.2861164 0.85694182
[30,] 0.1661107 0.3322214 0.83388929
[31,] 0.1588514 0.3177028 0.84114862
[32,] 0.1377959 0.2755918 0.86220410
[33,] 0.0940174 0.1880348 0.90598261
[34,] 0.2574370 0.5148740 0.74256302
[35,] 0.3082640 0.6165281 0.69173595
[36,] 0.4177554 0.8355109 0.58224456
> postscript(file="/var/www/html/rcomp/tmp/1d2mu1258741856.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/2d8tp1258741856.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/336az1258741856.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/4whdw1258741856.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/52q2d1258741856.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 = 67
Frequency = 1
1 2 3 4 5 6
-106.4342664 -96.1666667 212.5305341 -66.0336444 -48.3669777 248.0962677
7 8 9 10 11 12
-236.8090198 -268.3360491 -351.0590350 -133.4571688 -165.8515703 -199.7267182
13 14 15 16 17 18
-291.2417311 -2.9834622 -171.8918600 102.3420954 311.2106282 -28.7205279
19 20 21 22 23 24
-158.6164845 163.2695494 153.7484297 23.7446974 120.1390989 355.0620847
25 26 27 28 29 30
846.3545365 325.4296010 453.3379988 -97.4280458 441.4311561 -221.9037323
31 32 33 34 35 36
127.7965787 66.6826126 153.5652253 45.7633591 -39.6403732 -37.3229859
37 38 39 40 41 42
-94.2324002 93.0445304 147.5491958 59.5812850 -53.1557807 105.5093309
43 44 45 46 47 48
228.2096419 37.8938097 -221.4254439 209.7726900 99.5708238 -127.1117888
49 50 51 52 53 54
163.5750644 232.8426642 -253.8545365 477.9756865 -201.3576468 -18.6925353
55 56 57 58 59 60
55.8059095 0.4900773 265.1708238 -145.8235777 -14.2179792 9.0994082
61 62 63 64 65 66
-518.0212032 -552.1666667 -387.6713321 -476.4373767 -449.7613792 -84.2888030
67
-16.3866258
> postscript(file="/var/www/html/rcomp/tmp/6t6ud1258741856.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 = 67
Frequency = 1
lag(myerror, k = 1) myerror
0 -106.4342664 NA
1 -96.1666667 -106.4342664
2 212.5305341 -96.1666667
3 -66.0336444 212.5305341
4 -48.3669777 -66.0336444
5 248.0962677 -48.3669777
6 -236.8090198 248.0962677
7 -268.3360491 -236.8090198
8 -351.0590350 -268.3360491
9 -133.4571688 -351.0590350
10 -165.8515703 -133.4571688
11 -199.7267182 -165.8515703
12 -291.2417311 -199.7267182
13 -2.9834622 -291.2417311
14 -171.8918600 -2.9834622
15 102.3420954 -171.8918600
16 311.2106282 102.3420954
17 -28.7205279 311.2106282
18 -158.6164845 -28.7205279
19 163.2695494 -158.6164845
20 153.7484297 163.2695494
21 23.7446974 153.7484297
22 120.1390989 23.7446974
23 355.0620847 120.1390989
24 846.3545365 355.0620847
25 325.4296010 846.3545365
26 453.3379988 325.4296010
27 -97.4280458 453.3379988
28 441.4311561 -97.4280458
29 -221.9037323 441.4311561
30 127.7965787 -221.9037323
31 66.6826126 127.7965787
32 153.5652253 66.6826126
33 45.7633591 153.5652253
34 -39.6403732 45.7633591
35 -37.3229859 -39.6403732
36 -94.2324002 -37.3229859
37 93.0445304 -94.2324002
38 147.5491958 93.0445304
39 59.5812850 147.5491958
40 -53.1557807 59.5812850
41 105.5093309 -53.1557807
42 228.2096419 105.5093309
43 37.8938097 228.2096419
44 -221.4254439 37.8938097
45 209.7726900 -221.4254439
46 99.5708238 209.7726900
47 -127.1117888 99.5708238
48 163.5750644 -127.1117888
49 232.8426642 163.5750644
50 -253.8545365 232.8426642
51 477.9756865 -253.8545365
52 -201.3576468 477.9756865
53 -18.6925353 -201.3576468
54 55.8059095 -18.6925353
55 0.4900773 55.8059095
56 265.1708238 0.4900773
57 -145.8235777 265.1708238
58 -14.2179792 -145.8235777
59 9.0994082 -14.2179792
60 -518.0212032 9.0994082
61 -552.1666667 -518.0212032
62 -387.6713321 -552.1666667
63 -476.4373767 -387.6713321
64 -449.7613792 -476.4373767
65 -84.2888030 -449.7613792
66 -16.3866258 -84.2888030
67 NA -16.3866258
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -96.1666667 -106.4342664
[2,] 212.5305341 -96.1666667
[3,] -66.0336444 212.5305341
[4,] -48.3669777 -66.0336444
[5,] 248.0962677 -48.3669777
[6,] -236.8090198 248.0962677
[7,] -268.3360491 -236.8090198
[8,] -351.0590350 -268.3360491
[9,] -133.4571688 -351.0590350
[10,] -165.8515703 -133.4571688
[11,] -199.7267182 -165.8515703
[12,] -291.2417311 -199.7267182
[13,] -2.9834622 -291.2417311
[14,] -171.8918600 -2.9834622
[15,] 102.3420954 -171.8918600
[16,] 311.2106282 102.3420954
[17,] -28.7205279 311.2106282
[18,] -158.6164845 -28.7205279
[19,] 163.2695494 -158.6164845
[20,] 153.7484297 163.2695494
[21,] 23.7446974 153.7484297
[22,] 120.1390989 23.7446974
[23,] 355.0620847 120.1390989
[24,] 846.3545365 355.0620847
[25,] 325.4296010 846.3545365
[26,] 453.3379988 325.4296010
[27,] -97.4280458 453.3379988
[28,] 441.4311561 -97.4280458
[29,] -221.9037323 441.4311561
[30,] 127.7965787 -221.9037323
[31,] 66.6826126 127.7965787
[32,] 153.5652253 66.6826126
[33,] 45.7633591 153.5652253
[34,] -39.6403732 45.7633591
[35,] -37.3229859 -39.6403732
[36,] -94.2324002 -37.3229859
[37,] 93.0445304 -94.2324002
[38,] 147.5491958 93.0445304
[39,] 59.5812850 147.5491958
[40,] -53.1557807 59.5812850
[41,] 105.5093309 -53.1557807
[42,] 228.2096419 105.5093309
[43,] 37.8938097 228.2096419
[44,] -221.4254439 37.8938097
[45,] 209.7726900 -221.4254439
[46,] 99.5708238 209.7726900
[47,] -127.1117888 99.5708238
[48,] 163.5750644 -127.1117888
[49,] 232.8426642 163.5750644
[50,] -253.8545365 232.8426642
[51,] 477.9756865 -253.8545365
[52,] -201.3576468 477.9756865
[53,] -18.6925353 -201.3576468
[54,] 55.8059095 -18.6925353
[55,] 0.4900773 55.8059095
[56,] 265.1708238 0.4900773
[57,] -145.8235777 265.1708238
[58,] -14.2179792 -145.8235777
[59,] 9.0994082 -14.2179792
[60,] -518.0212032 9.0994082
[61,] -552.1666667 -518.0212032
[62,] -387.6713321 -552.1666667
[63,] -476.4373767 -387.6713321
[64,] -449.7613792 -476.4373767
[65,] -84.2888030 -449.7613792
[66,] -16.3866258 -84.2888030
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -96.1666667 -106.4342664
2 212.5305341 -96.1666667
3 -66.0336444 212.5305341
4 -48.3669777 -66.0336444
5 248.0962677 -48.3669777
6 -236.8090198 248.0962677
7 -268.3360491 -236.8090198
8 -351.0590350 -268.3360491
9 -133.4571688 -351.0590350
10 -165.8515703 -133.4571688
11 -199.7267182 -165.8515703
12 -291.2417311 -199.7267182
13 -2.9834622 -291.2417311
14 -171.8918600 -2.9834622
15 102.3420954 -171.8918600
16 311.2106282 102.3420954
17 -28.7205279 311.2106282
18 -158.6164845 -28.7205279
19 163.2695494 -158.6164845
20 153.7484297 163.2695494
21 23.7446974 153.7484297
22 120.1390989 23.7446974
23 355.0620847 120.1390989
24 846.3545365 355.0620847
25 325.4296010 846.3545365
26 453.3379988 325.4296010
27 -97.4280458 453.3379988
28 441.4311561 -97.4280458
29 -221.9037323 441.4311561
30 127.7965787 -221.9037323
31 66.6826126 127.7965787
32 153.5652253 66.6826126
33 45.7633591 153.5652253
34 -39.6403732 45.7633591
35 -37.3229859 -39.6403732
36 -94.2324002 -37.3229859
37 93.0445304 -94.2324002
38 147.5491958 93.0445304
39 59.5812850 147.5491958
40 -53.1557807 59.5812850
41 105.5093309 -53.1557807
42 228.2096419 105.5093309
43 37.8938097 228.2096419
44 -221.4254439 37.8938097
45 209.7726900 -221.4254439
46 99.5708238 209.7726900
47 -127.1117888 99.5708238
48 163.5750644 -127.1117888
49 232.8426642 163.5750644
50 -253.8545365 232.8426642
51 477.9756865 -253.8545365
52 -201.3576468 477.9756865
53 -18.6925353 -201.3576468
54 55.8059095 -18.6925353
55 0.4900773 55.8059095
56 265.1708238 0.4900773
57 -145.8235777 265.1708238
58 -14.2179792 -145.8235777
59 9.0994082 -14.2179792
60 -518.0212032 9.0994082
61 -552.1666667 -518.0212032
62 -387.6713321 -552.1666667
63 -476.4373767 -387.6713321
64 -449.7613792 -476.4373767
65 -84.2888030 -449.7613792
66 -16.3866258 -84.2888030
> 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/7o9y91258741856.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/8s2pv1258741856.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/9ndim1258741856.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/10a0rn1258741856.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/11oot21258741856.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/12m4il1258741856.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/13de721258741856.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/144anm1258741856.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/15nb571258741856.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/16sd9f1258741856.tab")
+ }
>
> system("convert tmp/1d2mu1258741856.ps tmp/1d2mu1258741856.png")
> system("convert tmp/2d8tp1258741856.ps tmp/2d8tp1258741856.png")
> system("convert tmp/336az1258741856.ps tmp/336az1258741856.png")
> system("convert tmp/4whdw1258741856.ps tmp/4whdw1258741856.png")
> system("convert tmp/52q2d1258741856.ps tmp/52q2d1258741856.png")
> system("convert tmp/6t6ud1258741856.ps tmp/6t6ud1258741856.png")
> system("convert tmp/7o9y91258741856.ps tmp/7o9y91258741856.png")
> system("convert tmp/8s2pv1258741856.ps tmp/8s2pv1258741856.png")
> system("convert tmp/9ndim1258741856.ps tmp/9ndim1258741856.png")
> system("convert tmp/10a0rn1258741856.ps tmp/10a0rn1258741856.png")
>
>
> proc.time()
user system elapsed
2.488 1.651 3.002