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(332,0,0,182,0,0,-303,0,0,-443,0,0,908,0,0,4011,1,0,-2862,0,1,-1126,0,0,-50,0,0,3012,1,0,434,0,0,-273,0,0,-439,0,0,-1203,0,0,137,0,0,-102,0,0,1152,0,0,260,0,0,-1150,0,0,-299,0,0,-922,0,0,-1509,0,0,1152,0,0,-3,0,0,156,0,0,-1131,0,0,-1033,0,0,-130,0,0,-599,0,0,-1633,0,0,527,0,0,112,0,0,-895,0,0,669,0,0,-2126,0,1,-1779,0,0,-129,0,0,1922,0,0,674,0,0,185,0,0,-788,0,0,-696,0,0,-748,0,0,893,0,0,458,0,0,-78,0,0,-280,0,0,-1865,0,0,788,0,0,-916,0,0,1286,0,0,883,0,0,193,0,0,-2527,0,1,-1792,0,0,370,0,0,-2952,0,1,-403,0,0,-1478,0,0),dim=c(3,59),dimnames=list(c('X','Y','Z'),1:59)) > y <- array(NA,dim=c(3,59),dimnames=list(c('X','Y','Z'),1:59)) > 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 X Y Z 1 332 0 0 2 182 0 0 3 -303 0 0 4 -443 0 0 5 908 0 0 6 4011 1 0 7 -2862 0 1 8 -1126 0 0 9 -50 0 0 10 3012 1 0 11 434 0 0 12 -273 0 0 13 -439 0 0 14 -1203 0 0 15 137 0 0 16 -102 0 0 17 1152 0 0 18 260 0 0 19 -1150 0 0 20 -299 0 0 21 -922 0 0 22 -1509 0 0 23 1152 0 0 24 -3 0 0 25 156 0 0 26 -1131 0 0 27 -1033 0 0 28 -130 0 0 29 -599 0 0 30 -1633 0 0 31 527 0 0 32 112 0 0 33 -895 0 0 34 669 0 0 35 -2126 0 1 36 -1779 0 0 37 -129 0 0 38 1922 0 0 39 674 0 0 40 185 0 0 41 -788 0 0 42 -696 0 0 43 -748 0 0 44 893 0 0 45 458 0 0 46 -78 0 0 47 -280 0 0 48 -1865 0 0 49 788 0 0 50 -916 0 0 51 1286 0 0 52 883 0 0 53 193 0 0 54 -2527 0 1 55 -1792 0 0 56 370 0 0 57 -2952 0 1 58 -403 0 0 59 -1478 0 0 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Y Z -198.5 3710.0 -2418.2 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1666.47 -569.47 69.53 515.01 2120.53 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -198.5 117.1 -1.695 0.0957 . Y 3710.0 614.3 6.040 1.31e-07 *** Z -2418.2 442.2 -5.469 1.09e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 852.8 on 56 degrees of freedom Multiple R-Squared: 0.5552, Adjusted R-squared: 0.5393 F-statistic: 34.95 on 2 and 56 DF, p-value: 1.409e-10 > postscript(file="/var/www/html/rcomp/tmp/16o971200412749.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/2huca1200412749.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/34lo61200412749.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/4amp21200412749.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/5cp6y1200412749.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 = 59 Frequency = 1 1 2 3 4 5 6 7 530.5283 380.5283 -104.4717 -244.4717 1106.5283 499.5000 -245.2500 8 9 10 11 12 13 14 -927.4717 148.5283 -499.5000 632.5283 -74.4717 -240.4717 -1004.4717 15 16 17 18 19 20 21 335.5283 96.5283 1350.5283 458.5283 -951.4717 -100.4717 -723.4717 22 23 24 25 26 27 28 -1310.4717 1350.5283 195.5283 354.5283 -932.4717 -834.4717 68.5283 29 30 31 32 33 34 35 -400.4717 -1434.4717 725.5283 310.5283 -696.4717 867.5283 490.7500 36 37 38 39 40 41 42 -1580.4717 69.5283 2120.5283 872.5283 383.5283 -589.4717 -497.4717 43 44 45 46 47 48 49 -549.4717 1091.5283 656.5283 120.5283 -81.4717 -1666.4717 986.5283 50 51 52 53 54 55 56 -717.4717 1484.5283 1081.5283 391.5283 89.7500 -1593.4717 568.5283 57 58 59 -335.2500 -204.4717 -1279.4717 > postscript(file="/var/www/html/rcomp/tmp/62u531200412749.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 = 59 Frequency = 1 lag(myerror, k = 1) myerror 0 530.5283 NA 1 380.5283 530.5283 2 -104.4717 380.5283 3 -244.4717 -104.4717 4 1106.5283 -244.4717 5 499.5000 1106.5283 6 -245.2500 499.5000 7 -927.4717 -245.2500 8 148.5283 -927.4717 9 -499.5000 148.5283 10 632.5283 -499.5000 11 -74.4717 632.5283 12 -240.4717 -74.4717 13 -1004.4717 -240.4717 14 335.5283 -1004.4717 15 96.5283 335.5283 16 1350.5283 96.5283 17 458.5283 1350.5283 18 -951.4717 458.5283 19 -100.4717 -951.4717 20 -723.4717 -100.4717 21 -1310.4717 -723.4717 22 1350.5283 -1310.4717 23 195.5283 1350.5283 24 354.5283 195.5283 25 -932.4717 354.5283 26 -834.4717 -932.4717 27 68.5283 -834.4717 28 -400.4717 68.5283 29 -1434.4717 -400.4717 30 725.5283 -1434.4717 31 310.5283 725.5283 32 -696.4717 310.5283 33 867.5283 -696.4717 34 490.7500 867.5283 35 -1580.4717 490.7500 36 69.5283 -1580.4717 37 2120.5283 69.5283 38 872.5283 2120.5283 39 383.5283 872.5283 40 -589.4717 383.5283 41 -497.4717 -589.4717 42 -549.4717 -497.4717 43 1091.5283 -549.4717 44 656.5283 1091.5283 45 120.5283 656.5283 46 -81.4717 120.5283 47 -1666.4717 -81.4717 48 986.5283 -1666.4717 49 -717.4717 986.5283 50 1484.5283 -717.4717 51 1081.5283 1484.5283 52 391.5283 1081.5283 53 89.7500 391.5283 54 -1593.4717 89.7500 55 568.5283 -1593.4717 56 -335.2500 568.5283 57 -204.4717 -335.2500 58 -1279.4717 -204.4717 59 NA -1279.4717 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 380.5283 530.5283 [2,] -104.4717 380.5283 [3,] -244.4717 -104.4717 [4,] 1106.5283 -244.4717 [5,] 499.5000 1106.5283 [6,] -245.2500 499.5000 [7,] -927.4717 -245.2500 [8,] 148.5283 -927.4717 [9,] -499.5000 148.5283 [10,] 632.5283 -499.5000 [11,] -74.4717 632.5283 [12,] -240.4717 -74.4717 [13,] -1004.4717 -240.4717 [14,] 335.5283 -1004.4717 [15,] 96.5283 335.5283 [16,] 1350.5283 96.5283 [17,] 458.5283 1350.5283 [18,] -951.4717 458.5283 [19,] -100.4717 -951.4717 [20,] -723.4717 -100.4717 [21,] -1310.4717 -723.4717 [22,] 1350.5283 -1310.4717 [23,] 195.5283 1350.5283 [24,] 354.5283 195.5283 [25,] -932.4717 354.5283 [26,] -834.4717 -932.4717 [27,] 68.5283 -834.4717 [28,] -400.4717 68.5283 [29,] -1434.4717 -400.4717 [30,] 725.5283 -1434.4717 [31,] 310.5283 725.5283 [32,] -696.4717 310.5283 [33,] 867.5283 -696.4717 [34,] 490.7500 867.5283 [35,] -1580.4717 490.7500 [36,] 69.5283 -1580.4717 [37,] 2120.5283 69.5283 [38,] 872.5283 2120.5283 [39,] 383.5283 872.5283 [40,] -589.4717 383.5283 [41,] -497.4717 -589.4717 [42,] -549.4717 -497.4717 [43,] 1091.5283 -549.4717 [44,] 656.5283 1091.5283 [45,] 120.5283 656.5283 [46,] -81.4717 120.5283 [47,] -1666.4717 -81.4717 [48,] 986.5283 -1666.4717 [49,] -717.4717 986.5283 [50,] 1484.5283 -717.4717 [51,] 1081.5283 1484.5283 [52,] 391.5283 1081.5283 [53,] 89.7500 391.5283 [54,] -1593.4717 89.7500 [55,] 568.5283 -1593.4717 [56,] -335.2500 568.5283 [57,] -204.4717 -335.2500 [58,] -1279.4717 -204.4717 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 380.5283 530.5283 2 -104.4717 380.5283 3 -244.4717 -104.4717 4 1106.5283 -244.4717 5 499.5000 1106.5283 6 -245.2500 499.5000 7 -927.4717 -245.2500 8 148.5283 -927.4717 9 -499.5000 148.5283 10 632.5283 -499.5000 11 -74.4717 632.5283 12 -240.4717 -74.4717 13 -1004.4717 -240.4717 14 335.5283 -1004.4717 15 96.5283 335.5283 16 1350.5283 96.5283 17 458.5283 1350.5283 18 -951.4717 458.5283 19 -100.4717 -951.4717 20 -723.4717 -100.4717 21 -1310.4717 -723.4717 22 1350.5283 -1310.4717 23 195.5283 1350.5283 24 354.5283 195.5283 25 -932.4717 354.5283 26 -834.4717 -932.4717 27 68.5283 -834.4717 28 -400.4717 68.5283 29 -1434.4717 -400.4717 30 725.5283 -1434.4717 31 310.5283 725.5283 32 -696.4717 310.5283 33 867.5283 -696.4717 34 490.7500 867.5283 35 -1580.4717 490.7500 36 69.5283 -1580.4717 37 2120.5283 69.5283 38 872.5283 2120.5283 39 383.5283 872.5283 40 -589.4717 383.5283 41 -497.4717 -589.4717 42 -549.4717 -497.4717 43 1091.5283 -549.4717 44 656.5283 1091.5283 45 120.5283 656.5283 46 -81.4717 120.5283 47 -1666.4717 -81.4717 48 986.5283 -1666.4717 49 -717.4717 986.5283 50 1484.5283 -717.4717 51 1081.5283 1484.5283 52 391.5283 1081.5283 53 89.7500 391.5283 54 -1593.4717 89.7500 55 568.5283 -1593.4717 56 -335.2500 568.5283 57 -204.4717 -335.2500 58 -1279.4717 -204.4717 > 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/7lepb1200412749.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/8mc5s1200412749.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/9yiqf1200412749.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/1096kz1200412749.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/11jnsa1200412749.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/12e4md1200412749.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/13xltg1200412749.tab") > > system("convert tmp/16o971200412749.ps tmp/16o971200412749.png") > system("convert tmp/2huca1200412749.ps tmp/2huca1200412749.png") > system("convert tmp/34lo61200412749.ps tmp/34lo61200412749.png") > system("convert tmp/4amp21200412749.ps tmp/4amp21200412749.png") > system("convert tmp/5cp6y1200412749.ps tmp/5cp6y1200412749.png") > system("convert tmp/62u531200412749.ps tmp/62u531200412749.png") > system("convert tmp/7lepb1200412749.ps tmp/7lepb1200412749.png") > system("convert tmp/8mc5s1200412749.ps tmp/8mc5s1200412749.png") > system("convert tmp/9yiqf1200412749.ps tmp/9yiqf1200412749.png") > > > proc.time() user system elapsed 2.290 1.513 2.747