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(20.7246301,0,21.44580352,0,22.09413114,0,21.53321848,0,23.3470789,0,23.5656163,0,26.42117166,0,25.21193138,0,26.43574082,0,29.33500366,0,29.40056488,0,33.05013946,0,28.38072368,0,26.0059506,0,29.31314992,0,30.36212944,0,35.74543406,0,36.15337054,0,34.20838768,0,37.90895432,0,38.70297354,0,42.11944156,0,42.16314904,0,39.79566054,0,37.36261082,0,38.3533137,0,42.60022384,0,41.24529196,0,42.15586446,0,46.94183352,0,47.42990038,0,47.0583868,0,50.18347162,0,50.12519498,0,43.22669772,0,40.04333626,0,40.37114236,0,42.2141411,0,36.99838182,0,39.74466848,0,42.68035422,0,46.2935059,0,46.97097184,0,48.72655562,0,52.36884562,0,50.05234918,0,54.03701444,0,57.78128856,0,64.71620872,0,63.4122689,0,64.3592643,0,66.02743312,0,72.13919574,0,76.60464328,0,86.97060062,0,93.48301514,0,95.58825876,0,81.88596378,1,70.5511573,1,50.38015528,1,36.24807008,1),dim=c(2,61),dimnames=list(c('Olie','Dumivariabele'),1:61)) > y <- array(NA,dim=c(2,61),dimnames=list(c('Olie','Dumivariabele'),1:61)) > 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) > 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 Olie Dumivariabele 1 20.72463 0 2 21.44580 0 3 22.09413 0 4 21.53322 0 5 23.34708 0 6 23.56562 0 7 26.42117 0 8 25.21193 0 9 26.43574 0 10 29.33500 0 11 29.40056 0 12 33.05014 0 13 28.38072 0 14 26.00595 0 15 29.31315 0 16 30.36213 0 17 35.74543 0 18 36.15337 0 19 34.20839 0 20 37.90895 0 21 38.70297 0 22 42.11944 0 23 42.16315 0 24 39.79566 0 25 37.36261 0 26 38.35331 0 27 42.60022 0 28 41.24529 0 29 42.15586 0 30 46.94183 0 31 47.42990 0 32 47.05839 0 33 50.18347 0 34 50.12519 0 35 43.22670 0 36 40.04334 0 37 40.37114 0 38 42.21414 0 39 36.99838 0 40 39.74467 0 41 42.68035 0 42 46.29351 0 43 46.97097 0 44 48.72656 0 45 52.36885 0 46 50.05235 0 47 54.03701 0 48 57.78129 0 49 64.71621 0 50 63.41227 0 51 64.35926 0 52 66.02743 0 53 72.13920 0 54 76.60464 0 55 86.97060 0 56 93.48302 0 57 95.58826 0 58 81.88596 1 59 70.55116 1 60 50.38016 1 61 36.24807 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Dumivariabele 43.71 16.05 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -23.518 -13.352 -2.469 6.411 51.874 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 43.714 2.325 18.806 <2e-16 *** Dumivariabele 16.052 9.077 1.768 0.0822 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 17.55 on 59 degrees of freedom Multiple R-squared: 0.05034, Adjusted R-squared: 0.03424 F-statistic: 3.127 on 1 and 59 DF, p-value: 0.08217 > postscript(file="/var/www/html/rcomp/tmp/12cz91229870727.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/2syxp1229870727.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/3v2j21229870727.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/4yg0l1229870727.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/56woy1229870727.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 61 Frequency = 1 1 2 3 4 5 6 -22.9892399 -22.2680665 -21.6197388 -22.1806515 -20.3667911 -20.1482537 7 8 9 10 11 12 -17.2926983 -18.5019386 -17.2781292 -14.3788663 -14.3133051 -10.6637305 13 14 15 16 17 18 -15.3331463 -17.7079194 -14.4007201 -13.3517405 -7.9684359 -7.5604994 19 20 21 22 23 24 -9.5054823 -5.8049157 -5.0108964 -1.5944284 -1.5507209 -3.9182094 25 26 27 28 29 30 -6.3512592 -5.3605563 -1.1136461 -2.4685780 -1.5580055 3.2279635 31 32 33 34 35 36 3.7160304 3.3445168 6.4696016 6.4113250 -0.4871723 -3.6705337 37 38 39 40 41 42 -3.3427276 -1.4997289 -6.7154882 -3.9692015 -1.0335158 2.5796359 43 44 45 46 47 48 3.2571019 5.0126856 8.6549756 6.3384792 10.3231445 14.0674186 49 50 51 52 53 54 21.0023387 19.6983989 20.6453943 22.3135631 28.4253258 32.8907733 55 56 57 58 59 60 43.2567306 49.7691452 51.8743888 22.1196272 10.7848207 -9.3861813 61 -23.5182665 > postscript(file="/var/www/html/rcomp/tmp/6od1h1229870727.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 = 61 Frequency = 1 lag(myerror, k = 1) myerror 0 -22.9892399 NA 1 -22.2680665 -22.9892399 2 -21.6197388 -22.2680665 3 -22.1806515 -21.6197388 4 -20.3667911 -22.1806515 5 -20.1482537 -20.3667911 6 -17.2926983 -20.1482537 7 -18.5019386 -17.2926983 8 -17.2781292 -18.5019386 9 -14.3788663 -17.2781292 10 -14.3133051 -14.3788663 11 -10.6637305 -14.3133051 12 -15.3331463 -10.6637305 13 -17.7079194 -15.3331463 14 -14.4007201 -17.7079194 15 -13.3517405 -14.4007201 16 -7.9684359 -13.3517405 17 -7.5604994 -7.9684359 18 -9.5054823 -7.5604994 19 -5.8049157 -9.5054823 20 -5.0108964 -5.8049157 21 -1.5944284 -5.0108964 22 -1.5507209 -1.5944284 23 -3.9182094 -1.5507209 24 -6.3512592 -3.9182094 25 -5.3605563 -6.3512592 26 -1.1136461 -5.3605563 27 -2.4685780 -1.1136461 28 -1.5580055 -2.4685780 29 3.2279635 -1.5580055 30 3.7160304 3.2279635 31 3.3445168 3.7160304 32 6.4696016 3.3445168 33 6.4113250 6.4696016 34 -0.4871723 6.4113250 35 -3.6705337 -0.4871723 36 -3.3427276 -3.6705337 37 -1.4997289 -3.3427276 38 -6.7154882 -1.4997289 39 -3.9692015 -6.7154882 40 -1.0335158 -3.9692015 41 2.5796359 -1.0335158 42 3.2571019 2.5796359 43 5.0126856 3.2571019 44 8.6549756 5.0126856 45 6.3384792 8.6549756 46 10.3231445 6.3384792 47 14.0674186 10.3231445 48 21.0023387 14.0674186 49 19.6983989 21.0023387 50 20.6453943 19.6983989 51 22.3135631 20.6453943 52 28.4253258 22.3135631 53 32.8907733 28.4253258 54 43.2567306 32.8907733 55 49.7691452 43.2567306 56 51.8743888 49.7691452 57 22.1196272 51.8743888 58 10.7848207 22.1196272 59 -9.3861813 10.7848207 60 -23.5182665 -9.3861813 61 NA -23.5182665 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -22.2680665 -22.9892399 [2,] -21.6197388 -22.2680665 [3,] -22.1806515 -21.6197388 [4,] -20.3667911 -22.1806515 [5,] -20.1482537 -20.3667911 [6,] -17.2926983 -20.1482537 [7,] -18.5019386 -17.2926983 [8,] -17.2781292 -18.5019386 [9,] -14.3788663 -17.2781292 [10,] -14.3133051 -14.3788663 [11,] -10.6637305 -14.3133051 [12,] -15.3331463 -10.6637305 [13,] -17.7079194 -15.3331463 [14,] -14.4007201 -17.7079194 [15,] -13.3517405 -14.4007201 [16,] -7.9684359 -13.3517405 [17,] -7.5604994 -7.9684359 [18,] -9.5054823 -7.5604994 [19,] -5.8049157 -9.5054823 [20,] -5.0108964 -5.8049157 [21,] -1.5944284 -5.0108964 [22,] -1.5507209 -1.5944284 [23,] -3.9182094 -1.5507209 [24,] -6.3512592 -3.9182094 [25,] -5.3605563 -6.3512592 [26,] -1.1136461 -5.3605563 [27,] -2.4685780 -1.1136461 [28,] -1.5580055 -2.4685780 [29,] 3.2279635 -1.5580055 [30,] 3.7160304 3.2279635 [31,] 3.3445168 3.7160304 [32,] 6.4696016 3.3445168 [33,] 6.4113250 6.4696016 [34,] -0.4871723 6.4113250 [35,] -3.6705337 -0.4871723 [36,] -3.3427276 -3.6705337 [37,] -1.4997289 -3.3427276 [38,] -6.7154882 -1.4997289 [39,] -3.9692015 -6.7154882 [40,] -1.0335158 -3.9692015 [41,] 2.5796359 -1.0335158 [42,] 3.2571019 2.5796359 [43,] 5.0126856 3.2571019 [44,] 8.6549756 5.0126856 [45,] 6.3384792 8.6549756 [46,] 10.3231445 6.3384792 [47,] 14.0674186 10.3231445 [48,] 21.0023387 14.0674186 [49,] 19.6983989 21.0023387 [50,] 20.6453943 19.6983989 [51,] 22.3135631 20.6453943 [52,] 28.4253258 22.3135631 [53,] 32.8907733 28.4253258 [54,] 43.2567306 32.8907733 [55,] 49.7691452 43.2567306 [56,] 51.8743888 49.7691452 [57,] 22.1196272 51.8743888 [58,] 10.7848207 22.1196272 [59,] -9.3861813 10.7848207 [60,] -23.5182665 -9.3861813 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -22.2680665 -22.9892399 2 -21.6197388 -22.2680665 3 -22.1806515 -21.6197388 4 -20.3667911 -22.1806515 5 -20.1482537 -20.3667911 6 -17.2926983 -20.1482537 7 -18.5019386 -17.2926983 8 -17.2781292 -18.5019386 9 -14.3788663 -17.2781292 10 -14.3133051 -14.3788663 11 -10.6637305 -14.3133051 12 -15.3331463 -10.6637305 13 -17.7079194 -15.3331463 14 -14.4007201 -17.7079194 15 -13.3517405 -14.4007201 16 -7.9684359 -13.3517405 17 -7.5604994 -7.9684359 18 -9.5054823 -7.5604994 19 -5.8049157 -9.5054823 20 -5.0108964 -5.8049157 21 -1.5944284 -5.0108964 22 -1.5507209 -1.5944284 23 -3.9182094 -1.5507209 24 -6.3512592 -3.9182094 25 -5.3605563 -6.3512592 26 -1.1136461 -5.3605563 27 -2.4685780 -1.1136461 28 -1.5580055 -2.4685780 29 3.2279635 -1.5580055 30 3.7160304 3.2279635 31 3.3445168 3.7160304 32 6.4696016 3.3445168 33 6.4113250 6.4696016 34 -0.4871723 6.4113250 35 -3.6705337 -0.4871723 36 -3.3427276 -3.6705337 37 -1.4997289 -3.3427276 38 -6.7154882 -1.4997289 39 -3.9692015 -6.7154882 40 -1.0335158 -3.9692015 41 2.5796359 -1.0335158 42 3.2571019 2.5796359 43 5.0126856 3.2571019 44 8.6549756 5.0126856 45 6.3384792 8.6549756 46 10.3231445 6.3384792 47 14.0674186 10.3231445 48 21.0023387 14.0674186 49 19.6983989 21.0023387 50 20.6453943 19.6983989 51 22.3135631 20.6453943 52 28.4253258 22.3135631 53 32.8907733 28.4253258 54 43.2567306 32.8907733 55 49.7691452 43.2567306 56 51.8743888 49.7691452 57 22.1196272 51.8743888 58 10.7848207 22.1196272 59 -9.3861813 10.7848207 60 -23.5182665 -9.3861813 > 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/7lksf1229870727.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/8tlie1229870727.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/9uucg1229870727.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 > > #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/109jw91229870727.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/11v47w1229870727.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/12emij1229870727.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/13m6cs1229870727.tab") > > system("convert tmp/12cz91229870727.ps tmp/12cz91229870727.png") > system("convert tmp/2syxp1229870727.ps tmp/2syxp1229870727.png") > system("convert tmp/3v2j21229870727.ps tmp/3v2j21229870727.png") > system("convert tmp/4yg0l1229870727.ps tmp/4yg0l1229870727.png") > system("convert tmp/56woy1229870727.ps tmp/56woy1229870727.png") > system("convert tmp/6od1h1229870727.ps tmp/6od1h1229870727.png") > system("convert tmp/7lksf1229870727.ps tmp/7lksf1229870727.png") > system("convert tmp/8tlie1229870727.ps tmp/8tlie1229870727.png") > system("convert tmp/9uucg1229870727.ps tmp/9uucg1229870727.png") > > > proc.time() user system elapsed 1.788 1.325 2.350