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(264777 + ,26.4 + ,267366 + ,267413 + ,258863 + ,29.4 + ,264777 + ,267366 + ,254844 + ,34.4 + ,258863 + ,264777 + ,254868 + ,24.4 + ,254844 + ,258863 + ,277267 + ,26.4 + ,254868 + ,254844 + ,285351 + ,25.4 + ,277267 + ,254868 + ,286602 + ,31.4 + ,285351 + ,277267 + ,283042 + ,27.4 + ,286602 + ,285351 + ,276687 + ,27.4 + ,283042 + ,286602 + ,277915 + ,29.4 + ,276687 + ,283042 + ,277128 + ,32.4 + ,277915 + ,276687 + ,277103 + ,26.4 + ,277128 + ,277915 + ,275037 + ,22.4 + ,277103 + ,277128 + ,270150 + ,19.4 + ,275037 + ,277103 + ,267140 + ,21.4 + ,270150 + ,275037 + ,264993 + ,23.4 + ,267140 + ,270150 + ,287259 + ,23.4 + ,264993 + ,267140 + ,291186 + ,25.4 + ,287259 + ,264993 + ,292300 + ,28.4 + ,291186 + ,287259 + ,288186 + ,27.4 + ,292300 + ,291186 + ,281477 + ,21.4 + ,288186 + ,292300 + ,282656 + ,17.4 + ,281477 + ,288186 + ,280190 + ,24.4 + ,282656 + ,281477 + ,280408 + ,26.4 + ,280190 + ,282656 + ,276836 + ,22.4 + ,280408 + ,280190 + ,275216 + ,14.4 + ,276836 + ,280408 + ,274352 + ,18.4 + ,275216 + ,276836 + ,271311 + ,25.4 + ,274352 + ,275216 + ,289802 + ,29.4 + ,271311 + ,274352 + ,290726 + ,26.4 + ,289802 + ,271311 + ,292300 + ,26.4 + ,290726 + ,289802 + ,278506 + ,20.4 + ,292300 + ,290726 + ,269826 + ,26.4 + ,278506 + ,292300 + ,265861 + ,29.4 + ,269826 + ,278506 + ,269034 + ,33.4 + ,265861 + ,269826 + ,264176 + ,32.4 + ,269034 + ,265861 + ,255198 + ,35.4 + ,264176 + ,269034 + ,253353 + ,34.4 + ,255198 + ,264176 + ,246057 + ,36.4 + ,253353 + ,255198 + ,235372 + ,32.4 + ,246057 + ,253353 + ,258556 + ,34.4 + ,235372 + ,246057 + ,260993 + ,31.4 + ,258556 + ,235372 + ,254663 + ,27.4 + ,260993 + ,258556 + ,250643 + ,27.4 + ,254663 + ,260993 + ,243422 + ,30.4 + ,250643 + ,254663 + ,247105 + ,32.4 + ,243422 + ,250643 + ,248541 + ,32.4 + ,247105 + ,243422 + ,245039 + ,27.4 + ,248541 + ,247105 + ,237080 + ,31.4 + ,245039 + ,248541 + ,237085 + ,29.4 + ,237080 + ,245039 + ,225554 + ,27.4 + ,237085 + ,237080 + ,226839 + ,25.4 + ,225554 + ,237085 + ,247934 + ,26.4 + ,226839 + ,225554 + ,248333 + ,23.4 + ,247934 + ,226839 + ,246969 + ,18.4 + ,248333 + ,247934 + ,245098 + ,22.4 + ,246969 + ,248333 + ,246263 + ,17.4 + ,245098 + ,246969 + ,255765 + ,17.4 + ,246263 + ,245098 + ,264319 + ,11.4 + ,255765 + ,246263 + ,268347 + ,9.4 + ,264319 + ,255765 + ,273046 + ,6.4 + ,268347 + ,264319 + ,273963 + ,0 + ,273046 + ,268347 + ,267430 + ,7.8 + ,273963 + ,273046 + ,271993 + ,7.9 + ,267430 + ,273963 + ,292710 + ,12 + ,271993 + ,267430 + ,295881 + ,16.9 + ,292710 + ,271993 + ,293299 + ,12.3 + ,295881 + ,292710) + ,dim=c(4 + ,67) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2') + ,1:67)) > y <- array(NA,dim=c(4,67),dimnames=list(c('Y','X','Y1','Y2'),1:67)) > 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t 1 264777 26.4 267366 267413 1 0 0 0 0 0 0 0 0 0 0 1 2 258863 29.4 264777 267366 0 1 0 0 0 0 0 0 0 0 0 2 3 254844 34.4 258863 264777 0 0 1 0 0 0 0 0 0 0 0 3 4 254868 24.4 254844 258863 0 0 0 1 0 0 0 0 0 0 0 4 5 277267 26.4 254868 254844 0 0 0 0 1 0 0 0 0 0 0 5 6 285351 25.4 277267 254868 0 0 0 0 0 1 0 0 0 0 0 6 7 286602 31.4 285351 277267 0 0 0 0 0 0 1 0 0 0 0 7 8 283042 27.4 286602 285351 0 0 0 0 0 0 0 1 0 0 0 8 9 276687 27.4 283042 286602 0 0 0 0 0 0 0 0 1 0 0 9 10 277915 29.4 276687 283042 0 0 0 0 0 0 0 0 0 1 0 10 11 277128 32.4 277915 276687 0 0 0 0 0 0 0 0 0 0 1 11 12 277103 26.4 277128 277915 0 0 0 0 0 0 0 0 0 0 0 12 13 275037 22.4 277103 277128 1 0 0 0 0 0 0 0 0 0 0 13 14 270150 19.4 275037 277103 0 1 0 0 0 0 0 0 0 0 0 14 15 267140 21.4 270150 275037 0 0 1 0 0 0 0 0 0 0 0 15 16 264993 23.4 267140 270150 0 0 0 1 0 0 0 0 0 0 0 16 17 287259 23.4 264993 267140 0 0 0 0 1 0 0 0 0 0 0 17 18 291186 25.4 287259 264993 0 0 0 0 0 1 0 0 0 0 0 18 19 292300 28.4 291186 287259 0 0 0 0 0 0 1 0 0 0 0 19 20 288186 27.4 292300 291186 0 0 0 0 0 0 0 1 0 0 0 20 21 281477 21.4 288186 292300 0 0 0 0 0 0 0 0 1 0 0 21 22 282656 17.4 281477 288186 0 0 0 0 0 0 0 0 0 1 0 22 23 280190 24.4 282656 281477 0 0 0 0 0 0 0 0 0 0 1 23 24 280408 26.4 280190 282656 0 0 0 0 0 0 0 0 0 0 0 24 25 276836 22.4 280408 280190 1 0 0 0 0 0 0 0 0 0 0 25 26 275216 14.4 276836 280408 0 1 0 0 0 0 0 0 0 0 0 26 27 274352 18.4 275216 276836 0 0 1 0 0 0 0 0 0 0 0 27 28 271311 25.4 274352 275216 0 0 0 1 0 0 0 0 0 0 0 28 29 289802 29.4 271311 274352 0 0 0 0 1 0 0 0 0 0 0 29 30 290726 26.4 289802 271311 0 0 0 0 0 1 0 0 0 0 0 30 31 292300 26.4 290726 289802 0 0 0 0 0 0 1 0 0 0 0 31 32 278506 20.4 292300 290726 0 0 0 0 0 0 0 1 0 0 0 32 33 269826 26.4 278506 292300 0 0 0 0 0 0 0 0 1 0 0 33 34 265861 29.4 269826 278506 0 0 0 0 0 0 0 0 0 1 0 34 35 269034 33.4 265861 269826 0 0 0 0 0 0 0 0 0 0 1 35 36 264176 32.4 269034 265861 0 0 0 0 0 0 0 0 0 0 0 36 37 255198 35.4 264176 269034 1 0 0 0 0 0 0 0 0 0 0 37 38 253353 34.4 255198 264176 0 1 0 0 0 0 0 0 0 0 0 38 39 246057 36.4 253353 255198 0 0 1 0 0 0 0 0 0 0 0 39 40 235372 32.4 246057 253353 0 0 0 1 0 0 0 0 0 0 0 40 41 258556 34.4 235372 246057 0 0 0 0 1 0 0 0 0 0 0 41 42 260993 31.4 258556 235372 0 0 0 0 0 1 0 0 0 0 0 42 43 254663 27.4 260993 258556 0 0 0 0 0 0 1 0 0 0 0 43 44 250643 27.4 254663 260993 0 0 0 0 0 0 0 1 0 0 0 44 45 243422 30.4 250643 254663 0 0 0 0 0 0 0 0 1 0 0 45 46 247105 32.4 243422 250643 0 0 0 0 0 0 0 0 0 1 0 46 47 248541 32.4 247105 243422 0 0 0 0 0 0 0 0 0 0 1 47 48 245039 27.4 248541 247105 0 0 0 0 0 0 0 0 0 0 0 48 49 237080 31.4 245039 248541 1 0 0 0 0 0 0 0 0 0 0 49 50 237085 29.4 237080 245039 0 1 0 0 0 0 0 0 0 0 0 50 51 225554 27.4 237085 237080 0 0 1 0 0 0 0 0 0 0 0 51 52 226839 25.4 225554 237085 0 0 0 1 0 0 0 0 0 0 0 52 53 247934 26.4 226839 225554 0 0 0 0 1 0 0 0 0 0 0 53 54 248333 23.4 247934 226839 0 0 0 0 0 1 0 0 0 0 0 54 55 246969 18.4 248333 247934 0 0 0 0 0 0 1 0 0 0 0 55 56 245098 22.4 246969 248333 0 0 0 0 0 0 0 1 0 0 0 56 57 246263 17.4 245098 246969 0 0 0 0 0 0 0 0 1 0 0 57 58 255765 17.4 246263 245098 0 0 0 0 0 0 0 0 0 1 0 58 59 264319 11.4 255765 246263 0 0 0 0 0 0 0 0 0 0 1 59 60 268347 9.4 264319 255765 0 0 0 0 0 0 0 0 0 0 0 60 61 273046 6.4 268347 264319 1 0 0 0 0 0 0 0 0 0 0 61 62 273963 0.0 273046 268347 0 1 0 0 0 0 0 0 0 0 0 62 63 267430 7.8 273963 273046 0 0 1 0 0 0 0 0 0 0 0 63 64 271993 7.9 267430 273963 0 0 0 1 0 0 0 0 0 0 0 64 65 292710 12.0 271993 267430 0 0 0 0 1 0 0 0 0 0 0 65 66 295881 16.9 292710 271993 0 0 0 0 0 1 0 0 0 0 0 66 67 293299 12.3 295881 292710 0 0 0 0 0 0 1 0 0 0 0 67 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 M1 M2 3.870e+04 -3.574e+02 8.556e-01 4.014e-02 -3.281e+03 -3.517e+03 M3 M4 M5 M6 M7 M8 -5.821e+03 -2.989e+03 2.088e+04 5.719e+03 9.081e+02 -4.151e+03 M9 M10 M11 t -5.064e+03 2.531e+03 3.397e+03 -7.823e+01 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -8024.78 -1474.74 -89.29 2219.48 4736.57 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.870e+04 1.210e+04 3.197 0.00238 ** X -3.574e+02 8.678e+01 -4.118 0.00014 *** Y1 8.557e-01 1.501e-01 5.699 6.04e-07 *** Y2 4.014e-02 1.417e-01 0.283 0.77816 M1 -3.281e+03 2.080e+03 -1.578 0.12085 M2 -3.517e+03 2.283e+03 -1.540 0.12963 M3 -5.821e+03 2.148e+03 -2.710 0.00914 ** M4 -2.989e+03 2.407e+03 -1.242 0.21991 M5 2.088e+04 2.149e+03 9.715 3.43e-13 *** M6 5.719e+03 3.465e+03 1.650 0.10504 M7 9.081e+02 2.075e+03 0.438 0.66349 M8 -4.151e+03 2.156e+03 -1.926 0.05972 . M9 -5.064e+03 2.368e+03 -2.139 0.03727 * M10 2.531e+03 2.374e+03 1.066 0.29134 M11 3.397e+03 2.125e+03 1.598 0.11615 t -7.823e+01 3.239e+01 -2.415 0.01934 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3346 on 51 degrees of freedom Multiple R-squared: 0.9723, Adjusted R-squared: 0.9641 F-statistic: 119.2 on 15 and 51 DF, p-value: < 2.2e-16 > 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,] 2.680486e-02 5.360972e-02 0.97319514 [2,] 8.880504e-03 1.776101e-02 0.99111950 [3,] 2.673903e-03 5.347805e-03 0.99732610 [4,] 1.230030e-03 2.460060e-03 0.99876997 [5,] 6.052314e-04 1.210463e-03 0.99939477 [6,] 3.006987e-04 6.013973e-04 0.99969930 [7,] 8.261037e-05 1.652207e-04 0.99991739 [8,] 2.783313e-04 5.566626e-04 0.99972167 [9,] 3.143893e-04 6.287786e-04 0.99968561 [10,] 1.143581e-04 2.287162e-04 0.99988564 [11,] 3.881316e-05 7.762631e-05 0.99996119 [12,] 4.654258e-05 9.308516e-05 0.99995346 [13,] 1.750839e-04 3.501678e-04 0.99982492 [14,] 5.309877e-02 1.061975e-01 0.94690123 [15,] 3.939411e-02 7.878821e-02 0.96060589 [16,] 7.079976e-02 1.415995e-01 0.92920024 [17,] 1.859827e-01 3.719653e-01 0.81401735 [18,] 1.332252e-01 2.664503e-01 0.86677483 [19,] 1.021690e-01 2.043380e-01 0.89783098 [20,] 1.392513e-01 2.785025e-01 0.86074873 [21,] 3.803403e-01 7.606806e-01 0.61965970 [22,] 5.675329e-01 8.649343e-01 0.43246714 [23,] 5.948199e-01 8.103601e-01 0.40518006 [24,] 7.614314e-01 4.771373e-01 0.23856863 [25,] 8.463377e-01 3.073245e-01 0.15366225 [26,] 8.240865e-01 3.518269e-01 0.17591345 [27,] 7.780596e-01 4.438809e-01 0.22194043 [28,] 7.241074e-01 5.517852e-01 0.27589262 [29,] 7.836873e-01 4.326254e-01 0.21631269 [30,] 9.550770e-01 8.984596e-02 0.04492298 > postscript(file="/var/www/html/rcomp/tmp/126b71258715431.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/2j9xb1258715431.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/3057f1258715431.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/45ju81258715431.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/5aa161258715431.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 = 67 Frequency = 1 1 2 3 4 5 6 7 -634.5424 -2945.3504 2369.2654 -257.8413 -790.9240 3005.3160 3473.1827 8 9 10 11 12 13 14 2226.5688 -141.6689 -135.2452 -1433.0220 496.5674 413.3123 -3463.1293 15 16 17 18 19 20 21 888.6200 -525.5653 -89.2881 823.0210 3644.0291 3199.6253 -1187.3314 22 23 24 25 26 27 28 -3049.0176 -4540.1601 1930.0239 200.2419 -917.2212 3560.3283 1071.6579 29 30 31 32 33 34 35 -158.7593 -770.3684 4159.5549 -8024.7778 -1830.0388 -4259.0649 3297.2357 36 37 38 39 40 41 42 -999.2177 -1516.4633 4472.0766 2212.3961 -6338.8381 3207.7465 400.4166 43 44 45 46 47 48 49 -5486.1308 950.0879 -514.1252 2706.7537 494.0007 -2696.6839 -2928.0892 50 51 52 53 54 55 56 3626.7414 -5921.2876 1761.6343 -1210.2606 -4748.6222 -4198.8817 1648.4959 57 58 59 60 61 62 63 3673.1643 4736.5739 2181.9457 1269.3103 4465.5406 -773.1171 -3109.3222 64 65 66 67 4288.9526 -958.5146 1290.2370 -1591.7542 > postscript(file="/var/www/html/rcomp/tmp/6g8ar1258715431.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 = 67 Frequency = 1 lag(myerror, k = 1) myerror 0 -634.5424 NA 1 -2945.3504 -634.5424 2 2369.2654 -2945.3504 3 -257.8413 2369.2654 4 -790.9240 -257.8413 5 3005.3160 -790.9240 6 3473.1827 3005.3160 7 2226.5688 3473.1827 8 -141.6689 2226.5688 9 -135.2452 -141.6689 10 -1433.0220 -135.2452 11 496.5674 -1433.0220 12 413.3123 496.5674 13 -3463.1293 413.3123 14 888.6200 -3463.1293 15 -525.5653 888.6200 16 -89.2881 -525.5653 17 823.0210 -89.2881 18 3644.0291 823.0210 19 3199.6253 3644.0291 20 -1187.3314 3199.6253 21 -3049.0176 -1187.3314 22 -4540.1601 -3049.0176 23 1930.0239 -4540.1601 24 200.2419 1930.0239 25 -917.2212 200.2419 26 3560.3283 -917.2212 27 1071.6579 3560.3283 28 -158.7593 1071.6579 29 -770.3684 -158.7593 30 4159.5549 -770.3684 31 -8024.7778 4159.5549 32 -1830.0388 -8024.7778 33 -4259.0649 -1830.0388 34 3297.2357 -4259.0649 35 -999.2177 3297.2357 36 -1516.4633 -999.2177 37 4472.0766 -1516.4633 38 2212.3961 4472.0766 39 -6338.8381 2212.3961 40 3207.7465 -6338.8381 41 400.4166 3207.7465 42 -5486.1308 400.4166 43 950.0879 -5486.1308 44 -514.1252 950.0879 45 2706.7537 -514.1252 46 494.0007 2706.7537 47 -2696.6839 494.0007 48 -2928.0892 -2696.6839 49 3626.7414 -2928.0892 50 -5921.2876 3626.7414 51 1761.6343 -5921.2876 52 -1210.2606 1761.6343 53 -4748.6222 -1210.2606 54 -4198.8817 -4748.6222 55 1648.4959 -4198.8817 56 3673.1643 1648.4959 57 4736.5739 3673.1643 58 2181.9457 4736.5739 59 1269.3103 2181.9457 60 4465.5406 1269.3103 61 -773.1171 4465.5406 62 -3109.3222 -773.1171 63 4288.9526 -3109.3222 64 -958.5146 4288.9526 65 1290.2370 -958.5146 66 -1591.7542 1290.2370 67 NA -1591.7542 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -2945.3504 -634.5424 [2,] 2369.2654 -2945.3504 [3,] -257.8413 2369.2654 [4,] -790.9240 -257.8413 [5,] 3005.3160 -790.9240 [6,] 3473.1827 3005.3160 [7,] 2226.5688 3473.1827 [8,] -141.6689 2226.5688 [9,] -135.2452 -141.6689 [10,] -1433.0220 -135.2452 [11,] 496.5674 -1433.0220 [12,] 413.3123 496.5674 [13,] -3463.1293 413.3123 [14,] 888.6200 -3463.1293 [15,] -525.5653 888.6200 [16,] -89.2881 -525.5653 [17,] 823.0210 -89.2881 [18,] 3644.0291 823.0210 [19,] 3199.6253 3644.0291 [20,] -1187.3314 3199.6253 [21,] -3049.0176 -1187.3314 [22,] -4540.1601 -3049.0176 [23,] 1930.0239 -4540.1601 [24,] 200.2419 1930.0239 [25,] -917.2212 200.2419 [26,] 3560.3283 -917.2212 [27,] 1071.6579 3560.3283 [28,] -158.7593 1071.6579 [29,] -770.3684 -158.7593 [30,] 4159.5549 -770.3684 [31,] -8024.7778 4159.5549 [32,] -1830.0388 -8024.7778 [33,] -4259.0649 -1830.0388 [34,] 3297.2357 -4259.0649 [35,] -999.2177 3297.2357 [36,] -1516.4633 -999.2177 [37,] 4472.0766 -1516.4633 [38,] 2212.3961 4472.0766 [39,] -6338.8381 2212.3961 [40,] 3207.7465 -6338.8381 [41,] 400.4166 3207.7465 [42,] -5486.1308 400.4166 [43,] 950.0879 -5486.1308 [44,] -514.1252 950.0879 [45,] 2706.7537 -514.1252 [46,] 494.0007 2706.7537 [47,] -2696.6839 494.0007 [48,] -2928.0892 -2696.6839 [49,] 3626.7414 -2928.0892 [50,] -5921.2876 3626.7414 [51,] 1761.6343 -5921.2876 [52,] -1210.2606 1761.6343 [53,] -4748.6222 -1210.2606 [54,] -4198.8817 -4748.6222 [55,] 1648.4959 -4198.8817 [56,] 3673.1643 1648.4959 [57,] 4736.5739 3673.1643 [58,] 2181.9457 4736.5739 [59,] 1269.3103 2181.9457 [60,] 4465.5406 1269.3103 [61,] -773.1171 4465.5406 [62,] -3109.3222 -773.1171 [63,] 4288.9526 -3109.3222 [64,] -958.5146 4288.9526 [65,] 1290.2370 -958.5146 [66,] -1591.7542 1290.2370 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -2945.3504 -634.5424 2 2369.2654 -2945.3504 3 -257.8413 2369.2654 4 -790.9240 -257.8413 5 3005.3160 -790.9240 6 3473.1827 3005.3160 7 2226.5688 3473.1827 8 -141.6689 2226.5688 9 -135.2452 -141.6689 10 -1433.0220 -135.2452 11 496.5674 -1433.0220 12 413.3123 496.5674 13 -3463.1293 413.3123 14 888.6200 -3463.1293 15 -525.5653 888.6200 16 -89.2881 -525.5653 17 823.0210 -89.2881 18 3644.0291 823.0210 19 3199.6253 3644.0291 20 -1187.3314 3199.6253 21 -3049.0176 -1187.3314 22 -4540.1601 -3049.0176 23 1930.0239 -4540.1601 24 200.2419 1930.0239 25 -917.2212 200.2419 26 3560.3283 -917.2212 27 1071.6579 3560.3283 28 -158.7593 1071.6579 29 -770.3684 -158.7593 30 4159.5549 -770.3684 31 -8024.7778 4159.5549 32 -1830.0388 -8024.7778 33 -4259.0649 -1830.0388 34 3297.2357 -4259.0649 35 -999.2177 3297.2357 36 -1516.4633 -999.2177 37 4472.0766 -1516.4633 38 2212.3961 4472.0766 39 -6338.8381 2212.3961 40 3207.7465 -6338.8381 41 400.4166 3207.7465 42 -5486.1308 400.4166 43 950.0879 -5486.1308 44 -514.1252 950.0879 45 2706.7537 -514.1252 46 494.0007 2706.7537 47 -2696.6839 494.0007 48 -2928.0892 -2696.6839 49 3626.7414 -2928.0892 50 -5921.2876 3626.7414 51 1761.6343 -5921.2876 52 -1210.2606 1761.6343 53 -4748.6222 -1210.2606 54 -4198.8817 -4748.6222 55 1648.4959 -4198.8817 56 3673.1643 1648.4959 57 4736.5739 3673.1643 58 2181.9457 4736.5739 59 1269.3103 2181.9457 60 4465.5406 1269.3103 61 -773.1171 4465.5406 62 -3109.3222 -773.1171 63 4288.9526 -3109.3222 64 -958.5146 4288.9526 65 1290.2370 -958.5146 66 -1591.7542 1290.2370 > 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/7q1uk1258715431.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/8l5p81258715431.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/91coe1258715431.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/10yyks1258715431.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/11uzga1258715431.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/123bkv1258715431.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/130ru51258715431.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/14oufc1258715431.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/15yf1i1258715431.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/16mlmu1258715431.tab") + } > > system("convert tmp/126b71258715431.ps tmp/126b71258715431.png") > system("convert tmp/2j9xb1258715431.ps tmp/2j9xb1258715431.png") > system("convert tmp/3057f1258715431.ps tmp/3057f1258715431.png") > system("convert tmp/45ju81258715431.ps tmp/45ju81258715431.png") > system("convert tmp/5aa161258715431.ps tmp/5aa161258715431.png") > system("convert tmp/6g8ar1258715431.ps tmp/6g8ar1258715431.png") > system("convert tmp/7q1uk1258715431.ps tmp/7q1uk1258715431.png") > system("convert tmp/8l5p81258715431.ps tmp/8l5p81258715431.png") > system("convert tmp/91coe1258715431.ps tmp/91coe1258715431.png") > system("convert tmp/10yyks1258715431.ps tmp/10yyks1258715431.png") > > > proc.time() user system elapsed 2.485 1.560 2.895