R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(106.8,0,113.7,0,102.5,0,96.6,0,92.1,0,95.6,0,102.3,0,98.6,0,98.2,0,104.5,0,84,0,73.8,0,103.9,0,106,0,97.2,0,102.6,0,89,0,93.8,0,116.7,0,106.8,0,98.5,0,118.7,0,90,0,91.9,0,113.3,0,113.1,1,104.1,1,108.7,1,96.7,1,101,1,116.9,1,105.8,1,99,1,129.4,1,83,1,88.9,1,115.9,1,104.2,1,113.4,1,112.2,1,100.8,1,107.3,1,126.6,1,102.9,1,117.9,1,128.8,1,87.5,1,93.8,1,122.7,1,126.2,1,124.6,1,116.7,1,115.2,1,111.1,1,129.9,1,113.3,1,118.5,1,133.5,1,102.1,1,102.4,1),dim=c(2,60),dimnames=list(c('totmetaal','ramp'),1:60)) > y <- array(NA,dim=c(2,60),dimnames=list(c('totmetaal','ramp'),1:60)) > 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 totmetaal ramp 1 106.8 0 2 113.7 0 3 102.5 0 4 96.6 0 5 92.1 0 6 95.6 0 7 102.3 0 8 98.6 0 9 98.2 0 10 104.5 0 11 84.0 0 12 73.8 0 13 103.9 0 14 106.0 0 15 97.2 0 16 102.6 0 17 89.0 0 18 93.8 0 19 116.7 0 20 106.8 0 21 98.5 0 22 118.7 0 23 90.0 0 24 91.9 0 25 113.3 0 26 113.1 1 27 104.1 1 28 108.7 1 29 96.7 1 30 101.0 1 31 116.9 1 32 105.8 1 33 99.0 1 34 129.4 1 35 83.0 1 36 88.9 1 37 115.9 1 38 104.2 1 39 113.4 1 40 112.2 1 41 100.8 1 42 107.3 1 43 126.6 1 44 102.9 1 45 117.9 1 46 128.8 1 47 87.5 1 48 93.8 1 49 122.7 1 50 126.2 1 51 124.6 1 52 116.7 1 53 115.2 1 54 111.1 1 55 129.9 1 56 113.3 1 57 118.5 1 58 133.5 1 59 102.1 1 60 102.4 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) ramp 99.88 10.80 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -27.6886 -7.8374 0.9614 6.9160 22.8114 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 99.884 2.367 42.198 < 2e-16 *** ramp 10.805 3.099 3.486 0.00094 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 11.84 on 58 degrees of freedom Multiple R-Squared: 0.1732, Adjusted R-squared: 0.159 F-statistic: 12.15 on 1 and 58 DF, p-value: 0.0009405 > postscript(file="/var/www/html/rcomp/tmp/16mv81195468985.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/2cvt01195468985.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/3v5dn1195468985.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/4m6un1195468985.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/5wwev1195468985.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 = 60 Frequency = 1 1 2 3 4 5 6 6.9160000 13.8160000 2.6160000 -3.2840000 -7.7840000 -4.2840000 7 8 9 10 11 12 2.4160000 -1.2840000 -1.6840000 4.6160000 -15.8840000 -26.0840000 13 14 15 16 17 18 4.0160000 6.1160000 -2.6840000 2.7160000 -10.8840000 -6.0840000 19 20 21 22 23 24 16.8160000 6.9160000 -1.3840000 18.8160000 -9.8840000 -7.9840000 25 26 27 28 29 30 13.4160000 2.4114286 -6.5885714 -1.9885714 -13.9885714 -9.6885714 31 32 33 34 35 36 6.2114286 -4.8885714 -11.6885714 18.7114286 -27.6885714 -21.7885714 37 38 39 40 41 42 5.2114286 -6.4885714 2.7114286 1.5114286 -9.8885714 -3.3885714 43 44 45 46 47 48 15.9114286 -7.7885714 7.2114286 18.1114286 -23.1885714 -16.8885714 49 50 51 52 53 54 12.0114286 15.5114286 13.9114286 6.0114286 4.5114286 0.4114286 55 56 57 58 59 60 19.2114286 2.6114286 7.8114286 22.8114286 -8.5885714 -8.2885714 > postscript(file="/var/www/html/rcomp/tmp/6vvz71195468985.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 = 60 Frequency = 1 lag(myerror, k = 1) myerror 0 6.9160000 NA 1 13.8160000 6.9160000 2 2.6160000 13.8160000 3 -3.2840000 2.6160000 4 -7.7840000 -3.2840000 5 -4.2840000 -7.7840000 6 2.4160000 -4.2840000 7 -1.2840000 2.4160000 8 -1.6840000 -1.2840000 9 4.6160000 -1.6840000 10 -15.8840000 4.6160000 11 -26.0840000 -15.8840000 12 4.0160000 -26.0840000 13 6.1160000 4.0160000 14 -2.6840000 6.1160000 15 2.7160000 -2.6840000 16 -10.8840000 2.7160000 17 -6.0840000 -10.8840000 18 16.8160000 -6.0840000 19 6.9160000 16.8160000 20 -1.3840000 6.9160000 21 18.8160000 -1.3840000 22 -9.8840000 18.8160000 23 -7.9840000 -9.8840000 24 13.4160000 -7.9840000 25 2.4114286 13.4160000 26 -6.5885714 2.4114286 27 -1.9885714 -6.5885714 28 -13.9885714 -1.9885714 29 -9.6885714 -13.9885714 30 6.2114286 -9.6885714 31 -4.8885714 6.2114286 32 -11.6885714 -4.8885714 33 18.7114286 -11.6885714 34 -27.6885714 18.7114286 35 -21.7885714 -27.6885714 36 5.2114286 -21.7885714 37 -6.4885714 5.2114286 38 2.7114286 -6.4885714 39 1.5114286 2.7114286 40 -9.8885714 1.5114286 41 -3.3885714 -9.8885714 42 15.9114286 -3.3885714 43 -7.7885714 15.9114286 44 7.2114286 -7.7885714 45 18.1114286 7.2114286 46 -23.1885714 18.1114286 47 -16.8885714 -23.1885714 48 12.0114286 -16.8885714 49 15.5114286 12.0114286 50 13.9114286 15.5114286 51 6.0114286 13.9114286 52 4.5114286 6.0114286 53 0.4114286 4.5114286 54 19.2114286 0.4114286 55 2.6114286 19.2114286 56 7.8114286 2.6114286 57 22.8114286 7.8114286 58 -8.5885714 22.8114286 59 -8.2885714 -8.5885714 60 NA -8.2885714 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 13.8160000 6.9160000 [2,] 2.6160000 13.8160000 [3,] -3.2840000 2.6160000 [4,] -7.7840000 -3.2840000 [5,] -4.2840000 -7.7840000 [6,] 2.4160000 -4.2840000 [7,] -1.2840000 2.4160000 [8,] -1.6840000 -1.2840000 [9,] 4.6160000 -1.6840000 [10,] -15.8840000 4.6160000 [11,] -26.0840000 -15.8840000 [12,] 4.0160000 -26.0840000 [13,] 6.1160000 4.0160000 [14,] -2.6840000 6.1160000 [15,] 2.7160000 -2.6840000 [16,] -10.8840000 2.7160000 [17,] -6.0840000 -10.8840000 [18,] 16.8160000 -6.0840000 [19,] 6.9160000 16.8160000 [20,] -1.3840000 6.9160000 [21,] 18.8160000 -1.3840000 [22,] -9.8840000 18.8160000 [23,] -7.9840000 -9.8840000 [24,] 13.4160000 -7.9840000 [25,] 2.4114286 13.4160000 [26,] -6.5885714 2.4114286 [27,] -1.9885714 -6.5885714 [28,] -13.9885714 -1.9885714 [29,] -9.6885714 -13.9885714 [30,] 6.2114286 -9.6885714 [31,] -4.8885714 6.2114286 [32,] -11.6885714 -4.8885714 [33,] 18.7114286 -11.6885714 [34,] -27.6885714 18.7114286 [35,] -21.7885714 -27.6885714 [36,] 5.2114286 -21.7885714 [37,] -6.4885714 5.2114286 [38,] 2.7114286 -6.4885714 [39,] 1.5114286 2.7114286 [40,] -9.8885714 1.5114286 [41,] -3.3885714 -9.8885714 [42,] 15.9114286 -3.3885714 [43,] -7.7885714 15.9114286 [44,] 7.2114286 -7.7885714 [45,] 18.1114286 7.2114286 [46,] -23.1885714 18.1114286 [47,] -16.8885714 -23.1885714 [48,] 12.0114286 -16.8885714 [49,] 15.5114286 12.0114286 [50,] 13.9114286 15.5114286 [51,] 6.0114286 13.9114286 [52,] 4.5114286 6.0114286 [53,] 0.4114286 4.5114286 [54,] 19.2114286 0.4114286 [55,] 2.6114286 19.2114286 [56,] 7.8114286 2.6114286 [57,] 22.8114286 7.8114286 [58,] -8.5885714 22.8114286 [59,] -8.2885714 -8.5885714 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 13.8160000 6.9160000 2 2.6160000 13.8160000 3 -3.2840000 2.6160000 4 -7.7840000 -3.2840000 5 -4.2840000 -7.7840000 6 2.4160000 -4.2840000 7 -1.2840000 2.4160000 8 -1.6840000 -1.2840000 9 4.6160000 -1.6840000 10 -15.8840000 4.6160000 11 -26.0840000 -15.8840000 12 4.0160000 -26.0840000 13 6.1160000 4.0160000 14 -2.6840000 6.1160000 15 2.7160000 -2.6840000 16 -10.8840000 2.7160000 17 -6.0840000 -10.8840000 18 16.8160000 -6.0840000 19 6.9160000 16.8160000 20 -1.3840000 6.9160000 21 18.8160000 -1.3840000 22 -9.8840000 18.8160000 23 -7.9840000 -9.8840000 24 13.4160000 -7.9840000 25 2.4114286 13.4160000 26 -6.5885714 2.4114286 27 -1.9885714 -6.5885714 28 -13.9885714 -1.9885714 29 -9.6885714 -13.9885714 30 6.2114286 -9.6885714 31 -4.8885714 6.2114286 32 -11.6885714 -4.8885714 33 18.7114286 -11.6885714 34 -27.6885714 18.7114286 35 -21.7885714 -27.6885714 36 5.2114286 -21.7885714 37 -6.4885714 5.2114286 38 2.7114286 -6.4885714 39 1.5114286 2.7114286 40 -9.8885714 1.5114286 41 -3.3885714 -9.8885714 42 15.9114286 -3.3885714 43 -7.7885714 15.9114286 44 7.2114286 -7.7885714 45 18.1114286 7.2114286 46 -23.1885714 18.1114286 47 -16.8885714 -23.1885714 48 12.0114286 -16.8885714 49 15.5114286 12.0114286 50 13.9114286 15.5114286 51 6.0114286 13.9114286 52 4.5114286 6.0114286 53 0.4114286 4.5114286 54 19.2114286 0.4114286 55 2.6114286 19.2114286 56 7.8114286 2.6114286 57 22.8114286 7.8114286 58 -8.5885714 22.8114286 59 -8.2885714 -8.5885714 > 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/7t2in1195468985.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/8lxmv1195468985.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/9ko911195468985.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 > 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/1012a71195468985.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/11buhk1195468985.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/12h19u1195468986.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/13h9uc1195468986.tab") > > system("convert tmp/16mv81195468985.ps tmp/16mv81195468985.png") > system("convert tmp/2cvt01195468985.ps tmp/2cvt01195468985.png") > system("convert tmp/3v5dn1195468985.ps tmp/3v5dn1195468985.png") > system("convert tmp/4m6un1195468985.ps tmp/4m6un1195468985.png") > system("convert tmp/5wwev1195468985.ps tmp/5wwev1195468985.png") > system("convert tmp/6vvz71195468985.ps tmp/6vvz71195468985.png") > system("convert tmp/7t2in1195468985.ps tmp/7t2in1195468985.png") > system("convert tmp/8lxmv1195468985.ps tmp/8lxmv1195468985.png") > system("convert tmp/9ko911195468985.ps tmp/9ko911195468985.png") > > > proc.time() user system elapsed 2.225 1.423 2.594