R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(19,0,18,0,19,0,19,0,22,0,23,0,20,0,14,0,14,0,14,0,15,0,11,0,17,0,16,0,20,0,24,0,23,0,20,0,21,0,19,0,23,0,23,0,23,0,23,0,27,0,26,0,17,0,24,0,26,0,24,0,27,0,27,0,26,0,24,0,23,0,23,0,24,1,17,1,21,1,19,1,22,1,22,1,18,1,16,1,14,1,12,1,14,1,16,1,8,1,3,1,0,1,5,1,1,1,1,1,3,1,6,1,7,1,8,1,14,1,14,1,13,1,15,1),dim=c(2,62),dimnames=list(c('consumentenvertrouwen','financiële_crisis'),1:62)) > y <- array(NA,dim=c(2,62),dimnames=list(c('consumentenvertrouwen','financiële_crisis'),1:62)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par3 = '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 consumentenvertrouwen financi\353le_crisis t 1 19 0 1 2 18 0 2 3 19 0 3 4 19 0 4 5 22 0 5 6 23 0 6 7 20 0 7 8 14 0 8 9 14 0 9 10 14 0 10 11 15 0 11 12 11 0 12 13 17 0 13 14 16 0 14 15 20 0 15 16 24 0 16 17 23 0 17 18 20 0 18 19 21 0 19 20 19 0 20 21 23 0 21 22 23 0 22 23 23 0 23 24 23 0 24 25 27 0 25 26 26 0 26 27 17 0 27 28 24 0 28 29 26 0 29 30 24 0 30 31 27 0 31 32 27 0 32 33 26 0 33 34 24 0 34 35 23 0 35 36 23 0 36 37 24 1 37 38 17 1 38 39 21 1 39 40 19 1 40 41 22 1 41 42 22 1 42 43 18 1 43 44 16 1 44 45 14 1 45 46 12 1 46 47 14 1 47 48 16 1 48 49 8 1 49 50 3 1 50 51 0 1 51 52 5 1 52 53 1 1 53 54 1 1 54 55 3 1 55 56 6 1 56 57 7 1 57 58 8 1 58 59 14 1 59 60 14 1 60 61 13 1 61 62 15 1 62 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `financi\353le_crisis` t 20.29232 -9.99874 0.03525 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -12.091 -4.188 1.503 3.038 12.402 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 20.29232 1.71747 11.815 < 2e-16 *** `financi\353le_crisis` -9.99874 2.81151 -3.556 0.000749 *** t 0.03525 0.07752 0.455 0.650998 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.669 on 59 degrees of freedom Multiple R-squared: 0.3884, Adjusted R-squared: 0.3676 F-statistic: 18.73 on 2 and 59 DF, p-value: 5.027e-07 > postscript(file="/var/www/html/rcomp/tmp/1rm901260988528.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/2pj1x1260988528.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/36q101260988528.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/4wgkb1260988528.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/5iu1t1260988528.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 = 62 Frequency = 1 1 2 3 4 5 6 -1.32756740 -2.36281752 -1.39806763 -1.43331775 1.53143213 2.49618202 7 8 9 10 11 12 -0.53906810 -6.57431822 -6.60956833 -6.64481845 -5.68006857 -9.71531868 13 14 15 16 17 18 -3.75056880 -4.78581892 -0.82106904 3.14368085 2.10843073 -0.92681939 19 20 21 22 23 24 0.03793050 -1.99731962 1.96743026 1.93218015 1.89693003 1.86167991 25 26 27 28 29 30 5.82642980 4.79117968 -4.24407044 2.72067945 4.68542933 2.65017921 31 32 33 34 35 36 5.61492909 5.57967898 4.54442886 2.50917874 1.47392863 1.43867851 37 38 39 40 41 42 12.40216492 5.36691481 9.33166469 7.29641457 10.26116445 10.22591434 43 44 45 46 47 48 6.19066422 4.15541410 2.12016399 0.08491387 2.04966375 4.01441364 49 50 51 52 53 54 -4.02083648 -9.05608660 -12.09133671 -7.12658683 -11.16183695 -11.19708706 55 56 57 58 59 60 -9.23233718 -6.26758730 -5.30283742 -4.33808753 1.62666235 1.59141223 61 62 0.55616212 2.52091200 > postscript(file="/var/www/html/rcomp/tmp/67skr1260988528.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 = 62 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.32756740 NA 1 -2.36281752 -1.32756740 2 -1.39806763 -2.36281752 3 -1.43331775 -1.39806763 4 1.53143213 -1.43331775 5 2.49618202 1.53143213 6 -0.53906810 2.49618202 7 -6.57431822 -0.53906810 8 -6.60956833 -6.57431822 9 -6.64481845 -6.60956833 10 -5.68006857 -6.64481845 11 -9.71531868 -5.68006857 12 -3.75056880 -9.71531868 13 -4.78581892 -3.75056880 14 -0.82106904 -4.78581892 15 3.14368085 -0.82106904 16 2.10843073 3.14368085 17 -0.92681939 2.10843073 18 0.03793050 -0.92681939 19 -1.99731962 0.03793050 20 1.96743026 -1.99731962 21 1.93218015 1.96743026 22 1.89693003 1.93218015 23 1.86167991 1.89693003 24 5.82642980 1.86167991 25 4.79117968 5.82642980 26 -4.24407044 4.79117968 27 2.72067945 -4.24407044 28 4.68542933 2.72067945 29 2.65017921 4.68542933 30 5.61492909 2.65017921 31 5.57967898 5.61492909 32 4.54442886 5.57967898 33 2.50917874 4.54442886 34 1.47392863 2.50917874 35 1.43867851 1.47392863 36 12.40216492 1.43867851 37 5.36691481 12.40216492 38 9.33166469 5.36691481 39 7.29641457 9.33166469 40 10.26116445 7.29641457 41 10.22591434 10.26116445 42 6.19066422 10.22591434 43 4.15541410 6.19066422 44 2.12016399 4.15541410 45 0.08491387 2.12016399 46 2.04966375 0.08491387 47 4.01441364 2.04966375 48 -4.02083648 4.01441364 49 -9.05608660 -4.02083648 50 -12.09133671 -9.05608660 51 -7.12658683 -12.09133671 52 -11.16183695 -7.12658683 53 -11.19708706 -11.16183695 54 -9.23233718 -11.19708706 55 -6.26758730 -9.23233718 56 -5.30283742 -6.26758730 57 -4.33808753 -5.30283742 58 1.62666235 -4.33808753 59 1.59141223 1.62666235 60 0.55616212 1.59141223 61 2.52091200 0.55616212 62 NA 2.52091200 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -2.36281752 -1.32756740 [2,] -1.39806763 -2.36281752 [3,] -1.43331775 -1.39806763 [4,] 1.53143213 -1.43331775 [5,] 2.49618202 1.53143213 [6,] -0.53906810 2.49618202 [7,] -6.57431822 -0.53906810 [8,] -6.60956833 -6.57431822 [9,] -6.64481845 -6.60956833 [10,] -5.68006857 -6.64481845 [11,] -9.71531868 -5.68006857 [12,] -3.75056880 -9.71531868 [13,] -4.78581892 -3.75056880 [14,] -0.82106904 -4.78581892 [15,] 3.14368085 -0.82106904 [16,] 2.10843073 3.14368085 [17,] -0.92681939 2.10843073 [18,] 0.03793050 -0.92681939 [19,] -1.99731962 0.03793050 [20,] 1.96743026 -1.99731962 [21,] 1.93218015 1.96743026 [22,] 1.89693003 1.93218015 [23,] 1.86167991 1.89693003 [24,] 5.82642980 1.86167991 [25,] 4.79117968 5.82642980 [26,] -4.24407044 4.79117968 [27,] 2.72067945 -4.24407044 [28,] 4.68542933 2.72067945 [29,] 2.65017921 4.68542933 [30,] 5.61492909 2.65017921 [31,] 5.57967898 5.61492909 [32,] 4.54442886 5.57967898 [33,] 2.50917874 4.54442886 [34,] 1.47392863 2.50917874 [35,] 1.43867851 1.47392863 [36,] 12.40216492 1.43867851 [37,] 5.36691481 12.40216492 [38,] 9.33166469 5.36691481 [39,] 7.29641457 9.33166469 [40,] 10.26116445 7.29641457 [41,] 10.22591434 10.26116445 [42,] 6.19066422 10.22591434 [43,] 4.15541410 6.19066422 [44,] 2.12016399 4.15541410 [45,] 0.08491387 2.12016399 [46,] 2.04966375 0.08491387 [47,] 4.01441364 2.04966375 [48,] -4.02083648 4.01441364 [49,] -9.05608660 -4.02083648 [50,] -12.09133671 -9.05608660 [51,] -7.12658683 -12.09133671 [52,] -11.16183695 -7.12658683 [53,] -11.19708706 -11.16183695 [54,] -9.23233718 -11.19708706 [55,] -6.26758730 -9.23233718 [56,] -5.30283742 -6.26758730 [57,] -4.33808753 -5.30283742 [58,] 1.62666235 -4.33808753 [59,] 1.59141223 1.62666235 [60,] 0.55616212 1.59141223 [61,] 2.52091200 0.55616212 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -2.36281752 -1.32756740 2 -1.39806763 -2.36281752 3 -1.43331775 -1.39806763 4 1.53143213 -1.43331775 5 2.49618202 1.53143213 6 -0.53906810 2.49618202 7 -6.57431822 -0.53906810 8 -6.60956833 -6.57431822 9 -6.64481845 -6.60956833 10 -5.68006857 -6.64481845 11 -9.71531868 -5.68006857 12 -3.75056880 -9.71531868 13 -4.78581892 -3.75056880 14 -0.82106904 -4.78581892 15 3.14368085 -0.82106904 16 2.10843073 3.14368085 17 -0.92681939 2.10843073 18 0.03793050 -0.92681939 19 -1.99731962 0.03793050 20 1.96743026 -1.99731962 21 1.93218015 1.96743026 22 1.89693003 1.93218015 23 1.86167991 1.89693003 24 5.82642980 1.86167991 25 4.79117968 5.82642980 26 -4.24407044 4.79117968 27 2.72067945 -4.24407044 28 4.68542933 2.72067945 29 2.65017921 4.68542933 30 5.61492909 2.65017921 31 5.57967898 5.61492909 32 4.54442886 5.57967898 33 2.50917874 4.54442886 34 1.47392863 2.50917874 35 1.43867851 1.47392863 36 12.40216492 1.43867851 37 5.36691481 12.40216492 38 9.33166469 5.36691481 39 7.29641457 9.33166469 40 10.26116445 7.29641457 41 10.22591434 10.26116445 42 6.19066422 10.22591434 43 4.15541410 6.19066422 44 2.12016399 4.15541410 45 0.08491387 2.12016399 46 2.04966375 0.08491387 47 4.01441364 2.04966375 48 -4.02083648 4.01441364 49 -9.05608660 -4.02083648 50 -12.09133671 -9.05608660 51 -7.12658683 -12.09133671 52 -11.16183695 -7.12658683 53 -11.19708706 -11.16183695 54 -9.23233718 -11.19708706 55 -6.26758730 -9.23233718 56 -5.30283742 -6.26758730 57 -4.33808753 -5.30283742 58 1.62666235 -4.33808753 59 1.59141223 1.62666235 60 0.55616212 1.59141223 61 2.52091200 0.55616212 > 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/7m9d31260988528.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/8i42i1260988528.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/9h8of1260988528.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/10r6al1260988528.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/11bobp1260988528.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/12j1781260988528.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/136qol1260988528.tab") > try(system("convert tmp/1rm901260988528.ps tmp/1rm901260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/2pj1x1260988528.ps tmp/2pj1x1260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/36q101260988528.ps tmp/36q101260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/4wgkb1260988528.ps tmp/4wgkb1260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/5iu1t1260988528.ps tmp/5iu1t1260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/67skr1260988528.ps tmp/67skr1260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/7m9d31260988528.ps tmp/7m9d31260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/8i42i1260988528.ps tmp/8i42i1260988528.png",intern=TRUE)) character(0) > try(system("convert tmp/9h8of1260988528.ps tmp/9h8of1260988528.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.891 1.401 2.437