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(20 + ,0 + ,21 + ,20 + ,22 + ,22 + ,21 + ,0 + ,20 + ,21 + ,20 + ,22 + ,21 + ,0 + ,21 + ,20 + ,21 + ,20 + ,21 + ,0 + ,21 + ,21 + ,20 + ,21 + ,19 + ,0 + ,21 + ,21 + ,21 + ,20 + ,21 + ,0 + ,19 + ,21 + ,21 + ,21 + ,21 + ,0 + ,21 + ,19 + ,21 + ,21 + ,22 + ,0 + ,21 + ,21 + ,19 + ,21 + ,19 + ,0 + ,22 + ,21 + ,21 + ,19 + ,24 + ,0 + ,19 + ,22 + ,21 + ,21 + ,22 + ,0 + ,24 + ,19 + ,22 + ,21 + ,22 + ,0 + ,22 + ,24 + ,19 + ,22 + ,22 + ,0 + ,22 + ,22 + ,24 + ,19 + ,24 + ,0 + ,22 + ,22 + ,22 + ,24 + ,22 + ,0 + ,24 + ,22 + ,22 + ,22 + ,23 + ,0 + ,22 + ,24 + ,22 + ,22 + ,24 + ,0 + ,23 + ,22 + ,24 + ,22 + ,21 + ,0 + ,24 + ,23 + ,22 + ,24 + ,20 + ,0 + ,21 + ,24 + ,23 + ,22 + ,22 + ,0 + ,20 + ,21 + ,24 + ,23 + ,23 + ,0 + ,22 + ,20 + ,21 + ,24 + ,23 + ,0 + ,23 + ,22 + ,20 + ,21 + ,22 + ,0 + ,23 + ,23 + ,22 + ,20 + ,20 + ,0 + ,22 + ,23 + ,23 + ,22 + ,21 + ,1 + ,20 + ,22 + ,23 + ,23 + ,21 + ,1 + ,21 + ,20 + ,22 + ,23 + ,20 + ,1 + ,21 + ,21 + ,20 + ,22 + ,20 + ,1 + ,20 + ,21 + ,21 + ,20 + ,17 + ,1 + ,20 + ,20 + ,21 + ,21 + ,18 + ,1 + ,17 + ,20 + ,20 + ,21 + ,19 + ,1 + ,18 + ,17 + ,20 + ,20 + ,19 + ,1 + ,19 + ,18 + ,17 + ,20 + ,20 + ,1 + ,19 + ,19 + ,18 + ,17 + ,21 + ,1 + ,20 + ,19 + ,19 + ,18 + ,20 + ,1 + ,21 + ,20 + ,19 + ,19 + ,21 + ,1 + ,20 + ,21 + ,20 + ,19 + ,19 + ,1 + ,21 + ,20 + ,21 + ,20 + ,22 + ,1 + ,19 + ,21 + ,20 + ,21 + ,20 + ,1 + ,22 + ,19 + ,21 + ,20 + ,18 + ,1 + ,20 + ,22 + ,19 + ,21 + ,16 + ,1 + ,18 + ,20 + ,22 + ,19 + ,17 + ,1 + ,16 + ,18 + ,20 + ,22 + ,18 + ,1 + ,17 + ,16 + ,18 + ,20 + ,19 + ,1 + ,18 + ,17 + ,16 + ,18 + ,18 + ,1 + ,19 + ,18 + ,17 + ,16 + ,20 + ,1 + ,18 + ,19 + ,18 + ,17 + ,21 + ,1 + ,20 + ,18 + ,19 + ,18 + ,18 + ,1 + ,21 + ,20 + ,18 + ,19 + ,19 + ,1 + ,18 + ,21 + ,20 + ,18 + ,19 + ,1 + ,19 + ,18 + ,21 + ,20 + ,19 + ,1 + ,19 + ,19 + ,18 + ,21 + ,21 + ,1 + ,19 + ,19 + ,19 + ,18 + ,19 + ,1 + ,21 + ,19 + ,19 + ,19 + ,19 + ,1 + ,19 + ,21 + ,19 + ,19 + ,17 + ,1 + ,19 + ,19 + ,21 + ,19 + ,16 + ,1 + ,17 + ,19 + ,19 + ,21 + ,16 + ,1 + ,16 + ,17 + ,19 + ,19 + ,17 + ,1 + ,16 + ,16 + ,17 + ,19 + ,16 + ,1 + ,17 + ,16 + ,16 + ,17 + ,15 + ,1 + ,16 + ,17 + ,16 + ,16 + ,16 + ,1 + ,15 + ,16 + ,17 + ,16 + ,16 + ,1 + ,16 + ,15 + ,16 + ,17 + ,16 + ,1 + ,16 + ,16 + ,15 + ,16 + ,18 + ,1 + ,16 + ,16 + ,16 + ,15 + ,19 + ,1 + ,18 + ,16 + ,16 + ,16 + ,16 + ,1 + ,19 + ,18 + ,16 + ,16 + ,16 + ,1 + ,16 + ,19 + ,18 + ,16 + ,16 + ,1 + ,16 + ,16 + ,19 + ,18) + ,dim=c(6 + ,68) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:68)) > y <- array(NA,dim=c(6,68),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:68)) > 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 t 1 20 0 21 20 22 22 1 0 0 0 0 0 0 0 0 0 0 1 2 21 0 20 21 20 22 0 1 0 0 0 0 0 0 0 0 0 2 3 21 0 21 20 21 20 0 0 1 0 0 0 0 0 0 0 0 3 4 21 0 21 21 20 21 0 0 0 1 0 0 0 0 0 0 0 4 5 19 0 21 21 21 20 0 0 0 0 1 0 0 0 0 0 0 5 6 21 0 19 21 21 21 0 0 0 0 0 1 0 0 0 0 0 6 7 21 0 21 19 21 21 0 0 0 0 0 0 1 0 0 0 0 7 8 22 0 21 21 19 21 0 0 0 0 0 0 0 1 0 0 0 8 9 19 0 22 21 21 19 0 0 0 0 0 0 0 0 1 0 0 9 10 24 0 19 22 21 21 0 0 0 0 0 0 0 0 0 1 0 10 11 22 0 24 19 22 21 0 0 0 0 0 0 0 0 0 0 1 11 12 22 0 22 24 19 22 0 0 0 0 0 0 0 0 0 0 0 12 13 22 0 22 22 24 19 1 0 0 0 0 0 0 0 0 0 0 13 14 24 0 22 22 22 24 0 1 0 0 0 0 0 0 0 0 0 14 15 22 0 24 22 22 22 0 0 1 0 0 0 0 0 0 0 0 15 16 23 0 22 24 22 22 0 0 0 1 0 0 0 0 0 0 0 16 17 24 0 23 22 24 22 0 0 0 0 1 0 0 0 0 0 0 17 18 21 0 24 23 22 24 0 0 0 0 0 1 0 0 0 0 0 18 19 20 0 21 24 23 22 0 0 0 0 0 0 1 0 0 0 0 19 20 22 0 20 21 24 23 0 0 0 0 0 0 0 1 0 0 0 20 21 23 0 22 20 21 24 0 0 0 0 0 0 0 0 1 0 0 21 22 23 0 23 22 20 21 0 0 0 0 0 0 0 0 0 1 0 22 23 22 0 23 23 22 20 0 0 0 0 0 0 0 0 0 0 1 23 24 20 0 22 23 23 22 0 0 0 0 0 0 0 0 0 0 0 24 25 21 1 20 22 23 23 1 0 0 0 0 0 0 0 0 0 0 25 26 21 1 21 20 22 23 0 1 0 0 0 0 0 0 0 0 0 26 27 20 1 21 21 20 22 0 0 1 0 0 0 0 0 0 0 0 27 28 20 1 20 21 21 20 0 0 0 1 0 0 0 0 0 0 0 28 29 17 1 20 20 21 21 0 0 0 0 1 0 0 0 0 0 0 29 30 18 1 17 20 20 21 0 0 0 0 0 1 0 0 0 0 0 30 31 19 1 18 17 20 20 0 0 0 0 0 0 1 0 0 0 0 31 32 19 1 19 18 17 20 0 0 0 0 0 0 0 1 0 0 0 32 33 20 1 19 19 18 17 0 0 0 0 0 0 0 0 1 0 0 33 34 21 1 20 19 19 18 0 0 0 0 0 0 0 0 0 1 0 34 35 20 1 21 20 19 19 0 0 0 0 0 0 0 0 0 0 1 35 36 21 1 20 21 20 19 0 0 0 0 0 0 0 0 0 0 0 36 37 19 1 21 20 21 20 1 0 0 0 0 0 0 0 0 0 0 37 38 22 1 19 21 20 21 0 1 0 0 0 0 0 0 0 0 0 38 39 20 1 22 19 21 20 0 0 1 0 0 0 0 0 0 0 0 39 40 18 1 20 22 19 21 0 0 0 1 0 0 0 0 0 0 0 40 41 16 1 18 20 22 19 0 0 0 0 1 0 0 0 0 0 0 41 42 17 1 16 18 20 22 0 0 0 0 0 1 0 0 0 0 0 42 43 18 1 17 16 18 20 0 0 0 0 0 0 1 0 0 0 0 43 44 19 1 18 17 16 18 0 0 0 0 0 0 0 1 0 0 0 44 45 18 1 19 18 17 16 0 0 0 0 0 0 0 0 1 0 0 45 46 20 1 18 19 18 17 0 0 0 0 0 0 0 0 0 1 0 46 47 21 1 20 18 19 18 0 0 0 0 0 0 0 0 0 0 1 47 48 18 1 21 20 18 19 0 0 0 0 0 0 0 0 0 0 0 48 49 19 1 18 21 20 18 1 0 0 0 0 0 0 0 0 0 0 49 50 19 1 19 18 21 20 0 1 0 0 0 0 0 0 0 0 0 50 51 19 1 19 19 18 21 0 0 1 0 0 0 0 0 0 0 0 51 52 21 1 19 19 19 18 0 0 0 1 0 0 0 0 0 0 0 52 53 19 1 21 19 19 19 0 0 0 0 1 0 0 0 0 0 0 53 54 19 1 19 21 19 19 0 0 0 0 0 1 0 0 0 0 0 54 55 17 1 19 19 21 19 0 0 0 0 0 0 1 0 0 0 0 55 56 16 1 17 19 19 21 0 0 0 0 0 0 0 1 0 0 0 56 57 16 1 16 17 19 19 0 0 0 0 0 0 0 0 1 0 0 57 58 17 1 16 16 17 19 0 0 0 0 0 0 0 0 0 1 0 58 59 16 1 17 16 16 17 0 0 0 0 0 0 0 0 0 0 1 59 60 15 1 16 17 16 16 0 0 0 0 0 0 0 0 0 0 0 60 61 16 1 15 16 17 16 1 0 0 0 0 0 0 0 0 0 0 61 62 16 1 16 15 16 17 0 1 0 0 0 0 0 0 0 0 0 62 63 16 1 16 16 15 16 0 0 1 0 0 0 0 0 0 0 0 63 64 18 1 16 16 16 15 0 0 0 1 0 0 0 0 0 0 0 64 65 19 1 18 16 16 16 0 0 0 0 1 0 0 0 0 0 0 65 66 16 1 19 18 16 16 0 0 0 0 0 1 0 0 0 0 0 66 67 16 1 16 19 18 16 0 0 0 0 0 0 1 0 0 0 0 67 68 16 1 16 16 19 18 0 0 0 0 0 0 0 1 0 0 0 68 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 8.01600 -0.39679 0.42904 0.11702 0.03219 0.03387 M1 M2 M3 M4 M5 M6 0.52208 1.60882 0.42910 1.21952 -0.06901 0.05998 M7 M8 M9 M10 M11 t 0.21231 0.87078 0.42980 2.35820 0.84752 -0.02733 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -2.41567 -0.90492 -0.09324 0.86943 2.57422 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 8.01600 3.51932 2.278 0.02705 * X -0.39679 0.64090 -0.619 0.53865 Y1 0.42904 0.14242 3.012 0.00406 ** Y2 0.11702 0.15074 0.776 0.44123 Y3 0.03219 0.15259 0.211 0.83378 Y4 0.03387 0.14306 0.237 0.81384 M1 0.52208 0.90711 0.576 0.56750 M2 1.60882 0.89196 1.804 0.07730 . M3 0.42910 0.86574 0.496 0.62232 M4 1.21952 0.82923 1.471 0.14764 M5 -0.06901 0.88428 -0.078 0.93811 M6 0.05998 0.85095 0.070 0.94408 M7 0.21231 0.89983 0.236 0.81444 M8 0.87078 0.88683 0.982 0.33087 M9 0.42980 0.90518 0.475 0.63698 M10 2.35820 0.87782 2.686 0.00978 ** M11 0.84752 0.93023 0.911 0.36662 t -0.02733 0.01878 -1.455 0.15195 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.351 on 50 degrees of freedom Multiple R-squared: 0.7472, Adjusted R-squared: 0.6613 F-statistic: 8.694 on 17 and 50 DF, p-value: 1.008e-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.8360132 0.3279737 0.16398683 [2,] 0.9018512 0.1962976 0.09814881 [3,] 0.8262189 0.3475622 0.17378109 [4,] 0.8806994 0.2386012 0.11930060 [5,] 0.8219181 0.3561638 0.17808190 [6,] 0.7363751 0.5272499 0.26362493 [7,] 0.6439590 0.7120819 0.35604095 [8,] 0.5472785 0.9054431 0.45272155 [9,] 0.6556198 0.6887605 0.34438023 [10,] 0.5559326 0.8881348 0.44406741 [11,] 0.4888564 0.9777128 0.51114358 [12,] 0.3921392 0.7842783 0.60786083 [13,] 0.3942776 0.7885552 0.60572240 [14,] 0.3012690 0.6025380 0.69873101 [15,] 0.2280811 0.4561623 0.77191886 [16,] 0.2905001 0.5810001 0.70949995 [17,] 0.2575957 0.5151914 0.74240429 [18,] 0.3350718 0.6701435 0.66492824 [19,] 0.2910725 0.5821450 0.70892748 [20,] 0.4764222 0.9528445 0.52357776 [21,] 0.8264606 0.3470788 0.17353942 [22,] 0.8253329 0.3493342 0.17466711 [23,] 0.7325282 0.5349435 0.26747175 [24,] 0.6695706 0.6608588 0.33042942 [25,] 0.5334836 0.9330327 0.46651637 [26,] 0.3877857 0.7755713 0.61221435 [27,] 0.5084062 0.9831877 0.49159383 > postscript(file="/var/www/html/rcomp/tmp/18bkh1258728336.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/2sxwu1258728336.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/305fm1258728336.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/4f7w01258728336.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/53w4e1258728336.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 = 68 Frequency = 1 1 2 3 4 5 6 -1.314325758 -0.997329253 -0.066758722 -0.948547111 -1.631010887 1.091541606 7 8 9 10 11 12 0.342503637 0.541705633 -2.415673324 1.785625460 -0.502699079 0.707830384 13 14 15 16 17 18 0.387765273 1.223406830 -0.359894295 0.501053734 2.557534239 -1.093543003 19 20 21 22 23 24 -1.012897886 1.070013364 1.859968502 -0.570391570 -0.179921815 -0.975955958 25 26 27 28 29 30 0.867319353 -0.354892022 -0.166618122 -0.465124417 -2.066109840 0.151541693 31 32 33 34 35 36 0.982433467 -0.098192872 1.322505550 -0.073661639 -0.115585185 2.039093274 37 38 39 40 41 42 -0.833739150 1.846240219 0.001883375 -2.223675475 -1.844528807 0.108714656 43 44 45 46 47 48 0.920833814 0.875750781 -0.166458880 0.178434175 1.909322040 -0.880588284 49 50 51 52 53 54 0.764243086 -0.473062803 0.679667790 1.985987674 0.409898687 0.932274991 55 56 57 58 59 60 -1.023062986 -1.799470028 -0.600341848 -1.320006425 -1.111115962 -0.890379415 61 62 63 64 65 66 0.128737196 -1.244362970 -0.088280026 1.150305595 2.574216608 -1.190529944 67 68 -0.209810046 -0.589806879 > postscript(file="/var/www/html/rcomp/tmp/63jxj1258728337.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 = 68 Frequency = 1 lag(myerror, k = 1) myerror 0 -1.314325758 NA 1 -0.997329253 -1.314325758 2 -0.066758722 -0.997329253 3 -0.948547111 -0.066758722 4 -1.631010887 -0.948547111 5 1.091541606 -1.631010887 6 0.342503637 1.091541606 7 0.541705633 0.342503637 8 -2.415673324 0.541705633 9 1.785625460 -2.415673324 10 -0.502699079 1.785625460 11 0.707830384 -0.502699079 12 0.387765273 0.707830384 13 1.223406830 0.387765273 14 -0.359894295 1.223406830 15 0.501053734 -0.359894295 16 2.557534239 0.501053734 17 -1.093543003 2.557534239 18 -1.012897886 -1.093543003 19 1.070013364 -1.012897886 20 1.859968502 1.070013364 21 -0.570391570 1.859968502 22 -0.179921815 -0.570391570 23 -0.975955958 -0.179921815 24 0.867319353 -0.975955958 25 -0.354892022 0.867319353 26 -0.166618122 -0.354892022 27 -0.465124417 -0.166618122 28 -2.066109840 -0.465124417 29 0.151541693 -2.066109840 30 0.982433467 0.151541693 31 -0.098192872 0.982433467 32 1.322505550 -0.098192872 33 -0.073661639 1.322505550 34 -0.115585185 -0.073661639 35 2.039093274 -0.115585185 36 -0.833739150 2.039093274 37 1.846240219 -0.833739150 38 0.001883375 1.846240219 39 -2.223675475 0.001883375 40 -1.844528807 -2.223675475 41 0.108714656 -1.844528807 42 0.920833814 0.108714656 43 0.875750781 0.920833814 44 -0.166458880 0.875750781 45 0.178434175 -0.166458880 46 1.909322040 0.178434175 47 -0.880588284 1.909322040 48 0.764243086 -0.880588284 49 -0.473062803 0.764243086 50 0.679667790 -0.473062803 51 1.985987674 0.679667790 52 0.409898687 1.985987674 53 0.932274991 0.409898687 54 -1.023062986 0.932274991 55 -1.799470028 -1.023062986 56 -0.600341848 -1.799470028 57 -1.320006425 -0.600341848 58 -1.111115962 -1.320006425 59 -0.890379415 -1.111115962 60 0.128737196 -0.890379415 61 -1.244362970 0.128737196 62 -0.088280026 -1.244362970 63 1.150305595 -0.088280026 64 2.574216608 1.150305595 65 -1.190529944 2.574216608 66 -0.209810046 -1.190529944 67 -0.589806879 -0.209810046 68 NA -0.589806879 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -0.997329253 -1.314325758 [2,] -0.066758722 -0.997329253 [3,] -0.948547111 -0.066758722 [4,] -1.631010887 -0.948547111 [5,] 1.091541606 -1.631010887 [6,] 0.342503637 1.091541606 [7,] 0.541705633 0.342503637 [8,] -2.415673324 0.541705633 [9,] 1.785625460 -2.415673324 [10,] -0.502699079 1.785625460 [11,] 0.707830384 -0.502699079 [12,] 0.387765273 0.707830384 [13,] 1.223406830 0.387765273 [14,] -0.359894295 1.223406830 [15,] 0.501053734 -0.359894295 [16,] 2.557534239 0.501053734 [17,] -1.093543003 2.557534239 [18,] -1.012897886 -1.093543003 [19,] 1.070013364 -1.012897886 [20,] 1.859968502 1.070013364 [21,] -0.570391570 1.859968502 [22,] -0.179921815 -0.570391570 [23,] -0.975955958 -0.179921815 [24,] 0.867319353 -0.975955958 [25,] -0.354892022 0.867319353 [26,] -0.166618122 -0.354892022 [27,] -0.465124417 -0.166618122 [28,] -2.066109840 -0.465124417 [29,] 0.151541693 -2.066109840 [30,] 0.982433467 0.151541693 [31,] -0.098192872 0.982433467 [32,] 1.322505550 -0.098192872 [33,] -0.073661639 1.322505550 [34,] -0.115585185 -0.073661639 [35,] 2.039093274 -0.115585185 [36,] -0.833739150 2.039093274 [37,] 1.846240219 -0.833739150 [38,] 0.001883375 1.846240219 [39,] -2.223675475 0.001883375 [40,] -1.844528807 -2.223675475 [41,] 0.108714656 -1.844528807 [42,] 0.920833814 0.108714656 [43,] 0.875750781 0.920833814 [44,] -0.166458880 0.875750781 [45,] 0.178434175 -0.166458880 [46,] 1.909322040 0.178434175 [47,] -0.880588284 1.909322040 [48,] 0.764243086 -0.880588284 [49,] -0.473062803 0.764243086 [50,] 0.679667790 -0.473062803 [51,] 1.985987674 0.679667790 [52,] 0.409898687 1.985987674 [53,] 0.932274991 0.409898687 [54,] -1.023062986 0.932274991 [55,] -1.799470028 -1.023062986 [56,] -0.600341848 -1.799470028 [57,] -1.320006425 -0.600341848 [58,] -1.111115962 -1.320006425 [59,] -0.890379415 -1.111115962 [60,] 0.128737196 -0.890379415 [61,] -1.244362970 0.128737196 [62,] -0.088280026 -1.244362970 [63,] 1.150305595 -0.088280026 [64,] 2.574216608 1.150305595 [65,] -1.190529944 2.574216608 [66,] -0.209810046 -1.190529944 [67,] -0.589806879 -0.209810046 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -0.997329253 -1.314325758 2 -0.066758722 -0.997329253 3 -0.948547111 -0.066758722 4 -1.631010887 -0.948547111 5 1.091541606 -1.631010887 6 0.342503637 1.091541606 7 0.541705633 0.342503637 8 -2.415673324 0.541705633 9 1.785625460 -2.415673324 10 -0.502699079 1.785625460 11 0.707830384 -0.502699079 12 0.387765273 0.707830384 13 1.223406830 0.387765273 14 -0.359894295 1.223406830 15 0.501053734 -0.359894295 16 2.557534239 0.501053734 17 -1.093543003 2.557534239 18 -1.012897886 -1.093543003 19 1.070013364 -1.012897886 20 1.859968502 1.070013364 21 -0.570391570 1.859968502 22 -0.179921815 -0.570391570 23 -0.975955958 -0.179921815 24 0.867319353 -0.975955958 25 -0.354892022 0.867319353 26 -0.166618122 -0.354892022 27 -0.465124417 -0.166618122 28 -2.066109840 -0.465124417 29 0.151541693 -2.066109840 30 0.982433467 0.151541693 31 -0.098192872 0.982433467 32 1.322505550 -0.098192872 33 -0.073661639 1.322505550 34 -0.115585185 -0.073661639 35 2.039093274 -0.115585185 36 -0.833739150 2.039093274 37 1.846240219 -0.833739150 38 0.001883375 1.846240219 39 -2.223675475 0.001883375 40 -1.844528807 -2.223675475 41 0.108714656 -1.844528807 42 0.920833814 0.108714656 43 0.875750781 0.920833814 44 -0.166458880 0.875750781 45 0.178434175 -0.166458880 46 1.909322040 0.178434175 47 -0.880588284 1.909322040 48 0.764243086 -0.880588284 49 -0.473062803 0.764243086 50 0.679667790 -0.473062803 51 1.985987674 0.679667790 52 0.409898687 1.985987674 53 0.932274991 0.409898687 54 -1.023062986 0.932274991 55 -1.799470028 -1.023062986 56 -0.600341848 -1.799470028 57 -1.320006425 -0.600341848 58 -1.111115962 -1.320006425 59 -0.890379415 -1.111115962 60 0.128737196 -0.890379415 61 -1.244362970 0.128737196 62 -0.088280026 -1.244362970 63 1.150305595 -0.088280026 64 2.574216608 1.150305595 65 -1.190529944 2.574216608 66 -0.209810046 -1.190529944 67 -0.589806879 -0.209810046 > 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/7zq6n1258728337.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/83hkr1258728337.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/9rpvq1258728337.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/10fde01258728337.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/11jw6y1258728337.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/12u03a1258728337.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/13oz731258728337.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/14x43a1258728337.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/15rv8z1258728337.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/161olh1258728337.tab") + } > system("convert tmp/18bkh1258728336.ps tmp/18bkh1258728336.png") > system("convert tmp/2sxwu1258728336.ps tmp/2sxwu1258728336.png") > system("convert tmp/305fm1258728336.ps tmp/305fm1258728336.png") > system("convert tmp/4f7w01258728336.ps tmp/4f7w01258728336.png") > system("convert tmp/53w4e1258728336.ps tmp/53w4e1258728336.png") > system("convert tmp/63jxj1258728337.ps tmp/63jxj1258728337.png") > system("convert tmp/7zq6n1258728337.ps tmp/7zq6n1258728337.png") > system("convert tmp/83hkr1258728337.ps tmp/83hkr1258728337.png") > system("convert tmp/9rpvq1258728337.ps tmp/9rpvq1258728337.png") > system("convert tmp/10fde01258728337.ps tmp/10fde01258728337.png") > > > proc.time() user system elapsed 2.536 1.640 5.605