R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) 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(17,13,14,1,5,22,22,17,13,14,1,7,23,23,17,13,14,1,5,23,22,17,13,14,1,5,23,25,17,13,14,1,5,22,22,16,13,14,1,5,22,22,17,13,14,1,5,23,23,15,13,14,1,5,25,25,16,13,14,1,6,25,24,16,13,14,1,6,25,25),dim=c(7,10),dimnames=list(c('Directe','Indirecte','socialepremies','Kapitaalbelastingen','Nietfiscaleontv','Uitkeringen','Overige'),1:10)) > y <- array(NA,dim=c(7,10),dimnames=list(c('Directe','Indirecte','socialepremies','Kapitaalbelastingen','Nietfiscaleontv','Uitkeringen','Overige'),1:10)) > 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 = '4' > par3 <- 'No Linear Trend' > par2 <- 'Do not include Seasonal Dummies' > par1 <- '4' > #'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) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from 'package:base': as.Date, as.Date.numeric > n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test > 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 Kapitaalbelastingen Directe Indirecte socialepremies Nietfiscaleontv 1 1 17 13 14 5 2 1 17 13 14 7 3 1 17 13 14 5 4 1 17 13 14 5 5 1 17 13 14 5 6 1 16 13 14 5 7 1 17 13 14 5 8 1 15 13 14 5 9 1 16 13 14 6 10 1 16 13 14 6 Uitkeringen Overige 1 22 22 2 23 23 3 23 22 4 23 25 5 22 22 6 22 22 7 23 23 8 25 25 9 25 24 10 25 25 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) Directe Indirecte socialepremies 1.000e+00 -4.093e-18 NA NA Nietfiscaleontv Uitkeringen Overige 8.609e-18 6.972e-18 6.662e-18 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: 1 2 3 4 5 6 7 -1.329e-16 9.710e-18 3.359e-17 1.361e-17 4.056e-17 3.647e-17 2.693e-17 8 9 10 -8.525e-18 -6.379e-18 -1.304e-17 Coefficients: (2 not defined because of singularities) Estimate Std. Error t value Pr(>|t|) (Intercept) 1.000e+00 1.278e-15 7.827e+14 <2e-16 *** Directe -4.093e-18 4.782e-17 -8.600e-02 0.935 Indirecte NA NA NA NA socialepremies NA NA NA NA Nietfiscaleontv 8.609e-18 3.767e-17 2.290e-01 0.828 Uitkeringen 6.972e-18 4.018e-17 1.740e-01 0.869 Overige 6.662e-18 2.883e-17 2.310e-01 0.826 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 6.791e-17 on 5 degrees of freedom Multiple R-squared: 0.6813, Adjusted R-squared: 0.4264 F-statistic: 2.673 on 4 and 5 DF, p-value: 0.155 > if (n > n25) { + kp3 <- k + 3 + nmkm3 <- n - k - 3 + gqarr <- array(NA, dim=c(nmkm3-kp3+1,3)) + numgqtests <- 0 + numsignificant1 <- 0 + numsignificant5 <- 0 + numsignificant10 <- 0 + for (mypoint in kp3:nmkm3) { + j <- 0 + numgqtests <- numgqtests + 1 + for (myalt in c('greater', 'two.sided', 'less')) { + j <- j + 1 + gqarr[mypoint-kp3+1,j] <- gqtest(mylm, point=mypoint, alternative=myalt)$p.value + } + if (gqarr[mypoint-kp3+1,2] < 0.01) numsignificant1 <- numsignificant1 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.05) numsignificant5 <- numsignificant5 + 1 + if (gqarr[mypoint-kp3+1,2] < 0.10) numsignificant10 <- numsignificant10 + 1 + } + gqarr + } > postscript(file="/var/wessaorg/rcomp/tmp/1l4th1353055405.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2vo231353055405.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/39xo01353055405.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4eeg11353055405.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5c80m1353055405.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(mysum$resid, main='Residual Normal Q-Q Plot') > qqline(mysum$resid) > grid() > dev.off() null device 1 > (myerror <- as.ts(mysum$resid)) Time Series: Start = 1 End = 10 Frequency = 1 1 2 3 4 5 -1.329220e-16 9.710166e-18 3.359040e-17 1.360552e-17 4.056253e-17 6 7 8 9 10 3.646958e-17 2.692878e-17 -8.524623e-18 -6.379354e-18 -1.304098e-17 > postscript(file="/var/wessaorg/rcomp/tmp/68uf61353055405.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > dum <- cbind(lag(myerror,k=1),myerror) > dum Time Series: Start = 0 End = 10 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.329220e-16 NA 1 9.710166e-18 -1.329220e-16 2 3.359040e-17 9.710166e-18 3 1.360552e-17 3.359040e-17 4 4.056253e-17 1.360552e-17 5 3.646958e-17 4.056253e-17 6 2.692878e-17 3.646958e-17 7 -8.524623e-18 2.692878e-17 8 -6.379354e-18 -8.524623e-18 9 -1.304098e-17 -6.379354e-18 10 NA -1.304098e-17 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 9.710166e-18 -1.329220e-16 [2,] 3.359040e-17 9.710166e-18 [3,] 1.360552e-17 3.359040e-17 [4,] 4.056253e-17 1.360552e-17 [5,] 3.646958e-17 4.056253e-17 [6,] 2.692878e-17 3.646958e-17 [7,] -8.524623e-18 2.692878e-17 [8,] -6.379354e-18 -8.524623e-18 [9,] -1.304098e-17 -6.379354e-18 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 9.710166e-18 -1.329220e-16 2 3.359040e-17 9.710166e-18 3 1.360552e-17 3.359040e-17 4 4.056253e-17 1.360552e-17 5 3.646958e-17 4.056253e-17 6 2.692878e-17 3.646958e-17 7 -8.524623e-18 2.692878e-17 8 -6.379354e-18 -8.524623e-18 9 -1.304098e-17 -6.379354e-18 > 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/wessaorg/rcomp/tmp/7da1f1353055405.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/83ew61353055405.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/91op01353055405.ps",horizontal=F,onefile=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 > if (n > n25) { + postscript(file="/var/wessaorg/rcomp/tmp/10p4df1353055405.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) + plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint') + grid() + dev.off() + } > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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='') + } + } Error: subscript out of bounds Execution halted