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 = '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 consumentenvertrouwen financi\353le_crisis 1 19 0 2 18 0 3 19 0 4 19 0 5 22 0 6 23 0 7 20 0 8 14 0 9 14 0 10 14 0 11 15 0 12 11 0 13 17 0 14 16 0 15 20 0 16 24 0 17 23 0 18 20 0 19 21 0 20 19 0 21 23 0 22 23 0 23 23 0 24 23 0 25 27 0 26 26 0 27 17 0 28 24 0 29 26 0 30 24 0 31 27 0 32 27 0 33 26 0 34 24 0 35 23 0 36 23 0 37 24 1 38 17 1 39 21 1 40 19 1 41 22 1 42 22 1 43 18 1 44 16 1 45 14 1 46 12 1 47 14 1 48 16 1 49 8 1 50 3 1 51 0 1 52 5 1 53 1 1 54 1 1 55 3 1 56 6 1 57 7 1 58 8 1 59 14 1 60 14 1 61 13 1 62 15 1 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) `financi\353le_crisis` 20.944 -8.906 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -12.038 -4.015 1.962 3.056 11.962 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 20.9444 0.9386 22.315 < 2e-16 *** `financi\353le_crisis` -8.9060 1.4494 -6.145 7.03e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 5.632 on 60 degrees of freedom Multiple R-squared: 0.3862, Adjusted R-squared: 0.376 F-statistic: 37.76 on 1 and 60 DF, p-value: 7.035e-08 > postscript(file="/var/www/html/rcomp/tmp/1q89v1260988781.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/2t21a1260988781.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/3mjm31260988781.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/4efon1260988781.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/5krvx1260988781.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.94444444 -2.94444444 -1.94444444 -1.94444444 1.05555556 2.05555556 7 8 9 10 11 12 -0.94444444 -6.94444444 -6.94444444 -6.94444444 -5.94444444 -9.94444444 13 14 15 16 17 18 -3.94444444 -4.94444444 -0.94444444 3.05555556 2.05555556 -0.94444444 19 20 21 22 23 24 0.05555556 -1.94444444 2.05555556 2.05555556 2.05555556 2.05555556 25 26 27 28 29 30 6.05555556 5.05555556 -3.94444444 3.05555556 5.05555556 3.05555556 31 32 33 34 35 36 6.05555556 6.05555556 5.05555556 3.05555556 2.05555556 2.05555556 37 38 39 40 41 42 11.96153846 4.96153846 8.96153846 6.96153846 9.96153846 9.96153846 43 44 45 46 47 48 5.96153846 3.96153846 1.96153846 -0.03846154 1.96153846 3.96153846 49 50 51 52 53 54 -4.03846154 -9.03846154 -12.03846154 -7.03846154 -11.03846154 -11.03846154 55 56 57 58 59 60 -9.03846154 -6.03846154 -5.03846154 -4.03846154 1.96153846 1.96153846 61 62 0.96153846 2.96153846 > postscript(file="/var/www/html/rcomp/tmp/6uefn1260988781.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.94444444 NA 1 -2.94444444 -1.94444444 2 -1.94444444 -2.94444444 3 -1.94444444 -1.94444444 4 1.05555556 -1.94444444 5 2.05555556 1.05555556 6 -0.94444444 2.05555556 7 -6.94444444 -0.94444444 8 -6.94444444 -6.94444444 9 -6.94444444 -6.94444444 10 -5.94444444 -6.94444444 11 -9.94444444 -5.94444444 12 -3.94444444 -9.94444444 13 -4.94444444 -3.94444444 14 -0.94444444 -4.94444444 15 3.05555556 -0.94444444 16 2.05555556 3.05555556 17 -0.94444444 2.05555556 18 0.05555556 -0.94444444 19 -1.94444444 0.05555556 20 2.05555556 -1.94444444 21 2.05555556 2.05555556 22 2.05555556 2.05555556 23 2.05555556 2.05555556 24 6.05555556 2.05555556 25 5.05555556 6.05555556 26 -3.94444444 5.05555556 27 3.05555556 -3.94444444 28 5.05555556 3.05555556 29 3.05555556 5.05555556 30 6.05555556 3.05555556 31 6.05555556 6.05555556 32 5.05555556 6.05555556 33 3.05555556 5.05555556 34 2.05555556 3.05555556 35 2.05555556 2.05555556 36 11.96153846 2.05555556 37 4.96153846 11.96153846 38 8.96153846 4.96153846 39 6.96153846 8.96153846 40 9.96153846 6.96153846 41 9.96153846 9.96153846 42 5.96153846 9.96153846 43 3.96153846 5.96153846 44 1.96153846 3.96153846 45 -0.03846154 1.96153846 46 1.96153846 -0.03846154 47 3.96153846 1.96153846 48 -4.03846154 3.96153846 49 -9.03846154 -4.03846154 50 -12.03846154 -9.03846154 51 -7.03846154 -12.03846154 52 -11.03846154 -7.03846154 53 -11.03846154 -11.03846154 54 -9.03846154 -11.03846154 55 -6.03846154 -9.03846154 56 -5.03846154 -6.03846154 57 -4.03846154 -5.03846154 58 1.96153846 -4.03846154 59 1.96153846 1.96153846 60 0.96153846 1.96153846 61 2.96153846 0.96153846 62 NA 2.96153846 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -2.94444444 -1.94444444 [2,] -1.94444444 -2.94444444 [3,] -1.94444444 -1.94444444 [4,] 1.05555556 -1.94444444 [5,] 2.05555556 1.05555556 [6,] -0.94444444 2.05555556 [7,] -6.94444444 -0.94444444 [8,] -6.94444444 -6.94444444 [9,] -6.94444444 -6.94444444 [10,] -5.94444444 -6.94444444 [11,] -9.94444444 -5.94444444 [12,] -3.94444444 -9.94444444 [13,] -4.94444444 -3.94444444 [14,] -0.94444444 -4.94444444 [15,] 3.05555556 -0.94444444 [16,] 2.05555556 3.05555556 [17,] -0.94444444 2.05555556 [18,] 0.05555556 -0.94444444 [19,] -1.94444444 0.05555556 [20,] 2.05555556 -1.94444444 [21,] 2.05555556 2.05555556 [22,] 2.05555556 2.05555556 [23,] 2.05555556 2.05555556 [24,] 6.05555556 2.05555556 [25,] 5.05555556 6.05555556 [26,] -3.94444444 5.05555556 [27,] 3.05555556 -3.94444444 [28,] 5.05555556 3.05555556 [29,] 3.05555556 5.05555556 [30,] 6.05555556 3.05555556 [31,] 6.05555556 6.05555556 [32,] 5.05555556 6.05555556 [33,] 3.05555556 5.05555556 [34,] 2.05555556 3.05555556 [35,] 2.05555556 2.05555556 [36,] 11.96153846 2.05555556 [37,] 4.96153846 11.96153846 [38,] 8.96153846 4.96153846 [39,] 6.96153846 8.96153846 [40,] 9.96153846 6.96153846 [41,] 9.96153846 9.96153846 [42,] 5.96153846 9.96153846 [43,] 3.96153846 5.96153846 [44,] 1.96153846 3.96153846 [45,] -0.03846154 1.96153846 [46,] 1.96153846 -0.03846154 [47,] 3.96153846 1.96153846 [48,] -4.03846154 3.96153846 [49,] -9.03846154 -4.03846154 [50,] -12.03846154 -9.03846154 [51,] -7.03846154 -12.03846154 [52,] -11.03846154 -7.03846154 [53,] -11.03846154 -11.03846154 [54,] -9.03846154 -11.03846154 [55,] -6.03846154 -9.03846154 [56,] -5.03846154 -6.03846154 [57,] -4.03846154 -5.03846154 [58,] 1.96153846 -4.03846154 [59,] 1.96153846 1.96153846 [60,] 0.96153846 1.96153846 [61,] 2.96153846 0.96153846 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -2.94444444 -1.94444444 2 -1.94444444 -2.94444444 3 -1.94444444 -1.94444444 4 1.05555556 -1.94444444 5 2.05555556 1.05555556 6 -0.94444444 2.05555556 7 -6.94444444 -0.94444444 8 -6.94444444 -6.94444444 9 -6.94444444 -6.94444444 10 -5.94444444 -6.94444444 11 -9.94444444 -5.94444444 12 -3.94444444 -9.94444444 13 -4.94444444 -3.94444444 14 -0.94444444 -4.94444444 15 3.05555556 -0.94444444 16 2.05555556 3.05555556 17 -0.94444444 2.05555556 18 0.05555556 -0.94444444 19 -1.94444444 0.05555556 20 2.05555556 -1.94444444 21 2.05555556 2.05555556 22 2.05555556 2.05555556 23 2.05555556 2.05555556 24 6.05555556 2.05555556 25 5.05555556 6.05555556 26 -3.94444444 5.05555556 27 3.05555556 -3.94444444 28 5.05555556 3.05555556 29 3.05555556 5.05555556 30 6.05555556 3.05555556 31 6.05555556 6.05555556 32 5.05555556 6.05555556 33 3.05555556 5.05555556 34 2.05555556 3.05555556 35 2.05555556 2.05555556 36 11.96153846 2.05555556 37 4.96153846 11.96153846 38 8.96153846 4.96153846 39 6.96153846 8.96153846 40 9.96153846 6.96153846 41 9.96153846 9.96153846 42 5.96153846 9.96153846 43 3.96153846 5.96153846 44 1.96153846 3.96153846 45 -0.03846154 1.96153846 46 1.96153846 -0.03846154 47 3.96153846 1.96153846 48 -4.03846154 3.96153846 49 -9.03846154 -4.03846154 50 -12.03846154 -9.03846154 51 -7.03846154 -12.03846154 52 -11.03846154 -7.03846154 53 -11.03846154 -11.03846154 54 -9.03846154 -11.03846154 55 -6.03846154 -9.03846154 56 -5.03846154 -6.03846154 57 -4.03846154 -5.03846154 58 1.96153846 -4.03846154 59 1.96153846 1.96153846 60 0.96153846 1.96153846 61 2.96153846 0.96153846 > 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/76nje1260988781.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/8zbbg1260988781.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/9cese1260988781.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/100v391260988781.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/11tuxw1260988782.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/12urnf1260988782.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/130ctt1260988782.tab") > try(system("convert tmp/1q89v1260988781.ps tmp/1q89v1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/2t21a1260988781.ps tmp/2t21a1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/3mjm31260988781.ps tmp/3mjm31260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/4efon1260988781.ps tmp/4efon1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/5krvx1260988781.ps tmp/5krvx1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/6uefn1260988781.ps tmp/6uefn1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/76nje1260988781.ps tmp/76nje1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/8zbbg1260988781.ps tmp/8zbbg1260988781.png",intern=TRUE)) character(0) > try(system("convert tmp/9cese1260988781.ps tmp/9cese1260988781.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.915 1.410 2.348