R version 2.6.1 (2007-11-26) 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(117,0,103.8,0,100.8,0,110.6,0,104,0,112.6,0,107.3,0,98.9,0,109.8,0,104.9,0,102.2,0,123.9,0,124.9,0,112.7,0,121.9,0,100.6,0,104.3,0,120.4,0,107.5,0,102.9,0,125.6,0,107.5,0,108.8,0,128.4,1,121.1,1,119.5,1,128.7,1,108.7,1,105.5,1,119.8,1,111.3,1,110.6,1,120.1,1,97.5,1,107.7,1,127.3,1,117.2,1,119.8,1,116.2,1,111,1,112.4,1,130.6,1,109.1,1,118.8,1,123.9,1,101.6,1,112.8,1,128,1,129.6,1,125.8,1,119.5,1,115.7,1,113.6,1,129.7,1,112,1,116.8,1,127,1,112.9,1,113.3,1,121.7,1),dim=c(2,60),dimnames=list(c('Cons','Wetg'),1:60)) > y <- array(NA,dim=c(2,60),dimnames=list(c('Cons','Wetg'),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 Cons Wetg 1 117.0 0 2 103.8 0 3 100.8 0 4 110.6 0 5 104.0 0 6 112.6 0 7 107.3 0 8 98.9 0 9 109.8 0 10 104.9 0 11 102.2 0 12 123.9 0 13 124.9 0 14 112.7 0 15 121.9 0 16 100.6 0 17 104.3 0 18 120.4 0 19 107.5 0 20 102.9 0 21 125.6 0 22 107.5 0 23 108.8 0 24 128.4 1 25 121.1 1 26 119.5 1 27 128.7 1 28 108.7 1 29 105.5 1 30 119.8 1 31 111.3 1 32 110.6 1 33 120.1 1 34 97.5 1 35 107.7 1 36 127.3 1 37 117.2 1 38 119.8 1 39 116.2 1 40 111.0 1 41 112.4 1 42 130.6 1 43 109.1 1 44 118.8 1 45 123.9 1 46 101.6 1 47 112.8 1 48 128.0 1 49 129.6 1 50 125.8 1 51 119.5 1 52 115.7 1 53 113.6 1 54 129.7 1 55 112.0 1 56 116.8 1 57 127.0 1 58 112.9 1 59 113.3 1 60 121.7 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Wetg 110.126 7.312 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -19.9378 -6.1290 -0.9378 6.5651 15.4739 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 110.126 1.735 63.48 < 2e-16 *** Wetg 7.312 2.209 3.31 0.00161 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 8.32 on 58 degrees of freedom Multiple R-Squared: 0.1589, Adjusted R-squared: 0.1444 F-statistic: 10.95 on 1 and 58 DF, p-value: 0.001610 > postscript(file="/var/www/html/rcomp/tmp/1dgsw1198185364.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/2ren01198185364.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/3rulf1198185364.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/47ufr1198185364.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/5y03e1198185364.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.8739130 -6.3260870 -9.3260870 0.4739130 -6.1260870 2.4739130 7 8 9 10 11 12 -2.8260870 -11.2260870 -0.3260870 -5.2260870 -7.9260870 13.7739130 13 14 15 16 17 18 14.7739130 2.5739130 11.7739130 -9.5260870 -5.8260870 10.2739130 19 20 21 22 23 24 -2.6260870 -7.2260870 15.4739130 -2.6260870 -1.3260870 10.9621622 25 26 27 28 29 30 3.6621622 2.0621622 11.2621622 -8.7378378 -11.9378378 2.3621622 31 32 33 34 35 36 -6.1378378 -6.8378378 2.6621622 -19.9378378 -9.7378378 9.8621622 37 38 39 40 41 42 -0.2378378 2.3621622 -1.2378378 -6.4378378 -5.0378378 13.1621622 43 44 45 46 47 48 -8.3378378 1.3621622 6.4621622 -15.8378378 -4.6378378 10.5621622 49 50 51 52 53 54 12.1621622 8.3621622 2.0621622 -1.7378378 -3.8378378 12.2621622 55 56 57 58 59 60 -5.4378378 -0.6378378 9.5621622 -4.5378378 -4.1378378 4.2621622 > postscript(file="/var/www/html/rcomp/tmp/6pkhi1198185364.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.8739130 NA 1 -6.3260870 6.8739130 2 -9.3260870 -6.3260870 3 0.4739130 -9.3260870 4 -6.1260870 0.4739130 5 2.4739130 -6.1260870 6 -2.8260870 2.4739130 7 -11.2260870 -2.8260870 8 -0.3260870 -11.2260870 9 -5.2260870 -0.3260870 10 -7.9260870 -5.2260870 11 13.7739130 -7.9260870 12 14.7739130 13.7739130 13 2.5739130 14.7739130 14 11.7739130 2.5739130 15 -9.5260870 11.7739130 16 -5.8260870 -9.5260870 17 10.2739130 -5.8260870 18 -2.6260870 10.2739130 19 -7.2260870 -2.6260870 20 15.4739130 -7.2260870 21 -2.6260870 15.4739130 22 -1.3260870 -2.6260870 23 10.9621622 -1.3260870 24 3.6621622 10.9621622 25 2.0621622 3.6621622 26 11.2621622 2.0621622 27 -8.7378378 11.2621622 28 -11.9378378 -8.7378378 29 2.3621622 -11.9378378 30 -6.1378378 2.3621622 31 -6.8378378 -6.1378378 32 2.6621622 -6.8378378 33 -19.9378378 2.6621622 34 -9.7378378 -19.9378378 35 9.8621622 -9.7378378 36 -0.2378378 9.8621622 37 2.3621622 -0.2378378 38 -1.2378378 2.3621622 39 -6.4378378 -1.2378378 40 -5.0378378 -6.4378378 41 13.1621622 -5.0378378 42 -8.3378378 13.1621622 43 1.3621622 -8.3378378 44 6.4621622 1.3621622 45 -15.8378378 6.4621622 46 -4.6378378 -15.8378378 47 10.5621622 -4.6378378 48 12.1621622 10.5621622 49 8.3621622 12.1621622 50 2.0621622 8.3621622 51 -1.7378378 2.0621622 52 -3.8378378 -1.7378378 53 12.2621622 -3.8378378 54 -5.4378378 12.2621622 55 -0.6378378 -5.4378378 56 9.5621622 -0.6378378 57 -4.5378378 9.5621622 58 -4.1378378 -4.5378378 59 4.2621622 -4.1378378 60 NA 4.2621622 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -6.3260870 6.8739130 [2,] -9.3260870 -6.3260870 [3,] 0.4739130 -9.3260870 [4,] -6.1260870 0.4739130 [5,] 2.4739130 -6.1260870 [6,] -2.8260870 2.4739130 [7,] -11.2260870 -2.8260870 [8,] -0.3260870 -11.2260870 [9,] -5.2260870 -0.3260870 [10,] -7.9260870 -5.2260870 [11,] 13.7739130 -7.9260870 [12,] 14.7739130 13.7739130 [13,] 2.5739130 14.7739130 [14,] 11.7739130 2.5739130 [15,] -9.5260870 11.7739130 [16,] -5.8260870 -9.5260870 [17,] 10.2739130 -5.8260870 [18,] -2.6260870 10.2739130 [19,] -7.2260870 -2.6260870 [20,] 15.4739130 -7.2260870 [21,] -2.6260870 15.4739130 [22,] -1.3260870 -2.6260870 [23,] 10.9621622 -1.3260870 [24,] 3.6621622 10.9621622 [25,] 2.0621622 3.6621622 [26,] 11.2621622 2.0621622 [27,] -8.7378378 11.2621622 [28,] -11.9378378 -8.7378378 [29,] 2.3621622 -11.9378378 [30,] -6.1378378 2.3621622 [31,] -6.8378378 -6.1378378 [32,] 2.6621622 -6.8378378 [33,] -19.9378378 2.6621622 [34,] -9.7378378 -19.9378378 [35,] 9.8621622 -9.7378378 [36,] -0.2378378 9.8621622 [37,] 2.3621622 -0.2378378 [38,] -1.2378378 2.3621622 [39,] -6.4378378 -1.2378378 [40,] -5.0378378 -6.4378378 [41,] 13.1621622 -5.0378378 [42,] -8.3378378 13.1621622 [43,] 1.3621622 -8.3378378 [44,] 6.4621622 1.3621622 [45,] -15.8378378 6.4621622 [46,] -4.6378378 -15.8378378 [47,] 10.5621622 -4.6378378 [48,] 12.1621622 10.5621622 [49,] 8.3621622 12.1621622 [50,] 2.0621622 8.3621622 [51,] -1.7378378 2.0621622 [52,] -3.8378378 -1.7378378 [53,] 12.2621622 -3.8378378 [54,] -5.4378378 12.2621622 [55,] -0.6378378 -5.4378378 [56,] 9.5621622 -0.6378378 [57,] -4.5378378 9.5621622 [58,] -4.1378378 -4.5378378 [59,] 4.2621622 -4.1378378 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -6.3260870 6.8739130 2 -9.3260870 -6.3260870 3 0.4739130 -9.3260870 4 -6.1260870 0.4739130 5 2.4739130 -6.1260870 6 -2.8260870 2.4739130 7 -11.2260870 -2.8260870 8 -0.3260870 -11.2260870 9 -5.2260870 -0.3260870 10 -7.9260870 -5.2260870 11 13.7739130 -7.9260870 12 14.7739130 13.7739130 13 2.5739130 14.7739130 14 11.7739130 2.5739130 15 -9.5260870 11.7739130 16 -5.8260870 -9.5260870 17 10.2739130 -5.8260870 18 -2.6260870 10.2739130 19 -7.2260870 -2.6260870 20 15.4739130 -7.2260870 21 -2.6260870 15.4739130 22 -1.3260870 -2.6260870 23 10.9621622 -1.3260870 24 3.6621622 10.9621622 25 2.0621622 3.6621622 26 11.2621622 2.0621622 27 -8.7378378 11.2621622 28 -11.9378378 -8.7378378 29 2.3621622 -11.9378378 30 -6.1378378 2.3621622 31 -6.8378378 -6.1378378 32 2.6621622 -6.8378378 33 -19.9378378 2.6621622 34 -9.7378378 -19.9378378 35 9.8621622 -9.7378378 36 -0.2378378 9.8621622 37 2.3621622 -0.2378378 38 -1.2378378 2.3621622 39 -6.4378378 -1.2378378 40 -5.0378378 -6.4378378 41 13.1621622 -5.0378378 42 -8.3378378 13.1621622 43 1.3621622 -8.3378378 44 6.4621622 1.3621622 45 -15.8378378 6.4621622 46 -4.6378378 -15.8378378 47 10.5621622 -4.6378378 48 12.1621622 10.5621622 49 8.3621622 12.1621622 50 2.0621622 8.3621622 51 -1.7378378 2.0621622 52 -3.8378378 -1.7378378 53 12.2621622 -3.8378378 54 -5.4378378 12.2621622 55 -0.6378378 -5.4378378 56 9.5621622 -0.6378378 57 -4.5378378 9.5621622 58 -4.1378378 -4.5378378 59 4.2621622 -4.1378378 > 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/7xtah1198185364.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/8zfp91198185364.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/9tmxu1198185364.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/10kn841198185364.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/11vcev1198185364.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/120oom1198185365.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/13kpza1198185365.tab") > > system("convert tmp/1dgsw1198185364.ps tmp/1dgsw1198185364.png") > system("convert tmp/2ren01198185364.ps tmp/2ren01198185364.png") > system("convert tmp/3rulf1198185364.ps tmp/3rulf1198185364.png") > system("convert tmp/47ufr1198185364.ps tmp/47ufr1198185364.png") > system("convert tmp/5y03e1198185364.ps tmp/5y03e1198185364.png") > system("convert tmp/6pkhi1198185364.ps tmp/6pkhi1198185364.png") > system("convert tmp/7xtah1198185364.ps tmp/7xtah1198185364.png") > system("convert tmp/8zfp91198185364.ps tmp/8zfp91198185364.png") > system("convert tmp/9tmxu1198185364.ps tmp/9tmxu1198185364.png") > > > proc.time() user system elapsed 4.006 2.503 4.341