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(2921.44 + ,0 + ,2849.27 + ,2756.76 + ,2981.85 + ,0 + ,2921.44 + ,2849.27 + ,3080.58 + ,0 + ,2981.85 + ,2921.44 + ,3106.22 + ,0 + ,3080.58 + ,2981.85 + ,3119.31 + ,0 + ,3106.22 + ,3080.58 + ,3061.26 + ,0 + ,3119.31 + ,3106.22 + ,3097.31 + ,0 + ,3061.26 + ,3119.31 + ,3161.69 + ,0 + ,3097.31 + ,3061.26 + ,3257.16 + ,0 + ,3161.69 + ,3097.31 + ,3277.01 + ,0 + ,3257.16 + ,3161.69 + ,3295.32 + ,0 + ,3277.01 + ,3257.16 + ,3363.99 + ,0 + ,3295.32 + ,3277.01 + ,3494.17 + ,0 + ,3363.99 + ,3295.32 + ,3667.03 + ,1 + ,3494.17 + ,3363.99 + ,3813.06 + ,1 + ,3667.03 + ,3494.17 + ,3917.96 + ,1 + ,3813.06 + ,3667.03 + ,3895.51 + ,1 + ,3917.96 + ,3813.06 + ,3801.06 + ,1 + ,3895.51 + ,3917.96 + ,3570.12 + ,0 + ,3801.06 + ,3895.51 + ,3701.61 + ,1 + ,3570.12 + ,3801.06 + ,3862.27 + ,1 + ,3701.61 + ,3570.12 + ,3970.1 + ,1 + ,3862.27 + ,3701.61 + ,4138.52 + ,1 + ,3970.1 + ,3862.27 + ,4199.75 + ,1 + ,4138.52 + ,3970.1 + ,4290.89 + ,1 + ,4199.75 + ,4138.52 + ,4443.91 + ,1 + ,4290.89 + ,4199.75 + ,4502.64 + ,1 + ,4443.91 + ,4290.89 + ,4356.98 + ,1 + ,4502.64 + ,4443.91 + ,4591.27 + ,1 + ,4356.98 + ,4502.64 + ,4696.96 + ,1 + ,4591.27 + ,4356.98 + ,4621.4 + ,1 + ,4696.96 + ,4591.27 + ,4562.84 + ,1 + ,4621.4 + ,4696.96 + ,4202.52 + ,1 + ,4562.84 + ,4621.4 + ,4296.49 + ,1 + ,4202.52 + ,4562.84 + ,4435.23 + ,1 + ,4296.49 + ,4202.52 + ,4105.18 + ,1 + ,4435.23 + ,4296.49 + ,4116.68 + ,1 + ,4105.18 + ,4435.23 + ,3844.49 + ,1 + ,4116.68 + ,4105.18 + ,3720.98 + ,1 + ,3844.49 + ,4116.68 + ,3674.4 + ,1 + ,3720.98 + ,3844.49 + ,3857.62 + ,1 + ,3674.4 + ,3720.98 + ,3801.06 + ,1 + ,3857.62 + ,3674.4 + ,3504.37 + ,1 + ,3801.06 + ,3857.62 + ,3032.6 + ,1 + ,3504.37 + ,3801.06 + ,3047.03 + ,0 + ,3032.6 + ,3504.37 + ,2962.34 + ,1 + ,3047.03 + ,3032.6 + ,2197.82 + ,1 + ,2962.34 + ,3047.03 + ,2014.45 + ,1 + ,2197.82 + ,2962.34 + ,1862.83 + ,0 + ,2014.45 + ,2197.82 + ,1905.41 + ,0 + ,1862.83 + ,2014.45 + ,1810.99 + ,0 + ,1905.41 + ,1862.83 + ,1670.07 + ,0 + ,1810.99 + ,1905.41 + ,1864.44 + ,0 + ,1670.07 + ,1810.99 + ,2052.02 + ,0 + ,1864.44 + ,1670.07 + ,2029.6 + ,0 + ,2052.02 + ,1864.44 + ,2070.83 + ,0 + ,2029.6 + ,2052.02 + ,2293.41 + ,0 + ,2070.83 + ,2029.6 + ,2443.27 + ,0 + ,2293.41 + ,2070.83) + ,dim=c(4 + ,58) + ,dimnames=list(c('Yt' + ,'X' + ,'Yt-1' + ,'Yt-2 ') + ,1:58)) > y <- array(NA,dim=c(4,58),dimnames=list(c('Yt','X','Yt-1','Yt-2 '),1:58)) > 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 = 'Do not include Seasonal 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 Yt X Yt-1 Yt-2\r\r\r\r t 1 2921.44 0 2849.27 2756.76 1 2 2981.85 0 2921.44 2849.27 2 3 3080.58 0 2981.85 2921.44 3 4 3106.22 0 3080.58 2981.85 4 5 3119.31 0 3106.22 3080.58 5 6 3061.26 0 3119.31 3106.22 6 7 3097.31 0 3061.26 3119.31 7 8 3161.69 0 3097.31 3061.26 8 9 3257.16 0 3161.69 3097.31 9 10 3277.01 0 3257.16 3161.69 10 11 3295.32 0 3277.01 3257.16 11 12 3363.99 0 3295.32 3277.01 12 13 3494.17 0 3363.99 3295.32 13 14 3667.03 1 3494.17 3363.99 14 15 3813.06 1 3667.03 3494.17 15 16 3917.96 1 3813.06 3667.03 16 17 3895.51 1 3917.96 3813.06 17 18 3801.06 1 3895.51 3917.96 18 19 3570.12 0 3801.06 3895.51 19 20 3701.61 1 3570.12 3801.06 20 21 3862.27 1 3701.61 3570.12 21 22 3970.10 1 3862.27 3701.61 22 23 4138.52 1 3970.10 3862.27 23 24 4199.75 1 4138.52 3970.10 24 25 4290.89 1 4199.75 4138.52 25 26 4443.91 1 4290.89 4199.75 26 27 4502.64 1 4443.91 4290.89 27 28 4356.98 1 4502.64 4443.91 28 29 4591.27 1 4356.98 4502.64 29 30 4696.96 1 4591.27 4356.98 30 31 4621.40 1 4696.96 4591.27 31 32 4562.84 1 4621.40 4696.96 32 33 4202.52 1 4562.84 4621.40 33 34 4296.49 1 4202.52 4562.84 34 35 4435.23 1 4296.49 4202.52 35 36 4105.18 1 4435.23 4296.49 36 37 4116.68 1 4105.18 4435.23 37 38 3844.49 1 4116.68 4105.18 38 39 3720.98 1 3844.49 4116.68 39 40 3674.40 1 3720.98 3844.49 40 41 3857.62 1 3674.40 3720.98 41 42 3801.06 1 3857.62 3674.40 42 43 3504.37 1 3801.06 3857.62 43 44 3032.60 1 3504.37 3801.06 44 45 3047.03 0 3032.60 3504.37 45 46 2962.34 1 3047.03 3032.60 46 47 2197.82 1 2962.34 3047.03 47 48 2014.45 1 2197.82 2962.34 48 49 1862.83 0 2014.45 2197.82 49 50 1905.41 0 1862.83 2014.45 50 51 1810.99 0 1905.41 1862.83 51 52 1670.07 0 1810.99 1905.41 52 53 1864.44 0 1670.07 1810.99 53 54 2052.02 0 1864.44 1670.07 54 55 2029.60 0 2052.02 1864.44 55 56 2070.83 0 2029.60 2052.02 56 57 2293.41 0 2070.83 2029.60 57 58 2443.27 0 2293.41 2070.83 58 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X `Yt-1` `Yt-2\r\r\r\r` t 201.7308 -11.4119 1.2136 -0.2507 -2.5144 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -705.51 -65.38 16.17 112.11 315.08 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 201.7308 182.9190 1.103 0.2751 X -11.4119 86.1990 -0.132 0.8952 `Yt-1` 1.2136 0.1368 8.869 4.71e-12 *** `Yt-2\r\r\r\r` -0.2507 0.1347 -1.861 0.0684 . t -2.5144 1.8241 -1.378 0.1738 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 176.2 on 53 degrees of freedom Multiple R-squared: 0.9607, Adjusted R-squared: 0.9577 F-statistic: 323.9 on 4 and 53 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,] 2.523431e-02 5.046862e-02 0.9747657 [2,] 6.563683e-03 1.312737e-02 0.9934363 [3,] 1.663801e-03 3.327603e-03 0.9983362 [4,] 3.355143e-04 6.710286e-04 0.9996645 [5,] 9.940400e-05 1.988080e-04 0.9999006 [6,] 8.877304e-05 1.775461e-04 0.9999112 [7,] 1.832714e-05 3.665427e-05 0.9999817 [8,] 3.870072e-06 7.740145e-06 0.9999961 [9,] 8.850361e-07 1.770072e-06 0.9999991 [10,] 2.816526e-07 5.633052e-07 0.9999997 [11,] 8.360613e-08 1.672123e-07 0.9999999 [12,] 1.327318e-07 2.654637e-07 0.9999999 [13,] 6.099861e-08 1.219972e-07 0.9999999 [14,] 9.656166e-08 1.931233e-07 0.9999999 [15,] 3.278852e-08 6.557703e-08 1.0000000 [16,] 3.868341e-08 7.736682e-08 1.0000000 [17,] 9.833090e-09 1.966618e-08 1.0000000 [18,] 1.965364e-08 3.930728e-08 1.0000000 [19,] 1.444203e-07 2.888406e-07 0.9999999 [20,] 5.759529e-08 1.151906e-07 0.9999999 [21,] 4.785302e-08 9.570604e-08 1.0000000 [22,] 8.508539e-06 1.701708e-05 0.9999915 [23,] 4.942012e-06 9.884024e-06 0.9999951 [24,] 2.046597e-06 4.093194e-06 0.9999980 [25,] 7.367168e-07 1.473434e-06 0.9999993 [26,] 1.139827e-04 2.279653e-04 0.9998860 [27,] 8.613505e-05 1.722701e-04 0.9999139 [28,] 8.467507e-05 1.693501e-04 0.9999153 [29,] 2.320373e-03 4.640746e-03 0.9976796 [30,] 1.692333e-03 3.384667e-03 0.9983077 [31,] 3.376927e-03 6.753855e-03 0.9966231 [32,] 2.000726e-03 4.001452e-03 0.9979993 [33,] 1.278406e-03 2.556811e-03 0.9987216 [34,] 1.135895e-02 2.271791e-02 0.9886410 [35,] 2.301786e-02 4.603571e-02 0.9769821 [36,] 3.045334e-02 6.090667e-02 0.9695467 [37,] 4.586464e-02 9.172928e-02 0.9541354 [38,] 6.719608e-02 1.343922e-01 0.9328039 [39,] 7.588240e-01 4.823520e-01 0.2411760 [40,] 8.286692e-01 3.426617e-01 0.1713308 [41,] 7.205147e-01 5.589707e-01 0.2794853 [42,] 5.969943e-01 8.060115e-01 0.4030057 [43,] 7.688205e-01 4.623591e-01 0.2311795 > postscript(file="/var/www/html/rcomp/tmp/1bcq71258907368.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/2c9lp1258907368.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/3hisz1258907368.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/4pzhe1258907368.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/59te61258907368.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 = 58 Frequency = 1 1 2 3 4 5 -44.51366249 -45.98215954 0.04200889 -76.47677023 -67.23760109 6 7 8 9 10 -132.23123205 -19.93630863 -11.34469249 17.54639297 -59.81082086 11 12 13 14 15 -39.14223433 14.79766690 68.74510878 114.76153579 86.16038013 16 17 18 19 20 59.68953702 -50.94252045 -89.33501966 -220.17701279 181.82750946 21 22 23 24 25 127.53131375 75.86436645 156.21416958 42.59830278 104.16679487 26 27 28 29 30 164.44473369 62.83403919 -113.22420872 315.07508145 102.43117780 31 32 33 34 35 -40.14320749 22.00610309 -283.67422220 235.41017186 172.29285151 36 37 38 39 40 -300.05831005 149.28299185 -217.09100779 -4.87654724 32.71148388 41 42 43 44 45 244.01148953 -44.06544101 -223.66789606 -347.04283647 156.64610878 46 47 48 49 50 -49.90045131 -705.50956035 20.21719512 -109.42618949 73.70265185 51 52 53 54 55 -107.88807685 -121.03187029 223.20094731 142.08185080 -56.74118718 56 57 58 61.23743176 230.67494227 123.26470798 > postscript(file="/var/www/html/rcomp/tmp/61h7r1258907368.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 = 58 Frequency = 1 lag(myerror, k = 1) myerror 0 -44.51366249 NA 1 -45.98215954 -44.51366249 2 0.04200889 -45.98215954 3 -76.47677023 0.04200889 4 -67.23760109 -76.47677023 5 -132.23123205 -67.23760109 6 -19.93630863 -132.23123205 7 -11.34469249 -19.93630863 8 17.54639297 -11.34469249 9 -59.81082086 17.54639297 10 -39.14223433 -59.81082086 11 14.79766690 -39.14223433 12 68.74510878 14.79766690 13 114.76153579 68.74510878 14 86.16038013 114.76153579 15 59.68953702 86.16038013 16 -50.94252045 59.68953702 17 -89.33501966 -50.94252045 18 -220.17701279 -89.33501966 19 181.82750946 -220.17701279 20 127.53131375 181.82750946 21 75.86436645 127.53131375 22 156.21416958 75.86436645 23 42.59830278 156.21416958 24 104.16679487 42.59830278 25 164.44473369 104.16679487 26 62.83403919 164.44473369 27 -113.22420872 62.83403919 28 315.07508145 -113.22420872 29 102.43117780 315.07508145 30 -40.14320749 102.43117780 31 22.00610309 -40.14320749 32 -283.67422220 22.00610309 33 235.41017186 -283.67422220 34 172.29285151 235.41017186 35 -300.05831005 172.29285151 36 149.28299185 -300.05831005 37 -217.09100779 149.28299185 38 -4.87654724 -217.09100779 39 32.71148388 -4.87654724 40 244.01148953 32.71148388 41 -44.06544101 244.01148953 42 -223.66789606 -44.06544101 43 -347.04283647 -223.66789606 44 156.64610878 -347.04283647 45 -49.90045131 156.64610878 46 -705.50956035 -49.90045131 47 20.21719512 -705.50956035 48 -109.42618949 20.21719512 49 73.70265185 -109.42618949 50 -107.88807685 73.70265185 51 -121.03187029 -107.88807685 52 223.20094731 -121.03187029 53 142.08185080 223.20094731 54 -56.74118718 142.08185080 55 61.23743176 -56.74118718 56 230.67494227 61.23743176 57 123.26470798 230.67494227 58 NA 123.26470798 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -45.98215954 -44.51366249 [2,] 0.04200889 -45.98215954 [3,] -76.47677023 0.04200889 [4,] -67.23760109 -76.47677023 [5,] -132.23123205 -67.23760109 [6,] -19.93630863 -132.23123205 [7,] -11.34469249 -19.93630863 [8,] 17.54639297 -11.34469249 [9,] -59.81082086 17.54639297 [10,] -39.14223433 -59.81082086 [11,] 14.79766690 -39.14223433 [12,] 68.74510878 14.79766690 [13,] 114.76153579 68.74510878 [14,] 86.16038013 114.76153579 [15,] 59.68953702 86.16038013 [16,] -50.94252045 59.68953702 [17,] -89.33501966 -50.94252045 [18,] -220.17701279 -89.33501966 [19,] 181.82750946 -220.17701279 [20,] 127.53131375 181.82750946 [21,] 75.86436645 127.53131375 [22,] 156.21416958 75.86436645 [23,] 42.59830278 156.21416958 [24,] 104.16679487 42.59830278 [25,] 164.44473369 104.16679487 [26,] 62.83403919 164.44473369 [27,] -113.22420872 62.83403919 [28,] 315.07508145 -113.22420872 [29,] 102.43117780 315.07508145 [30,] -40.14320749 102.43117780 [31,] 22.00610309 -40.14320749 [32,] -283.67422220 22.00610309 [33,] 235.41017186 -283.67422220 [34,] 172.29285151 235.41017186 [35,] -300.05831005 172.29285151 [36,] 149.28299185 -300.05831005 [37,] -217.09100779 149.28299185 [38,] -4.87654724 -217.09100779 [39,] 32.71148388 -4.87654724 [40,] 244.01148953 32.71148388 [41,] -44.06544101 244.01148953 [42,] -223.66789606 -44.06544101 [43,] -347.04283647 -223.66789606 [44,] 156.64610878 -347.04283647 [45,] -49.90045131 156.64610878 [46,] -705.50956035 -49.90045131 [47,] 20.21719512 -705.50956035 [48,] -109.42618949 20.21719512 [49,] 73.70265185 -109.42618949 [50,] -107.88807685 73.70265185 [51,] -121.03187029 -107.88807685 [52,] 223.20094731 -121.03187029 [53,] 142.08185080 223.20094731 [54,] -56.74118718 142.08185080 [55,] 61.23743176 -56.74118718 [56,] 230.67494227 61.23743176 [57,] 123.26470798 230.67494227 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -45.98215954 -44.51366249 2 0.04200889 -45.98215954 3 -76.47677023 0.04200889 4 -67.23760109 -76.47677023 5 -132.23123205 -67.23760109 6 -19.93630863 -132.23123205 7 -11.34469249 -19.93630863 8 17.54639297 -11.34469249 9 -59.81082086 17.54639297 10 -39.14223433 -59.81082086 11 14.79766690 -39.14223433 12 68.74510878 14.79766690 13 114.76153579 68.74510878 14 86.16038013 114.76153579 15 59.68953702 86.16038013 16 -50.94252045 59.68953702 17 -89.33501966 -50.94252045 18 -220.17701279 -89.33501966 19 181.82750946 -220.17701279 20 127.53131375 181.82750946 21 75.86436645 127.53131375 22 156.21416958 75.86436645 23 42.59830278 156.21416958 24 104.16679487 42.59830278 25 164.44473369 104.16679487 26 62.83403919 164.44473369 27 -113.22420872 62.83403919 28 315.07508145 -113.22420872 29 102.43117780 315.07508145 30 -40.14320749 102.43117780 31 22.00610309 -40.14320749 32 -283.67422220 22.00610309 33 235.41017186 -283.67422220 34 172.29285151 235.41017186 35 -300.05831005 172.29285151 36 149.28299185 -300.05831005 37 -217.09100779 149.28299185 38 -4.87654724 -217.09100779 39 32.71148388 -4.87654724 40 244.01148953 32.71148388 41 -44.06544101 244.01148953 42 -223.66789606 -44.06544101 43 -347.04283647 -223.66789606 44 156.64610878 -347.04283647 45 -49.90045131 156.64610878 46 -705.50956035 -49.90045131 47 20.21719512 -705.50956035 48 -109.42618949 20.21719512 49 73.70265185 -109.42618949 50 -107.88807685 73.70265185 51 -121.03187029 -107.88807685 52 223.20094731 -121.03187029 53 142.08185080 223.20094731 54 -56.74118718 142.08185080 55 61.23743176 -56.74118718 56 230.67494227 61.23743176 57 123.26470798 230.67494227 > 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/79sdm1258907368.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/80yfu1258907368.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/97auw1258907368.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/10ryuo1258907368.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/11a5rx1258907368.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/1229j81258907368.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/13h6fg1258907369.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/147rwg1258907369.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/15dm9u1258907369.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/167oxm1258907369.tab") + } > > system("convert tmp/1bcq71258907368.ps tmp/1bcq71258907368.png") > system("convert tmp/2c9lp1258907368.ps tmp/2c9lp1258907368.png") > system("convert tmp/3hisz1258907368.ps tmp/3hisz1258907368.png") > system("convert tmp/4pzhe1258907368.ps tmp/4pzhe1258907368.png") > system("convert tmp/59te61258907368.ps tmp/59te61258907368.png") > system("convert tmp/61h7r1258907368.ps tmp/61h7r1258907368.png") > system("convert tmp/79sdm1258907368.ps tmp/79sdm1258907368.png") > system("convert tmp/80yfu1258907368.ps tmp/80yfu1258907368.png") > system("convert tmp/97auw1258907368.ps tmp/97auw1258907368.png") > system("convert tmp/10ryuo1258907368.ps tmp/10ryuo1258907368.png") > > > proc.time() user system elapsed 2.436 1.575 2.898