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(100.49 + ,1.9 + ,100.16 + ,99.6 + ,100.25 + ,100.03 + ,99.72 + ,2 + ,100.49 + ,100.16 + ,99.6 + ,100.25 + ,100.14 + ,2.3 + ,99.72 + ,100.49 + ,100.16 + ,99.6 + ,98.48 + ,2.8 + ,100.14 + ,99.72 + ,100.49 + ,100.16 + ,100.38 + ,2.4 + ,98.48 + ,100.14 + ,99.72 + ,100.49 + ,101.45 + ,2.3 + ,100.38 + ,98.48 + ,100.14 + ,99.72 + ,98.42 + ,2.7 + ,101.45 + ,100.38 + ,98.48 + ,100.14 + ,98.6 + ,2.7 + ,98.42 + ,101.45 + ,100.38 + ,98.48 + ,100.06 + ,2.9 + ,98.6 + ,98.42 + ,101.45 + ,100.38 + ,98.62 + ,3 + ,100.06 + ,98.6 + ,98.42 + ,101.45 + ,100.84 + ,2.2 + ,98.62 + ,100.06 + ,98.6 + ,98.42 + ,100.02 + ,2.3 + ,100.84 + ,98.62 + ,100.06 + ,98.6 + ,97.95 + ,2.8 + ,100.02 + ,100.84 + ,98.62 + ,100.06 + ,98.32 + ,2.8 + ,97.95 + ,100.02 + ,100.84 + ,98.62 + ,98.27 + ,2.8 + ,98.32 + ,97.95 + ,100.02 + ,100.84 + ,97.22 + ,2.2 + ,98.27 + ,98.32 + ,97.95 + ,100.02 + ,99.28 + ,2.6 + ,97.22 + ,98.27 + ,98.32 + ,97.95 + ,100.38 + ,2.8 + ,99.28 + ,97.22 + ,98.27 + ,98.32 + ,99.02 + ,2.5 + ,100.38 + ,99.28 + ,97.22 + ,98.27 + ,100.32 + ,2.4 + ,99.02 + ,100.38 + ,99.28 + ,97.22 + ,99.81 + ,2.3 + ,100.32 + ,99.02 + ,100.38 + ,99.28 + ,100.6 + ,1.9 + ,99.81 + ,100.32 + ,99.02 + ,100.38 + ,101.19 + ,1.7 + ,100.6 + ,99.81 + ,100.32 + ,99.02 + ,100.47 + ,2 + ,101.19 + ,100.6 + ,99.81 + ,100.32 + ,101.77 + ,2.1 + ,100.47 + ,101.19 + ,100.6 + ,99.81 + ,102.32 + ,1.7 + ,101.77 + ,100.47 + ,101.19 + ,100.6 + ,102.39 + ,1.8 + ,102.32 + ,101.77 + ,100.47 + ,101.19 + ,101.16 + ,1.8 + ,102.39 + ,102.32 + ,101.77 + ,100.47 + ,100.63 + ,1.8 + ,101.16 + ,102.39 + ,102.32 + ,101.77 + ,101.48 + ,1.3 + ,100.63 + ,101.16 + ,102.39 + ,102.32 + ,101.44 + ,1.3 + ,101.48 + ,100.63 + ,101.16 + ,102.39 + ,100.09 + ,1.3 + ,101.44 + ,101.48 + ,100.63 + ,101.16 + ,100.7 + ,1.2 + ,100.09 + ,101.44 + ,101.48 + ,100.63 + ,100.78 + ,1.4 + ,100.7 + ,100.09 + ,101.44 + ,101.48 + ,99.81 + ,2.2 + ,100.78 + ,100.7 + ,100.09 + ,101.44 + ,98.45 + ,2.9 + ,99.81 + ,100.78 + ,100.7 + ,100.09 + ,98.49 + ,3.1 + ,98.45 + ,99.81 + ,100.78 + ,100.7 + ,97.48 + ,3.5 + ,98.49 + ,98.45 + ,99.81 + ,100.78 + ,97.91 + ,3.6 + ,97.48 + ,98.49 + ,98.45 + ,99.81 + ,96.94 + ,4.4 + ,97.91 + ,97.48 + ,98.49 + ,98.45 + ,98.53 + ,4.1 + ,96.94 + ,97.91 + ,97.48 + ,98.49 + ,96.82 + ,5.1 + ,98.53 + ,96.94 + ,97.91 + ,97.48 + ,95.76 + ,5.8 + ,96.82 + ,98.53 + ,96.94 + ,97.91 + ,95.27 + ,5.9 + ,95.76 + ,96.82 + ,98.53 + ,96.94 + ,97.32 + ,5.4 + ,95.27 + ,95.76 + ,96.82 + ,98.53 + ,96.68 + ,5.5 + ,97.32 + ,95.27 + ,95.76 + ,96.82 + ,97.87 + ,4.8 + ,96.68 + ,97.32 + ,95.27 + ,95.76 + ,97.42 + ,3.2 + ,97.87 + ,96.68 + ,97.32 + ,95.27 + ,97.94 + ,2.7 + ,97.42 + ,97.87 + ,96.68 + ,97.32 + ,99.52 + ,2.1 + ,97.94 + ,97.42 + ,97.87 + ,96.68 + ,100.99 + ,1.9 + ,99.52 + ,97.94 + ,97.42 + ,97.87 + ,99.92 + ,0.6 + ,100.99 + ,99.52 + ,97.94 + ,97.42 + ,101.97 + ,0.7 + ,99.92 + ,100.99 + ,99.52 + ,97.94 + ,101.58 + ,-0.2 + ,101.97 + ,99.92 + ,100.99 + ,99.52 + ,99.54 + ,-1 + ,101.58 + ,101.97 + ,99.92 + ,100.99 + ,100.83 + ,-1.7 + ,99.54 + ,101.58 + ,101.97 + ,99.92) + ,dim=c(6 + ,56) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:56)) > 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 = 'Include Monthly 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) > library(lmtest) Loading required package: zoo Attaching package: 'zoo' The following object(s) are masked from package:base : 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 Y X Y1 Y2 Y3 Y4 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 1 100.49 1.9 100.16 99.60 100.25 100.03 1 0 0 0 0 0 0 0 0 0 0 2 99.72 2.0 100.49 100.16 99.60 100.25 0 1 0 0 0 0 0 0 0 0 0 3 100.14 2.3 99.72 100.49 100.16 99.60 0 0 1 0 0 0 0 0 0 0 0 4 98.48 2.8 100.14 99.72 100.49 100.16 0 0 0 1 0 0 0 0 0 0 0 5 100.38 2.4 98.48 100.14 99.72 100.49 0 0 0 0 1 0 0 0 0 0 0 6 101.45 2.3 100.38 98.48 100.14 99.72 0 0 0 0 0 1 0 0 0 0 0 7 98.42 2.7 101.45 100.38 98.48 100.14 0 0 0 0 0 0 1 0 0 0 0 8 98.60 2.7 98.42 101.45 100.38 98.48 0 0 0 0 0 0 0 1 0 0 0 9 100.06 2.9 98.60 98.42 101.45 100.38 0 0 0 0 0 0 0 0 1 0 0 10 98.62 3.0 100.06 98.60 98.42 101.45 0 0 0 0 0 0 0 0 0 1 0 11 100.84 2.2 98.62 100.06 98.60 98.42 0 0 0 0 0 0 0 0 0 0 1 12 100.02 2.3 100.84 98.62 100.06 98.60 0 0 0 0 0 0 0 0 0 0 0 13 97.95 2.8 100.02 100.84 98.62 100.06 1 0 0 0 0 0 0 0 0 0 0 14 98.32 2.8 97.95 100.02 100.84 98.62 0 1 0 0 0 0 0 0 0 0 0 15 98.27 2.8 98.32 97.95 100.02 100.84 0 0 1 0 0 0 0 0 0 0 0 16 97.22 2.2 98.27 98.32 97.95 100.02 0 0 0 1 0 0 0 0 0 0 0 17 99.28 2.6 97.22 98.27 98.32 97.95 0 0 0 0 1 0 0 0 0 0 0 18 100.38 2.8 99.28 97.22 98.27 98.32 0 0 0 0 0 1 0 0 0 0 0 19 99.02 2.5 100.38 99.28 97.22 98.27 0 0 0 0 0 0 1 0 0 0 0 20 100.32 2.4 99.02 100.38 99.28 97.22 0 0 0 0 0 0 0 1 0 0 0 21 99.81 2.3 100.32 99.02 100.38 99.28 0 0 0 0 0 0 0 0 1 0 0 22 100.60 1.9 99.81 100.32 99.02 100.38 0 0 0 0 0 0 0 0 0 1 0 23 101.19 1.7 100.60 99.81 100.32 99.02 0 0 0 0 0 0 0 0 0 0 1 24 100.47 2.0 101.19 100.60 99.81 100.32 0 0 0 0 0 0 0 0 0 0 0 25 101.77 2.1 100.47 101.19 100.60 99.81 1 0 0 0 0 0 0 0 0 0 0 26 102.32 1.7 101.77 100.47 101.19 100.60 0 1 0 0 0 0 0 0 0 0 0 27 102.39 1.8 102.32 101.77 100.47 101.19 0 0 1 0 0 0 0 0 0 0 0 28 101.16 1.8 102.39 102.32 101.77 100.47 0 0 0 1 0 0 0 0 0 0 0 29 100.63 1.8 101.16 102.39 102.32 101.77 0 0 0 0 1 0 0 0 0 0 0 30 101.48 1.3 100.63 101.16 102.39 102.32 0 0 0 0 0 1 0 0 0 0 0 31 101.44 1.3 101.48 100.63 101.16 102.39 0 0 0 0 0 0 1 0 0 0 0 32 100.09 1.3 101.44 101.48 100.63 101.16 0 0 0 0 0 0 0 1 0 0 0 33 100.70 1.2 100.09 101.44 101.48 100.63 0 0 0 0 0 0 0 0 1 0 0 34 100.78 1.4 100.70 100.09 101.44 101.48 0 0 0 0 0 0 0 0 0 1 0 35 99.81 2.2 100.78 100.70 100.09 101.44 0 0 0 0 0 0 0 0 0 0 1 36 98.45 2.9 99.81 100.78 100.70 100.09 0 0 0 0 0 0 0 0 0 0 0 37 98.49 3.1 98.45 99.81 100.78 100.70 1 0 0 0 0 0 0 0 0 0 0 38 97.48 3.5 98.49 98.45 99.81 100.78 0 1 0 0 0 0 0 0 0 0 0 39 97.91 3.6 97.48 98.49 98.45 99.81 0 0 1 0 0 0 0 0 0 0 0 40 96.94 4.4 97.91 97.48 98.49 98.45 0 0 0 1 0 0 0 0 0 0 0 41 98.53 4.1 96.94 97.91 97.48 98.49 0 0 0 0 1 0 0 0 0 0 0 42 96.82 5.1 98.53 96.94 97.91 97.48 0 0 0 0 0 1 0 0 0 0 0 43 95.76 5.8 96.82 98.53 96.94 97.91 0 0 0 0 0 0 1 0 0 0 0 44 95.27 5.9 95.76 96.82 98.53 96.94 0 0 0 0 0 0 0 1 0 0 0 45 97.32 5.4 95.27 95.76 96.82 98.53 0 0 0 0 0 0 0 0 1 0 0 46 96.68 5.5 97.32 95.27 95.76 96.82 0 0 0 0 0 0 0 0 0 1 0 47 97.87 4.8 96.68 97.32 95.27 95.76 0 0 0 0 0 0 0 0 0 0 1 48 97.42 3.2 97.87 96.68 97.32 95.27 0 0 0 0 0 0 0 0 0 0 0 49 97.94 2.7 97.42 97.87 96.68 97.32 1 0 0 0 0 0 0 0 0 0 0 50 99.52 2.1 97.94 97.42 97.87 96.68 0 1 0 0 0 0 0 0 0 0 0 51 100.99 1.9 99.52 97.94 97.42 97.87 0 0 1 0 0 0 0 0 0 0 0 52 99.92 0.6 100.99 99.52 97.94 97.42 0 0 0 1 0 0 0 0 0 0 0 53 101.97 0.7 99.92 100.99 99.52 97.94 0 0 0 0 1 0 0 0 0 0 0 54 101.58 -0.2 101.97 99.92 100.99 99.52 0 0 0 0 0 1 0 0 0 0 0 55 99.54 -1.0 101.58 101.97 99.92 100.99 0 0 0 0 0 0 1 0 0 0 0 56 100.83 -1.7 99.54 101.58 101.97 99.92 0 0 0 0 0 0 0 1 0 0 0 t 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 52.923713 -0.456561 0.529785 0.001629 0.211227 -0.268926 M1 M2 M3 M4 M5 M6 0.779716 0.720845 1.394167 -0.251541 1.761477 1.119170 M7 M8 M9 M10 M11 t -0.099745 0.207964 1.424104 1.029986 1.501842 -0.008383 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -1.4419 -0.4695 -0.1392 0.5648 1.7106 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 52.923713 13.880394 3.813 0.00049 *** X -0.456561 0.136277 -3.350 0.00183 ** Y1 0.529785 0.150924 3.510 0.00117 ** Y2 0.001629 0.169852 0.010 0.99240 Y3 0.211227 0.165712 1.275 0.21017 Y4 -0.268926 0.139164 -1.932 0.06079 . M1 0.779716 0.631015 1.236 0.22417 M2 0.720845 0.604075 1.193 0.24015 M3 1.394167 0.625470 2.229 0.03180 * M4 -0.251541 0.599557 -0.420 0.67718 M5 1.761477 0.654977 2.689 0.01057 * M6 1.119170 0.607961 1.841 0.07346 . M7 -0.099745 0.669930 -0.149 0.88243 M8 0.207964 0.660939 0.315 0.75475 M9 1.424104 0.661141 2.154 0.03765 * M10 1.029986 0.684813 1.504 0.14084 M11 1.501842 0.655248 2.292 0.02753 * t -0.008383 0.008107 -1.034 0.30764 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.8717 on 38 degrees of freedom Multiple R-squared: 0.8174, Adjusted R-squared: 0.7357 F-statistic: 10.01 on 17 and 38 DF, p-value: 2.725e-09 > 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 + } [,1] [,2] [,3] [1,] 0.5934757 0.8130487 0.4065243 [2,] 0.4734982 0.9469963 0.5265018 [3,] 0.4456636 0.8913271 0.5543364 [4,] 0.4168256 0.8336511 0.5831744 [5,] 0.5830741 0.8338519 0.4169259 [6,] 0.5836970 0.8326059 0.4163030 [7,] 0.4824131 0.9648261 0.5175869 [8,] 0.4189850 0.8379699 0.5810150 [9,] 0.6095565 0.7808869 0.3904435 [10,] 0.6145643 0.7708714 0.3854357 [11,] 0.7254677 0.5490646 0.2745323 [12,] 0.7778116 0.4443769 0.2221884 [13,] 0.7781745 0.4436511 0.2218255 [14,] 0.6747354 0.6505292 0.3252646 [15,] 0.4959186 0.9918372 0.5040814 > postscript(file="/var/www/html/rcomp/tmp/1vk791258703368.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/2c1gn1258703368.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/3vaiy1258703368.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/4eixo1258703368.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/5fqtm1258703368.ps",horizontal=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 = 56 Frequency = 1 1 2 3 4 5 6 0.16211230 -0.47425753 -0.46792045 -0.38591078 0.45697825 0.83233696 7 8 9 10 11 12 -0.89411815 -0.25768880 0.28038606 -0.55746602 0.74145745 0.04357718 13 14 15 16 17 18 -1.44186838 -0.76280267 -0.90016937 -0.32740734 -0.16789314 0.69452710 19 20 21 22 23 24 0.04708130 1.00331383 -1.12496683 0.73607036 -0.28674901 0.78391437 25 26 27 28 29 30 1.43470015 1.26960925 0.73757743 0.65546599 -0.99421968 0.69410212 31 32 33 34 35 36 1.71058088 -0.13776719 -0.38797944 0.10190034 -0.73530077 -0.24362032 37 38 39 40 41 42 -0.01440758 -0.56710151 -0.19495619 0.25403335 0.43971694 -1.36625188 43 44 45 46 47 48 0.34450981 -0.43151359 1.23256020 -0.28050467 0.28059233 -0.58387123 49 50 51 52 53 54 -0.14053648 0.53455247 0.82546859 -0.19618122 0.26541762 -0.85471430 55 56 -1.20805384 -0.17634425 > postscript(file="/var/www/html/rcomp/tmp/6gkc11258703368.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 = 56 Frequency = 1 lag(myerror, k = 1) myerror 0 0.16211230 NA 1 -0.47425753 0.16211230 2 -0.46792045 -0.47425753 3 -0.38591078 -0.46792045 4 0.45697825 -0.38591078 5 0.83233696 0.45697825 6 -0.89411815 0.83233696 7 -0.25768880 -0.89411815 8 0.28038606 -0.25768880 9 -0.55746602 0.28038606 10 0.74145745 -0.55746602 11 0.04357718 0.74145745 12 -1.44186838 0.04357718 13 -0.76280267 -1.44186838 14 -0.90016937 -0.76280267 15 -0.32740734 -0.90016937 16 -0.16789314 -0.32740734 17 0.69452710 -0.16789314 18 0.04708130 0.69452710 19 1.00331383 0.04708130 20 -1.12496683 1.00331383 21 0.73607036 -1.12496683 22 -0.28674901 0.73607036 23 0.78391437 -0.28674901 24 1.43470015 0.78391437 25 1.26960925 1.43470015 26 0.73757743 1.26960925 27 0.65546599 0.73757743 28 -0.99421968 0.65546599 29 0.69410212 -0.99421968 30 1.71058088 0.69410212 31 -0.13776719 1.71058088 32 -0.38797944 -0.13776719 33 0.10190034 -0.38797944 34 -0.73530077 0.10190034 35 -0.24362032 -0.73530077 36 -0.01440758 -0.24362032 37 -0.56710151 -0.01440758 38 -0.19495619 -0.56710151 39 0.25403335 -0.19495619 40 0.43971694 0.25403335 41 -1.36625188 0.43971694 42 0.34450981 -1.36625188 43 -0.43151359 0.34450981 44 1.23256020 -0.43151359 45 -0.28050467 1.23256020 46 0.28059233 -0.28050467 47 -0.58387123 0.28059233 48 -0.14053648 -0.58387123 49 0.53455247 -0.14053648 50 0.82546859 0.53455247 51 -0.19618122 0.82546859 52 0.26541762 -0.19618122 53 -0.85471430 0.26541762 54 -1.20805384 -0.85471430 55 -0.17634425 -1.20805384 56 NA -0.17634425 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.47425753 0.16211230 [2,] -0.46792045 -0.47425753 [3,] -0.38591078 -0.46792045 [4,] 0.45697825 -0.38591078 [5,] 0.83233696 0.45697825 [6,] -0.89411815 0.83233696 [7,] -0.25768880 -0.89411815 [8,] 0.28038606 -0.25768880 [9,] -0.55746602 0.28038606 [10,] 0.74145745 -0.55746602 [11,] 0.04357718 0.74145745 [12,] -1.44186838 0.04357718 [13,] -0.76280267 -1.44186838 [14,] -0.90016937 -0.76280267 [15,] -0.32740734 -0.90016937 [16,] -0.16789314 -0.32740734 [17,] 0.69452710 -0.16789314 [18,] 0.04708130 0.69452710 [19,] 1.00331383 0.04708130 [20,] -1.12496683 1.00331383 [21,] 0.73607036 -1.12496683 [22,] -0.28674901 0.73607036 [23,] 0.78391437 -0.28674901 [24,] 1.43470015 0.78391437 [25,] 1.26960925 1.43470015 [26,] 0.73757743 1.26960925 [27,] 0.65546599 0.73757743 [28,] -0.99421968 0.65546599 [29,] 0.69410212 -0.99421968 [30,] 1.71058088 0.69410212 [31,] -0.13776719 1.71058088 [32,] -0.38797944 -0.13776719 [33,] 0.10190034 -0.38797944 [34,] -0.73530077 0.10190034 [35,] -0.24362032 -0.73530077 [36,] -0.01440758 -0.24362032 [37,] -0.56710151 -0.01440758 [38,] -0.19495619 -0.56710151 [39,] 0.25403335 -0.19495619 [40,] 0.43971694 0.25403335 [41,] -1.36625188 0.43971694 [42,] 0.34450981 -1.36625188 [43,] -0.43151359 0.34450981 [44,] 1.23256020 -0.43151359 [45,] -0.28050467 1.23256020 [46,] 0.28059233 -0.28050467 [47,] -0.58387123 0.28059233 [48,] -0.14053648 -0.58387123 [49,] 0.53455247 -0.14053648 [50,] 0.82546859 0.53455247 [51,] -0.19618122 0.82546859 [52,] 0.26541762 -0.19618122 [53,] -0.85471430 0.26541762 [54,] -1.20805384 -0.85471430 [55,] -0.17634425 -1.20805384 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.47425753 0.16211230 2 -0.46792045 -0.47425753 3 -0.38591078 -0.46792045 4 0.45697825 -0.38591078 5 0.83233696 0.45697825 6 -0.89411815 0.83233696 7 -0.25768880 -0.89411815 8 0.28038606 -0.25768880 9 -0.55746602 0.28038606 10 0.74145745 -0.55746602 11 0.04357718 0.74145745 12 -1.44186838 0.04357718 13 -0.76280267 -1.44186838 14 -0.90016937 -0.76280267 15 -0.32740734 -0.90016937 16 -0.16789314 -0.32740734 17 0.69452710 -0.16789314 18 0.04708130 0.69452710 19 1.00331383 0.04708130 20 -1.12496683 1.00331383 21 0.73607036 -1.12496683 22 -0.28674901 0.73607036 23 0.78391437 -0.28674901 24 1.43470015 0.78391437 25 1.26960925 1.43470015 26 0.73757743 1.26960925 27 0.65546599 0.73757743 28 -0.99421968 0.65546599 29 0.69410212 -0.99421968 30 1.71058088 0.69410212 31 -0.13776719 1.71058088 32 -0.38797944 -0.13776719 33 0.10190034 -0.38797944 34 -0.73530077 0.10190034 35 -0.24362032 -0.73530077 36 -0.01440758 -0.24362032 37 -0.56710151 -0.01440758 38 -0.19495619 -0.56710151 39 0.25403335 -0.19495619 40 0.43971694 0.25403335 41 -1.36625188 0.43971694 42 0.34450981 -1.36625188 43 -0.43151359 0.34450981 44 1.23256020 -0.43151359 45 -0.28050467 1.23256020 46 0.28059233 -0.28050467 47 -0.58387123 0.28059233 48 -0.14053648 -0.58387123 49 0.53455247 -0.14053648 50 0.82546859 0.53455247 51 -0.19618122 0.82546859 52 0.26541762 -0.19618122 53 -0.85471430 0.26541762 54 -1.20805384 -0.85471430 55 -0.17634425 -1.20805384 > 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/7pd6x1258703368.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/8o9g11258703368.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/9uniy1258703368.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 > if (n > n25) { + postscript(file="/var/www/html/rcomp/tmp/10m61l1258703368.ps",horizontal=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() + } 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/11243k1258703368.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/1289z81258703368.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/13fun01258703368.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/14zfj21258703368.tab") > if (n > n25) { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'p-values',header=TRUE) + a<-table.element(a,'Alternative Hypothesis',3,header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'breakpoint index',header=TRUE) + a<-table.element(a,'greater',header=TRUE) + a<-table.element(a,'2-sided',header=TRUE) + a<-table.element(a,'less',header=TRUE) + a<-table.row.end(a) + for (mypoint in kp3:nmkm3) { + a<-table.row.start(a) + a<-table.element(a,mypoint,header=TRUE) + a<-table.element(a,gqarr[mypoint-kp3+1,1]) + a<-table.element(a,gqarr[mypoint-kp3+1,2]) + a<-table.element(a,gqarr[mypoint-kp3+1,3]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/157ob41258703368.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Description',header=TRUE) + a<-table.element(a,'# significant tests',header=TRUE) + a<-table.element(a,'% significant tests',header=TRUE) + a<-table.element(a,'OK/NOK',header=TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'1% type I error level',header=TRUE) + a<-table.element(a,numsignificant1) + a<-table.element(a,numsignificant1/numgqtests) + if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'5% type I error level',header=TRUE) + a<-table.element(a,numsignificant5) + a<-table.element(a,numsignificant5/numgqtests) + if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'10% type I error level',header=TRUE) + a<-table.element(a,numsignificant10) + a<-table.element(a,numsignificant10/numgqtests) + if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK' + a<-table.element(a,dum) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/16bf5b1258703368.tab") + } > > system("convert tmp/1vk791258703368.ps tmp/1vk791258703368.png") > system("convert tmp/2c1gn1258703368.ps tmp/2c1gn1258703368.png") > system("convert tmp/3vaiy1258703368.ps tmp/3vaiy1258703368.png") > system("convert tmp/4eixo1258703368.ps tmp/4eixo1258703368.png") > system("convert tmp/5fqtm1258703368.ps tmp/5fqtm1258703368.png") > system("convert tmp/6gkc11258703368.ps tmp/6gkc11258703368.png") > system("convert tmp/7pd6x1258703368.ps tmp/7pd6x1258703368.png") > system("convert tmp/8o9g11258703368.ps tmp/8o9g11258703368.png") > system("convert tmp/9uniy1258703368.ps tmp/9uniy1258703368.png") > system("convert tmp/10m61l1258703368.ps tmp/10m61l1258703368.png") > > > proc.time() user system elapsed 2.351 1.572 3.018