R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(-3.3,0,-3.5,0,-3.5,0,-8.4,0,-15.7,0,-18.7,0,-22.8,0,-20.7,0,-14,0,-6.3,0,0.7,0,0.2,0,0.8,0,1.2,0,4.5,0,0.4,0,5.9,0,6.5,0,12.8,0,4.2,0,-3.3,0,-12.5,0,-16.3,0,-10.5,0,-11.8,0,-11.4,0,-17.7,0,-17.3,0,-18.6,0,-17.9,0,-21.4,0,-19.4,0,-15.5,0,-7.7,0,-0.7,0,-1.6,0,1.4,0,0.7,0,9.5,0,1.4,0,4.1,0,6.6,0,18.4,0,16.9,0,9.2,0,-4.3,0,-5.9,0,-7.7,0,-5.4,0,-2.3,0,-4.8,0,2.3,0,-5.2,0,-10,0,-17.1,0,-14.4,0,-3.9,0,3.7,0,6.5,0,0.9,0,-4.1,0,-7,0,-12.2,0,-2.5,0,4.4,0,13.7,0,12.3,0,13.4,0,2.2,0,1.7,0,-7.2,0,-4.8,0,-2.9,0,-2.4,0,-2.5,0,-5.3,0,-7.1,0,-8,0,-8.9,1,-7.7,1,-1.1,1,4,1,9.6,1,10.9,1,13,1,14.9,1,20.1,1,10.8,1,11,1,3.8,1,10.8,1,7.6,1,10.2,1,2.2,1,-0.1,1,-1.7,1,-4.8,1),dim=c(2,97),dimnames=list(c('Registraties','Dummies'),1:97)) > y <- array(NA,dim=c(2,97),dimnames=list(c('Registraties','Dummies'),1:97)) > 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 = '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 Registraties Dummies 1 -3.3 0 2 -3.5 0 3 -3.5 0 4 -8.4 0 5 -15.7 0 6 -18.7 0 7 -22.8 0 8 -20.7 0 9 -14.0 0 10 -6.3 0 11 0.7 0 12 0.2 0 13 0.8 0 14 1.2 0 15 4.5 0 16 0.4 0 17 5.9 0 18 6.5 0 19 12.8 0 20 4.2 0 21 -3.3 0 22 -12.5 0 23 -16.3 0 24 -10.5 0 25 -11.8 0 26 -11.4 0 27 -17.7 0 28 -17.3 0 29 -18.6 0 30 -17.9 0 31 -21.4 0 32 -19.4 0 33 -15.5 0 34 -7.7 0 35 -0.7 0 36 -1.6 0 37 1.4 0 38 0.7 0 39 9.5 0 40 1.4 0 41 4.1 0 42 6.6 0 43 18.4 0 44 16.9 0 45 9.2 0 46 -4.3 0 47 -5.9 0 48 -7.7 0 49 -5.4 0 50 -2.3 0 51 -4.8 0 52 2.3 0 53 -5.2 0 54 -10.0 0 55 -17.1 0 56 -14.4 0 57 -3.9 0 58 3.7 0 59 6.5 0 60 0.9 0 61 -4.1 0 62 -7.0 0 63 -12.2 0 64 -2.5 0 65 4.4 0 66 13.7 0 67 12.3 0 68 13.4 0 69 2.2 0 70 1.7 0 71 -7.2 0 72 -4.8 0 73 -2.9 0 74 -2.4 0 75 -2.5 0 76 -5.3 0 77 -7.1 0 78 -8.0 0 79 -8.9 1 80 -7.7 1 81 -1.1 1 82 4.0 1 83 9.6 1 84 10.9 1 85 13.0 1 86 14.9 1 87 20.1 1 88 10.8 1 89 11.0 1 90 3.8 1 91 10.8 1 92 7.6 1 93 10.2 1 94 2.2 1 95 -0.1 1 96 -1.7 1 97 -4.8 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Dummies -3.859 9.364 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -18.941 -6.605 0.359 5.395 22.259 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.859 1.047 -3.686 0.000380 *** Dummies 9.364 2.366 3.958 0.000146 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 9.247 on 95 degrees of freedom Multiple R-squared: 0.1416, Adjusted R-squared: 0.1325 F-statistic: 15.67 on 1 and 95 DF, p-value: 0.0001457 > 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.2724835 0.54496695 0.727516525 [2,] 0.3843851 0.76877019 0.615614904 [3,] 0.5503636 0.89927276 0.449636381 [4,] 0.5675227 0.86495456 0.432477282 [5,] 0.4632428 0.92648555 0.536757227 [6,] 0.3958059 0.79161179 0.604194107 [7,] 0.4648116 0.92962329 0.535188356 [8,] 0.4837610 0.96752199 0.516239007 [9,] 0.4934571 0.98691423 0.506542883 [10,] 0.4939272 0.98785439 0.506072807 [11,] 0.5453635 0.90927305 0.454636524 [12,] 0.5085013 0.98299747 0.491498737 [13,] 0.5580769 0.88384615 0.441923074 [14,] 0.6013830 0.79723401 0.398617003 [15,] 0.7550598 0.48988034 0.244940169 [16,] 0.7386097 0.52278056 0.261390282 [17,] 0.6759508 0.64809833 0.324049167 [18,] 0.6609692 0.67806157 0.339030787 [19,] 0.6959006 0.60819882 0.304099409 [20,] 0.6576855 0.68462909 0.342314544 [21,] 0.6297175 0.74056504 0.370282521 [22,] 0.5968235 0.80635306 0.403176530 [23,] 0.6499437 0.70011265 0.350056324 [24,] 0.6917594 0.61648128 0.308240642 [25,] 0.7505598 0.49888034 0.249440171 [26,] 0.7941289 0.41174229 0.205871147 [27,] 0.8771099 0.24578016 0.122890081 [28,] 0.9201296 0.15974074 0.079870371 [29,] 0.9315479 0.13690411 0.068452057 [30,] 0.9158917 0.16821654 0.084108269 [31,] 0.9006207 0.19875864 0.099379320 [32,] 0.8804342 0.23913167 0.119565833 [33,] 0.8677861 0.26442786 0.132213932 [34,] 0.8497342 0.30053161 0.150265805 [35,] 0.8937582 0.21248360 0.106241801 [36,] 0.8779871 0.24402585 0.122012925 [37,] 0.8734022 0.25319567 0.126597834 [38,] 0.8837191 0.23256189 0.116280945 [39,] 0.9711933 0.05761331 0.028806656 [40,] 0.9934959 0.01300813 0.006504067 [41,] 0.9956276 0.00874471 0.004372355 [42,] 0.9933705 0.01325908 0.006629539 [43,] 0.9904197 0.01916055 0.009580275 [44,] 0.9872161 0.02556783 0.012783914 [45,] 0.9819533 0.03609338 0.018046689 [46,] 0.9744439 0.05111211 0.025556053 [47,] 0.9648214 0.07035726 0.035178631 [48,] 0.9567669 0.08646619 0.043233094 [49,] 0.9424083 0.11518339 0.057591697 [50,] 0.9358631 0.12827376 0.064136882 [51,] 0.9619514 0.07609715 0.038048574 [52,] 0.9730186 0.05396286 0.026981430 [53,] 0.9634072 0.07318551 0.036592753 [54,] 0.9559436 0.08811280 0.044056399 [55,] 0.9552012 0.08959755 0.044798777 [56,] 0.9410462 0.11790753 0.058953766 [57,] 0.9224063 0.15518746 0.077593732 [58,] 0.9075175 0.18496492 0.092482459 [59,] 0.9221266 0.15574688 0.077873441 [60,] 0.8988513 0.20229735 0.101148676 [61,] 0.8811966 0.23760685 0.118803425 [62,] 0.9330124 0.13397515 0.066987573 [63,] 0.9632791 0.07344176 0.036720881 [64,] 0.9882801 0.02343985 0.011719927 [65,] 0.9856051 0.02878975 0.014394874 [66,] 0.9824969 0.03500618 0.017503091 [67,] 0.9741095 0.05178107 0.025890535 [68,] 0.9610966 0.07780683 0.038903415 [69,] 0.9439016 0.11219676 0.056098381 [70,] 0.9224934 0.15501320 0.077506599 [71,] 0.8968675 0.20626506 0.103132530 [72,] 0.8600073 0.27998546 0.139992731 [73,] 0.8133945 0.37321101 0.186605506 [74,] 0.7576549 0.48469020 0.242345101 [75,] 0.8411531 0.31769381 0.158846904 [76,] 0.9117567 0.17648663 0.088243316 [77,] 0.9134432 0.17311357 0.086556783 [78,] 0.8848937 0.23021252 0.115106258 [79,] 0.8442854 0.31142918 0.155714588 [80,] 0.7976706 0.40465872 0.202329360 [81,] 0.7626806 0.47463877 0.237319385 [82,] 0.7586417 0.48271665 0.241358324 [83,] 0.9021221 0.19575577 0.097877883 [84,] 0.8790952 0.24180953 0.120904763 [85,] 0.8657537 0.26849267 0.134246336 [86,] 0.7712960 0.45740810 0.228704048 [87,] 0.7648615 0.47027702 0.235138511 [88,] 0.6911789 0.61764215 0.308821074 > postscript(file="/var/www/html/rcomp/tmp/1i83i1227777240.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/2r53h1227777240.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/3fczx1227777240.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/4tmlg1227777240.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/5tgy11227777240.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 = 97 Frequency = 1 1 2 3 4 5 6 0.55897436 0.35897436 0.35897436 -4.54102564 -11.84102564 -14.84102564 7 8 9 10 11 12 -18.94102564 -16.84102564 -10.14102564 -2.44102564 4.55897436 4.05897436 13 14 15 16 17 18 4.65897436 5.05897436 8.35897436 4.25897436 9.75897436 10.35897436 19 20 21 22 23 24 16.65897436 8.05897436 0.55897436 -8.64102564 -12.44102564 -6.64102564 25 26 27 28 29 30 -7.94102564 -7.54102564 -13.84102564 -13.44102564 -14.74102564 -14.04102564 31 32 33 34 35 36 -17.54102564 -15.54102564 -11.64102564 -3.84102564 3.15897436 2.25897436 37 38 39 40 41 42 5.25897436 4.55897436 13.35897436 5.25897436 7.95897436 10.45897436 43 44 45 46 47 48 22.25897436 20.75897436 13.05897436 -0.44102564 -2.04102564 -3.84102564 49 50 51 52 53 54 -1.54102564 1.55897436 -0.94102564 6.15897436 -1.34102564 -6.14102564 55 56 57 58 59 60 -13.24102564 -10.54102564 -0.04102564 7.55897436 10.35897436 4.75897436 61 62 63 64 65 66 -0.24102564 -3.14102564 -8.34102564 1.35897436 8.25897436 17.55897436 67 68 69 70 71 72 16.15897436 17.25897436 6.05897436 5.55897436 -3.34102564 -0.94102564 73 74 75 76 77 78 0.95897436 1.45897436 1.35897436 -1.44102564 -3.24102564 -4.14102564 79 80 81 82 83 84 -14.40526316 -13.20526316 -6.60526316 -1.50526316 4.09473684 5.39473684 85 86 87 88 89 90 7.49473684 9.39473684 14.59473684 5.29473684 5.49473684 -1.70526316 91 92 93 94 95 96 5.29473684 2.09473684 4.69473684 -3.30526316 -5.60526316 -7.20526316 97 -10.30526316 > postscript(file="/var/www/html/rcomp/tmp/6dlvr1227777240.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 = 97 Frequency = 1 lag(myerror, k = 1) myerror 0 0.55897436 NA 1 0.35897436 0.55897436 2 0.35897436 0.35897436 3 -4.54102564 0.35897436 4 -11.84102564 -4.54102564 5 -14.84102564 -11.84102564 6 -18.94102564 -14.84102564 7 -16.84102564 -18.94102564 8 -10.14102564 -16.84102564 9 -2.44102564 -10.14102564 10 4.55897436 -2.44102564 11 4.05897436 4.55897436 12 4.65897436 4.05897436 13 5.05897436 4.65897436 14 8.35897436 5.05897436 15 4.25897436 8.35897436 16 9.75897436 4.25897436 17 10.35897436 9.75897436 18 16.65897436 10.35897436 19 8.05897436 16.65897436 20 0.55897436 8.05897436 21 -8.64102564 0.55897436 22 -12.44102564 -8.64102564 23 -6.64102564 -12.44102564 24 -7.94102564 -6.64102564 25 -7.54102564 -7.94102564 26 -13.84102564 -7.54102564 27 -13.44102564 -13.84102564 28 -14.74102564 -13.44102564 29 -14.04102564 -14.74102564 30 -17.54102564 -14.04102564 31 -15.54102564 -17.54102564 32 -11.64102564 -15.54102564 33 -3.84102564 -11.64102564 34 3.15897436 -3.84102564 35 2.25897436 3.15897436 36 5.25897436 2.25897436 37 4.55897436 5.25897436 38 13.35897436 4.55897436 39 5.25897436 13.35897436 40 7.95897436 5.25897436 41 10.45897436 7.95897436 42 22.25897436 10.45897436 43 20.75897436 22.25897436 44 13.05897436 20.75897436 45 -0.44102564 13.05897436 46 -2.04102564 -0.44102564 47 -3.84102564 -2.04102564 48 -1.54102564 -3.84102564 49 1.55897436 -1.54102564 50 -0.94102564 1.55897436 51 6.15897436 -0.94102564 52 -1.34102564 6.15897436 53 -6.14102564 -1.34102564 54 -13.24102564 -6.14102564 55 -10.54102564 -13.24102564 56 -0.04102564 -10.54102564 57 7.55897436 -0.04102564 58 10.35897436 7.55897436 59 4.75897436 10.35897436 60 -0.24102564 4.75897436 61 -3.14102564 -0.24102564 62 -8.34102564 -3.14102564 63 1.35897436 -8.34102564 64 8.25897436 1.35897436 65 17.55897436 8.25897436 66 16.15897436 17.55897436 67 17.25897436 16.15897436 68 6.05897436 17.25897436 69 5.55897436 6.05897436 70 -3.34102564 5.55897436 71 -0.94102564 -3.34102564 72 0.95897436 -0.94102564 73 1.45897436 0.95897436 74 1.35897436 1.45897436 75 -1.44102564 1.35897436 76 -3.24102564 -1.44102564 77 -4.14102564 -3.24102564 78 -14.40526316 -4.14102564 79 -13.20526316 -14.40526316 80 -6.60526316 -13.20526316 81 -1.50526316 -6.60526316 82 4.09473684 -1.50526316 83 5.39473684 4.09473684 84 7.49473684 5.39473684 85 9.39473684 7.49473684 86 14.59473684 9.39473684 87 5.29473684 14.59473684 88 5.49473684 5.29473684 89 -1.70526316 5.49473684 90 5.29473684 -1.70526316 91 2.09473684 5.29473684 92 4.69473684 2.09473684 93 -3.30526316 4.69473684 94 -5.60526316 -3.30526316 95 -7.20526316 -5.60526316 96 -10.30526316 -7.20526316 97 NA -10.30526316 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 0.35897436 0.55897436 [2,] 0.35897436 0.35897436 [3,] -4.54102564 0.35897436 [4,] -11.84102564 -4.54102564 [5,] -14.84102564 -11.84102564 [6,] -18.94102564 -14.84102564 [7,] -16.84102564 -18.94102564 [8,] -10.14102564 -16.84102564 [9,] -2.44102564 -10.14102564 [10,] 4.55897436 -2.44102564 [11,] 4.05897436 4.55897436 [12,] 4.65897436 4.05897436 [13,] 5.05897436 4.65897436 [14,] 8.35897436 5.05897436 [15,] 4.25897436 8.35897436 [16,] 9.75897436 4.25897436 [17,] 10.35897436 9.75897436 [18,] 16.65897436 10.35897436 [19,] 8.05897436 16.65897436 [20,] 0.55897436 8.05897436 [21,] -8.64102564 0.55897436 [22,] -12.44102564 -8.64102564 [23,] -6.64102564 -12.44102564 [24,] -7.94102564 -6.64102564 [25,] -7.54102564 -7.94102564 [26,] -13.84102564 -7.54102564 [27,] -13.44102564 -13.84102564 [28,] -14.74102564 -13.44102564 [29,] -14.04102564 -14.74102564 [30,] -17.54102564 -14.04102564 [31,] -15.54102564 -17.54102564 [32,] -11.64102564 -15.54102564 [33,] -3.84102564 -11.64102564 [34,] 3.15897436 -3.84102564 [35,] 2.25897436 3.15897436 [36,] 5.25897436 2.25897436 [37,] 4.55897436 5.25897436 [38,] 13.35897436 4.55897436 [39,] 5.25897436 13.35897436 [40,] 7.95897436 5.25897436 [41,] 10.45897436 7.95897436 [42,] 22.25897436 10.45897436 [43,] 20.75897436 22.25897436 [44,] 13.05897436 20.75897436 [45,] -0.44102564 13.05897436 [46,] -2.04102564 -0.44102564 [47,] -3.84102564 -2.04102564 [48,] -1.54102564 -3.84102564 [49,] 1.55897436 -1.54102564 [50,] -0.94102564 1.55897436 [51,] 6.15897436 -0.94102564 [52,] -1.34102564 6.15897436 [53,] -6.14102564 -1.34102564 [54,] -13.24102564 -6.14102564 [55,] -10.54102564 -13.24102564 [56,] -0.04102564 -10.54102564 [57,] 7.55897436 -0.04102564 [58,] 10.35897436 7.55897436 [59,] 4.75897436 10.35897436 [60,] -0.24102564 4.75897436 [61,] -3.14102564 -0.24102564 [62,] -8.34102564 -3.14102564 [63,] 1.35897436 -8.34102564 [64,] 8.25897436 1.35897436 [65,] 17.55897436 8.25897436 [66,] 16.15897436 17.55897436 [67,] 17.25897436 16.15897436 [68,] 6.05897436 17.25897436 [69,] 5.55897436 6.05897436 [70,] -3.34102564 5.55897436 [71,] -0.94102564 -3.34102564 [72,] 0.95897436 -0.94102564 [73,] 1.45897436 0.95897436 [74,] 1.35897436 1.45897436 [75,] -1.44102564 1.35897436 [76,] -3.24102564 -1.44102564 [77,] -4.14102564 -3.24102564 [78,] -14.40526316 -4.14102564 [79,] -13.20526316 -14.40526316 [80,] -6.60526316 -13.20526316 [81,] -1.50526316 -6.60526316 [82,] 4.09473684 -1.50526316 [83,] 5.39473684 4.09473684 [84,] 7.49473684 5.39473684 [85,] 9.39473684 7.49473684 [86,] 14.59473684 9.39473684 [87,] 5.29473684 14.59473684 [88,] 5.49473684 5.29473684 [89,] -1.70526316 5.49473684 [90,] 5.29473684 -1.70526316 [91,] 2.09473684 5.29473684 [92,] 4.69473684 2.09473684 [93,] -3.30526316 4.69473684 [94,] -5.60526316 -3.30526316 [95,] -7.20526316 -5.60526316 [96,] -10.30526316 -7.20526316 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 0.35897436 0.55897436 2 0.35897436 0.35897436 3 -4.54102564 0.35897436 4 -11.84102564 -4.54102564 5 -14.84102564 -11.84102564 6 -18.94102564 -14.84102564 7 -16.84102564 -18.94102564 8 -10.14102564 -16.84102564 9 -2.44102564 -10.14102564 10 4.55897436 -2.44102564 11 4.05897436 4.55897436 12 4.65897436 4.05897436 13 5.05897436 4.65897436 14 8.35897436 5.05897436 15 4.25897436 8.35897436 16 9.75897436 4.25897436 17 10.35897436 9.75897436 18 16.65897436 10.35897436 19 8.05897436 16.65897436 20 0.55897436 8.05897436 21 -8.64102564 0.55897436 22 -12.44102564 -8.64102564 23 -6.64102564 -12.44102564 24 -7.94102564 -6.64102564 25 -7.54102564 -7.94102564 26 -13.84102564 -7.54102564 27 -13.44102564 -13.84102564 28 -14.74102564 -13.44102564 29 -14.04102564 -14.74102564 30 -17.54102564 -14.04102564 31 -15.54102564 -17.54102564 32 -11.64102564 -15.54102564 33 -3.84102564 -11.64102564 34 3.15897436 -3.84102564 35 2.25897436 3.15897436 36 5.25897436 2.25897436 37 4.55897436 5.25897436 38 13.35897436 4.55897436 39 5.25897436 13.35897436 40 7.95897436 5.25897436 41 10.45897436 7.95897436 42 22.25897436 10.45897436 43 20.75897436 22.25897436 44 13.05897436 20.75897436 45 -0.44102564 13.05897436 46 -2.04102564 -0.44102564 47 -3.84102564 -2.04102564 48 -1.54102564 -3.84102564 49 1.55897436 -1.54102564 50 -0.94102564 1.55897436 51 6.15897436 -0.94102564 52 -1.34102564 6.15897436 53 -6.14102564 -1.34102564 54 -13.24102564 -6.14102564 55 -10.54102564 -13.24102564 56 -0.04102564 -10.54102564 57 7.55897436 -0.04102564 58 10.35897436 7.55897436 59 4.75897436 10.35897436 60 -0.24102564 4.75897436 61 -3.14102564 -0.24102564 62 -8.34102564 -3.14102564 63 1.35897436 -8.34102564 64 8.25897436 1.35897436 65 17.55897436 8.25897436 66 16.15897436 17.55897436 67 17.25897436 16.15897436 68 6.05897436 17.25897436 69 5.55897436 6.05897436 70 -3.34102564 5.55897436 71 -0.94102564 -3.34102564 72 0.95897436 -0.94102564 73 1.45897436 0.95897436 74 1.35897436 1.45897436 75 -1.44102564 1.35897436 76 -3.24102564 -1.44102564 77 -4.14102564 -3.24102564 78 -14.40526316 -4.14102564 79 -13.20526316 -14.40526316 80 -6.60526316 -13.20526316 81 -1.50526316 -6.60526316 82 4.09473684 -1.50526316 83 5.39473684 4.09473684 84 7.49473684 5.39473684 85 9.39473684 7.49473684 86 14.59473684 9.39473684 87 5.29473684 14.59473684 88 5.49473684 5.29473684 89 -1.70526316 5.49473684 90 5.29473684 -1.70526316 91 2.09473684 5.29473684 92 4.69473684 2.09473684 93 -3.30526316 4.69473684 94 -5.60526316 -3.30526316 95 -7.20526316 -5.60526316 96 -10.30526316 -7.20526316 > 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/7us2q1227777240.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/8q0jn1227777240.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/9nxuo1227777240.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/10w5w91227777240.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/110r2j1227777240.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/12u36k1227777240.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/13ykex1227777240.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/1483mh1227777240.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/1567qy1227777240.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/16av4y1227777241.tab") + } > > system("convert tmp/1i83i1227777240.ps tmp/1i83i1227777240.png") > system("convert tmp/2r53h1227777240.ps tmp/2r53h1227777240.png") > system("convert tmp/3fczx1227777240.ps tmp/3fczx1227777240.png") > system("convert tmp/4tmlg1227777240.ps tmp/4tmlg1227777240.png") > system("convert tmp/5tgy11227777240.ps tmp/5tgy11227777240.png") > system("convert tmp/6dlvr1227777240.ps tmp/6dlvr1227777240.png") > system("convert tmp/7us2q1227777240.ps tmp/7us2q1227777240.png") > system("convert tmp/8q0jn1227777240.ps tmp/8q0jn1227777240.png") > system("convert tmp/9nxuo1227777240.ps tmp/9nxuo1227777240.png") > system("convert tmp/10w5w91227777240.ps tmp/10w5w91227777240.png") > > > proc.time() user system elapsed 3.147 1.755 3.761