R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) 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(31/12/1961 + ,9190 + ,0 + ,0 + ,5064 + ,0 + ,3103 + ,0 + ,1023 + ,0 + ,31/12/1962 + ,9251 + ,1 + ,9251 + ,5109 + ,5109 + ,3112 + ,3112 + ,1030 + ,1030 + ,31/12/1963 + ,9328 + ,0 + ,0 + ,5161 + ,0 + ,3127 + ,0 + ,1041 + ,0 + ,31/12/1964 + ,9428 + ,1 + ,9428 + ,5218 + ,5218 + ,3153 + ,3153 + ,1058 + ,1058 + ,31/12/1965 + ,9499 + ,0 + ,0 + ,5264 + ,0 + ,3169 + ,0 + ,1066 + ,0 + ,31/12/1966 + ,9556 + ,1 + ,9556 + ,5308 + ,5308 + ,3174 + ,3174 + ,1074 + ,1074 + ,31/12/1967 + ,9606 + ,0 + ,0 + ,5347 + ,0 + ,3179 + ,0 + ,1079 + ,0 + ,31/12/1968 + ,9632 + ,1 + ,9632 + ,5373 + ,5373 + ,3181 + ,3181 + ,1077 + ,1077 + ,31/12/1969 + ,9660 + ,0 + ,0 + ,5404 + ,0 + ,3183 + ,0 + ,1073 + ,0 + ,31/12/1970 + ,9651 + ,1 + ,9651 + ,5416 + ,5416 + ,3160 + ,3160 + ,1075 + ,1075 + ,31/12/1971 + ,9695 + ,0 + ,0 + ,5452 + ,0 + ,3170 + ,0 + ,1074 + ,0 + ,31/12/1972 + ,9727 + ,1 + ,9727 + ,5478 + ,5478 + ,3180 + ,3180 + ,1069 + ,1069 + ,31/12/1973 + ,9757 + ,0 + ,0 + ,5501 + ,0 + ,3192 + ,0 + ,1064 + ,0 + ,31/12/1974 + ,9788 + ,1 + ,9788 + ,5527 + ,5527 + ,3206 + ,3206 + ,1055 + ,1055 + ,31/12/1975 + ,9813 + ,0 + ,0 + ,5548 + ,0 + ,3213 + ,0 + ,1051 + ,0 + ,31/12/1976 + ,9823 + ,1 + ,9823 + ,5566 + ,5566 + ,3215 + ,3215 + ,1042 + ,1042 + ,31/12/1977 + ,9837 + ,0 + ,0 + ,5584 + ,0 + ,3224 + ,0 + ,1029 + ,0 + ,31/12/1978 + ,9842 + ,1 + ,9842 + ,5601 + ,5601 + ,3225 + ,3225 + ,1016 + ,1016 + ,31/12/1979 + ,9855 + ,0 + ,0 + ,5619 + ,0 + ,3228 + ,0 + ,1009 + ,0 + ,31/12/1980 + ,9863 + ,1 + ,9863 + ,5635 + ,5635 + ,3229 + ,3229 + ,1000 + ,1000 + ,31/12/1981 + ,9855 + ,0 + ,0 + ,5642 + ,0 + ,3218 + ,0 + ,994 + ,0 + ,31/12/1982 + ,9858 + ,1 + ,9858 + ,5655 + ,5655 + ,3213 + ,3213 + ,990 + ,990 + ,31/12/1983 + ,9853 + ,0 + ,0 + ,5662 + ,0 + ,3208 + ,0 + ,983 + ,0 + ,31/12/1984 + ,9858 + ,1 + ,9858 + ,5670 + ,5670 + ,3208 + ,3208 + ,979 + ,979 + ,31/12/1985 + ,9859 + ,0 + ,0 + ,5676 + ,0 + ,3206 + ,0 + ,976 + ,0 + ,31/12/1986 + ,9865 + ,1 + ,9865 + ,5685 + ,5685 + ,3206 + ,3206 + ,973 + ,973 + ,31/12/1987 + ,9876 + ,0 + ,0 + ,5696 + ,0 + ,3210 + ,0 + ,970 + ,0 + ,31/12/1988 + ,9928 + ,1 + ,9928 + ,5722 + ,5722 + ,3235 + ,3235 + ,970 + ,970 + ,31/12/1989 + ,9948 + ,0 + ,0 + ,5740 + ,0 + ,3244 + ,0 + ,964 + ,0 + ,31/12/1990 + ,9987 + ,1 + ,9987 + ,5768 + ,5768 + ,3259 + ,3259 + ,961 + ,961 + ,31/12/1991 + ,10022 + ,0 + ,0 + ,5795 + ,0 + ,3276 + ,0 + ,951 + ,0 + ,31/12/1992 + ,10068 + ,1 + ,10068 + ,5825 + ,5825 + ,3293 + ,3293 + ,950 + ,950 + ,31/12/1993 + ,10101 + ,0 + ,0 + ,5847 + ,0 + ,3305 + ,0 + ,949 + ,0 + ,31/12/1994 + ,10131 + ,1 + ,10131 + ,5866 + ,5866 + ,3313 + ,3313 + ,952 + ,952 + ,31/12/1995 + ,10143 + ,0 + ,0 + ,5880 + ,0 + ,3315 + ,0 + ,948 + ,0 + ,31/12/1996 + ,10170 + ,1 + ,10170 + ,5899 + ,5899 + ,3320 + ,3320 + ,951 + ,951 + ,31/12/1997 + ,10192 + ,0 + ,0 + ,5913 + ,0 + ,3326 + ,0 + ,953 + ,0 + ,31/12/1998 + ,10214 + ,1 + ,10214 + ,5927 + ,5927 + ,3332 + ,3332 + ,955 + ,955 + ,31/12/1999 + ,10239 + ,0 + ,0 + ,5941 + ,0 + ,3340 + ,0 + ,959 + ,0 + ,31/12/2000 + ,10263 + ,1 + ,10263 + ,5953 + ,5953 + ,3346 + ,3346 + ,964 + ,964 + ,31/12/2001 + ,10310 + ,0 + ,0 + ,5973 + ,0 + ,3358 + ,0 + ,979 + ,0 + ,31/12/2002 + ,10355 + ,1 + ,10355 + ,5995 + ,5995 + ,3369 + ,3369 + ,992 + ,992 + ,31/12/2003 + ,10396 + ,0 + ,0 + ,6016 + ,0 + ,3380 + ,0 + ,1000 + ,0 + ,31/12/2004 + ,10446 + ,1 + ,10446 + ,6043 + ,6043 + ,3396 + ,3396 + ,1007 + ,1007 + ,31/12/2005 + ,10511 + ,0 + ,0 + ,6078 + ,0 + ,3414 + ,0 + ,1019 + ,0 + ,31/12/2006 + ,10585 + ,1 + ,10585 + ,6117 + ,6117 + ,3436 + ,3436 + ,1031 + ,1031 + ,31/12/2007 + ,10667 + ,0 + ,0 + ,6162 + ,0 + ,3456 + ,0 + ,1049 + ,0 + ,31/12/2008 + ,10753 + ,1 + ,10753 + ,6209 + ,6209 + ,3476 + ,3476 + ,1069 + ,1069 + ,31/12/2009 + ,10840 + ,0 + ,0 + ,6252 + ,0 + ,3498 + ,0 + ,1090 + ,0 + ,31/12/2010 + ,10951 + ,1 + ,10951 + ,6306 + ,6306 + ,3525 + ,3525 + ,1119 + ,1119) + ,dim=c(10 + ,50) + ,dimnames=list(c('jaar' + ,'totaal' + ,'pop' + ,'pop_t' + ,'totaal_vlaams_gewest' + ,'pop_vlaams_gewest' + ,'totaal_waals_gewest' + ,'waals_gewest_pop' + ,'totaal_brussel' + ,'totaal_brussel_pop') + ,1:50)) > y <- array(NA,dim=c(10,50),dimnames=list(c('jaar','totaal','pop','pop_t','totaal_vlaams_gewest','pop_vlaams_gewest','totaal_waals_gewest','waals_gewest_pop','totaal_brussel','totaal_brussel_pop'),1:50)) > 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 = '2' > library(lattice) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, 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 totaal jaar pop pop_t totaal_vlaams_gewest pop_vlaams_gewest 1 9190 0.001317355 0 0 5064 0 2 9251 0.001316684 1 9251 5109 5109 3 9328 0.001316013 0 0 5161 0 4 9428 0.001315343 1 9428 5218 5218 5 9499 0.001314673 0 0 5264 0 6 9556 0.001314005 1 9556 5308 5308 7 9606 0.001313337 0 0 5347 0 8 9632 0.001312669 1 9632 5373 5373 9 9660 0.001312003 0 0 5404 0 10 9651 0.001311337 1 9651 5416 5416 11 9695 0.001310671 0 0 5452 0 12 9727 0.001310007 1 9727 5478 5478 13 9757 0.001309343 0 0 5501 0 14 9788 0.001308680 1 9788 5527 5527 15 9813 0.001308017 0 0 5548 0 16 9823 0.001307355 1 9823 5566 5566 17 9837 0.001306694 0 0 5584 0 18 9842 0.001306033 1 9842 5601 5601 19 9855 0.001305373 0 0 5619 0 20 9863 0.001304714 1 9863 5635 5635 21 9855 0.001304055 0 0 5642 0 22 9858 0.001303397 1 9858 5655 5655 23 9853 0.001302740 0 0 5662 0 24 9858 0.001302083 1 9858 5670 5670 25 9859 0.001301427 0 0 5676 0 26 9865 0.001300772 1 9865 5685 5685 27 9876 0.001300117 0 0 5696 0 28 9928 0.001299463 1 9928 5722 5722 29 9948 0.001298810 0 0 5740 0 30 9987 0.001298157 1 9987 5768 5768 31 10022 0.001297505 0 0 5795 0 32 10068 0.001296854 1 10068 5825 5825 33 10101 0.001296203 0 0 5847 0 34 10131 0.001295553 1 10131 5866 5866 35 10143 0.001294904 0 0 5880 0 36 10170 0.001294255 1 10170 5899 5899 37 10192 0.001293607 0 0 5913 0 38 10214 0.001292960 1 10214 5927 5927 39 10239 0.001292313 0 0 5941 0 40 10263 0.001291667 1 10263 5953 5953 41 10310 0.001291021 0 0 5973 0 42 10355 0.001290376 1 10355 5995 5995 43 10396 0.001289732 0 0 6016 0 44 10446 0.001289088 1 10446 6043 6043 45 10511 0.001288446 0 0 6078 0 46 10585 0.001287803 1 10585 6117 6117 47 10667 0.001287162 0 0 6162 0 48 10753 0.001286521 1 10753 6209 6209 49 10840 0.001285880 0 0 6252 0 50 10951 0.001285240 1 10951 6306 6306 totaal_waals_gewest waals_gewest_pop totaal_brussel totaal_brussel_pop t 1 3103 0 1023 0 1 2 3112 3112 1030 1030 2 3 3127 0 1041 0 3 4 3153 3153 1058 1058 4 5 3169 0 1066 0 5 6 3174 3174 1074 1074 6 7 3179 0 1079 0 7 8 3181 3181 1077 1077 8 9 3183 0 1073 0 9 10 3160 3160 1075 1075 10 11 3170 0 1074 0 11 12 3180 3180 1069 1069 12 13 3192 0 1064 0 13 14 3206 3206 1055 1055 14 15 3213 0 1051 0 15 16 3215 3215 1042 1042 16 17 3224 0 1029 0 17 18 3225 3225 1016 1016 18 19 3228 0 1009 0 19 20 3229 3229 1000 1000 20 21 3218 0 994 0 21 22 3213 3213 990 990 22 23 3208 0 983 0 23 24 3208 3208 979 979 24 25 3206 0 976 0 25 26 3206 3206 973 973 26 27 3210 0 970 0 27 28 3235 3235 970 970 28 29 3244 0 964 0 29 30 3259 3259 961 961 30 31 3276 0 951 0 31 32 3293 3293 950 950 32 33 3305 0 949 0 33 34 3313 3313 952 952 34 35 3315 0 948 0 35 36 3320 3320 951 951 36 37 3326 0 953 0 37 38 3332 3332 955 955 38 39 3340 0 959 0 39 40 3346 3346 964 964 40 41 3358 0 979 0 41 42 3369 3369 992 992 42 43 3380 0 1000 0 43 44 3396 3396 1007 1007 44 45 3414 0 1019 0 45 46 3436 3436 1031 1031 46 47 3456 0 1049 0 47 48 3476 3476 1069 1069 48 49 3498 0 1090 0 49 50 3525 3525 1119 1119 50 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) jaar pop 7.894e+03 -5.985e+06 -4.248e+00 pop_t totaal_vlaams_gewest pop_vlaams_gewest 1.012e+00 9.963e-01 -1.014e+00 totaal_waals_gewest waals_gewest_pop totaal_brussel 1.002e+00 -1.007e+00 1.007e+00 totaal_brussel_pop t -1.014e+00 -3.851e+00 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.14794 -0.06329 0.00519 0.06606 0.96457 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7.894e+03 9.226e+03 0.856 0.397 jaar -5.985e+06 6.995e+06 -0.856 0.397 pop -4.248e+00 6.357e+00 -0.668 0.508 pop_t 1.012e+00 1.408e-01 7.187 1.19e-08 *** totaal_vlaams_gewest 9.963e-01 7.083e-03 140.668 < 2e-16 *** pop_vlaams_gewest -1.014e+00 1.413e-01 -7.175 1.23e-08 *** totaal_waals_gewest 1.002e+00 8.569e-03 116.898 < 2e-16 *** waals_gewest_pop -1.007e+00 1.396e-01 -7.210 1.11e-08 *** totaal_brussel 1.007e+00 6.875e-03 146.457 < 2e-16 *** totaal_brussel_pop -1.014e+00 1.415e-01 -7.167 1.27e-08 *** t -3.851e+00 4.485e+00 -0.859 0.396 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4375 on 39 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 3.981e+06 on 10 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.6383263 0.7233474125 0.3616737063 [2,] 0.6728754 0.6542492282 0.3271246141 [3,] 0.6477248 0.7045503877 0.3522751938 [4,] 0.9233474 0.1533051112 0.0766525556 [5,] 0.8678688 0.2642624920 0.1321312460 [6,] 0.9955600 0.0088800966 0.0044400483 [7,] 0.9902125 0.0195749376 0.0097874688 [8,] 0.9938491 0.0123017946 0.0061508973 [9,] 0.9979796 0.0040407741 0.0020203870 [10,] 0.9992370 0.0015260592 0.0007630296 [11,] 0.9988405 0.0023190666 0.0011595333 [12,] 0.9997223 0.0005553034 0.0002776517 [13,] 0.9995265 0.0009470715 0.0004735357 [14,] 0.9994351 0.0011297268 0.0005648634 [15,] 0.9985167 0.0029665963 0.0014832981 [16,] 0.9967208 0.0065583150 0.0032791575 [17,] 0.9922317 0.0155365167 0.0077682583 [18,] 0.9838802 0.0322395223 0.0161197611 [19,] 0.9798333 0.0403333766 0.0201666883 [20,] 0.9749889 0.0500221873 0.0250110937 [21,] 0.9405743 0.1188514368 0.0594257184 [22,] 0.9418858 0.1162283516 0.0581141758 [23,] 0.9338199 0.1323602333 0.0661801166 > postscript(file="/var/wessaorg/rcomp/tmp/13dad1354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/273en1354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3lgwc1354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/421xg1354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5mv8r1354824687.ps",horizontal=F,onefile=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 = 50 Frequency = 1 1 2 3 4 5 0.3836677125 0.1194748746 -0.7557079765 -0.0057068106 0.0647443494 6 7 8 9 10 -0.0520008541 0.9645707787 -0.0638244026 -0.0731131799 0.0563573049 11 12 13 14 15 -1.1479383461 0.0263202496 -0.1849403960 -0.0616746142 0.8092941739 16 17 18 19 20 -0.0779927836 -0.1417399578 -0.0473726247 -1.0826554767 0.0004585178 21 22 23 24 25 0.9368877982 0.0717810252 -0.0664551592 0.0626475323 0.8828948558 26 27 28 29 30 0.0383163549 -0.1468152685 -0.0732444772 -0.1224981739 -0.0357176091 31 32 33 34 35 0.0099162361 -0.0168071529 0.0756245798 -0.0220023788 0.1118079767 36 37 38 39 40 0.0461658438 0.1202591707 0.0465066112 -0.8860921630 0.0153324625 41 42 43 44 45 0.0339187703 -0.0490602853 -0.0037810263 -0.0570452369 0.0376715928 46 47 48 49 50 -0.0375086117 0.0857087011 0.0665048238 0.0947704276 0.0500922411 > postscript(file="/var/wessaorg/rcomp/tmp/6a9ff1354824687.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 50 Frequency = 1 lag(myerror, k = 1) myerror 0 0.3836677125 NA 1 0.1194748746 0.3836677125 2 -0.7557079765 0.1194748746 3 -0.0057068106 -0.7557079765 4 0.0647443494 -0.0057068106 5 -0.0520008541 0.0647443494 6 0.9645707787 -0.0520008541 7 -0.0638244026 0.9645707787 8 -0.0731131799 -0.0638244026 9 0.0563573049 -0.0731131799 10 -1.1479383461 0.0563573049 11 0.0263202496 -1.1479383461 12 -0.1849403960 0.0263202496 13 -0.0616746142 -0.1849403960 14 0.8092941739 -0.0616746142 15 -0.0779927836 0.8092941739 16 -0.1417399578 -0.0779927836 17 -0.0473726247 -0.1417399578 18 -1.0826554767 -0.0473726247 19 0.0004585178 -1.0826554767 20 0.9368877982 0.0004585178 21 0.0717810252 0.9368877982 22 -0.0664551592 0.0717810252 23 0.0626475323 -0.0664551592 24 0.8828948558 0.0626475323 25 0.0383163549 0.8828948558 26 -0.1468152685 0.0383163549 27 -0.0732444772 -0.1468152685 28 -0.1224981739 -0.0732444772 29 -0.0357176091 -0.1224981739 30 0.0099162361 -0.0357176091 31 -0.0168071529 0.0099162361 32 0.0756245798 -0.0168071529 33 -0.0220023788 0.0756245798 34 0.1118079767 -0.0220023788 35 0.0461658438 0.1118079767 36 0.1202591707 0.0461658438 37 0.0465066112 0.1202591707 38 -0.8860921630 0.0465066112 39 0.0153324625 -0.8860921630 40 0.0339187703 0.0153324625 41 -0.0490602853 0.0339187703 42 -0.0037810263 -0.0490602853 43 -0.0570452369 -0.0037810263 44 0.0376715928 -0.0570452369 45 -0.0375086117 0.0376715928 46 0.0857087011 -0.0375086117 47 0.0665048238 0.0857087011 48 0.0947704276 0.0665048238 49 0.0500922411 0.0947704276 50 NA 0.0500922411 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.1194748746 0.3836677125 [2,] -0.7557079765 0.1194748746 [3,] -0.0057068106 -0.7557079765 [4,] 0.0647443494 -0.0057068106 [5,] -0.0520008541 0.0647443494 [6,] 0.9645707787 -0.0520008541 [7,] -0.0638244026 0.9645707787 [8,] -0.0731131799 -0.0638244026 [9,] 0.0563573049 -0.0731131799 [10,] -1.1479383461 0.0563573049 [11,] 0.0263202496 -1.1479383461 [12,] -0.1849403960 0.0263202496 [13,] -0.0616746142 -0.1849403960 [14,] 0.8092941739 -0.0616746142 [15,] -0.0779927836 0.8092941739 [16,] -0.1417399578 -0.0779927836 [17,] -0.0473726247 -0.1417399578 [18,] -1.0826554767 -0.0473726247 [19,] 0.0004585178 -1.0826554767 [20,] 0.9368877982 0.0004585178 [21,] 0.0717810252 0.9368877982 [22,] -0.0664551592 0.0717810252 [23,] 0.0626475323 -0.0664551592 [24,] 0.8828948558 0.0626475323 [25,] 0.0383163549 0.8828948558 [26,] -0.1468152685 0.0383163549 [27,] -0.0732444772 -0.1468152685 [28,] -0.1224981739 -0.0732444772 [29,] -0.0357176091 -0.1224981739 [30,] 0.0099162361 -0.0357176091 [31,] -0.0168071529 0.0099162361 [32,] 0.0756245798 -0.0168071529 [33,] -0.0220023788 0.0756245798 [34,] 0.1118079767 -0.0220023788 [35,] 0.0461658438 0.1118079767 [36,] 0.1202591707 0.0461658438 [37,] 0.0465066112 0.1202591707 [38,] -0.8860921630 0.0465066112 [39,] 0.0153324625 -0.8860921630 [40,] 0.0339187703 0.0153324625 [41,] -0.0490602853 0.0339187703 [42,] -0.0037810263 -0.0490602853 [43,] -0.0570452369 -0.0037810263 [44,] 0.0376715928 -0.0570452369 [45,] -0.0375086117 0.0376715928 [46,] 0.0857087011 -0.0375086117 [47,] 0.0665048238 0.0857087011 [48,] 0.0947704276 0.0665048238 [49,] 0.0500922411 0.0947704276 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.1194748746 0.3836677125 2 -0.7557079765 0.1194748746 3 -0.0057068106 -0.7557079765 4 0.0647443494 -0.0057068106 5 -0.0520008541 0.0647443494 6 0.9645707787 -0.0520008541 7 -0.0638244026 0.9645707787 8 -0.0731131799 -0.0638244026 9 0.0563573049 -0.0731131799 10 -1.1479383461 0.0563573049 11 0.0263202496 -1.1479383461 12 -0.1849403960 0.0263202496 13 -0.0616746142 -0.1849403960 14 0.8092941739 -0.0616746142 15 -0.0779927836 0.8092941739 16 -0.1417399578 -0.0779927836 17 -0.0473726247 -0.1417399578 18 -1.0826554767 -0.0473726247 19 0.0004585178 -1.0826554767 20 0.9368877982 0.0004585178 21 0.0717810252 0.9368877982 22 -0.0664551592 0.0717810252 23 0.0626475323 -0.0664551592 24 0.8828948558 0.0626475323 25 0.0383163549 0.8828948558 26 -0.1468152685 0.0383163549 27 -0.0732444772 -0.1468152685 28 -0.1224981739 -0.0732444772 29 -0.0357176091 -0.1224981739 30 0.0099162361 -0.0357176091 31 -0.0168071529 0.0099162361 32 0.0756245798 -0.0168071529 33 -0.0220023788 0.0756245798 34 0.1118079767 -0.0220023788 35 0.0461658438 0.1118079767 36 0.1202591707 0.0461658438 37 0.0465066112 0.1202591707 38 -0.8860921630 0.0465066112 39 0.0153324625 -0.8860921630 40 0.0339187703 0.0153324625 41 -0.0490602853 0.0339187703 42 -0.0037810263 -0.0490602853 43 -0.0570452369 -0.0037810263 44 0.0376715928 -0.0570452369 45 -0.0375086117 0.0376715928 46 0.0857087011 -0.0375086117 47 0.0665048238 0.0857087011 48 0.0947704276 0.0665048238 49 0.0500922411 0.0947704276 > 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/wessaorg/rcomp/tmp/7nca21354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/80er71354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/9zclc1354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/10787b1354824687.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/11nzrw1354824687.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/wessaorg/rcomp/tmp/12o74w1354824688.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/wessaorg/rcomp/tmp/13x9yj1354824688.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/wessaorg/rcomp/tmp/14vv1e1354824688.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/wessaorg/rcomp/tmp/1579qt1354824688.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/wessaorg/rcomp/tmp/165gei1354824688.tab") + } > > try(system("convert tmp/13dad1354824687.ps tmp/13dad1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/273en1354824687.ps tmp/273en1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/3lgwc1354824687.ps tmp/3lgwc1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/421xg1354824687.ps tmp/421xg1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/5mv8r1354824687.ps tmp/5mv8r1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/6a9ff1354824687.ps tmp/6a9ff1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/7nca21354824687.ps tmp/7nca21354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/80er71354824687.ps tmp/80er71354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/9zclc1354824687.ps tmp/9zclc1354824687.png",intern=TRUE)) character(0) > try(system("convert tmp/10787b1354824687.ps tmp/10787b1354824687.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 8.313 1.676 10.001