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(277128 + ,0 + ,277915 + ,276687 + ,283042 + ,286602 + ,277103 + ,0 + ,277128 + ,277915 + ,276687 + ,283042 + ,275037 + ,0 + ,277103 + ,277128 + ,277915 + ,276687 + ,270150 + ,0 + ,275037 + ,277103 + ,277128 + ,277915 + ,267140 + ,0 + ,270150 + ,275037 + ,277103 + ,277128 + ,264993 + ,0 + ,267140 + ,270150 + ,275037 + ,277103 + ,287259 + ,0 + ,264993 + ,267140 + ,270150 + ,275037 + ,291186 + ,0 + ,287259 + ,264993 + ,267140 + ,270150 + ,292300 + ,0 + ,291186 + ,287259 + ,264993 + ,267140 + ,288186 + ,0 + ,292300 + ,291186 + ,287259 + ,264993 + ,281477 + ,0 + ,288186 + ,292300 + ,291186 + ,287259 + ,282656 + ,0 + ,281477 + ,288186 + ,292300 + ,291186 + ,280190 + ,0 + ,282656 + ,281477 + ,288186 + ,292300 + ,280408 + ,0 + ,280190 + ,282656 + ,281477 + ,288186 + ,276836 + ,0 + ,280408 + ,280190 + ,282656 + ,281477 + ,275216 + ,0 + ,276836 + ,280408 + ,280190 + ,282656 + ,274352 + ,0 + ,275216 + ,276836 + ,280408 + ,280190 + ,271311 + ,0 + ,274352 + ,275216 + ,276836 + ,280408 + ,289802 + ,0 + ,271311 + ,274352 + ,275216 + ,276836 + ,290726 + ,0 + ,289802 + ,271311 + ,274352 + ,275216 + ,292300 + ,0 + ,290726 + ,289802 + ,271311 + ,274352 + ,278506 + ,0 + ,292300 + ,290726 + ,289802 + ,271311 + ,269826 + ,0 + ,278506 + ,292300 + ,290726 + ,289802 + ,265861 + ,0 + ,269826 + ,278506 + ,292300 + ,290726 + ,269034 + ,0 + ,265861 + ,269826 + ,278506 + ,292300 + ,264176 + ,0 + ,269034 + ,265861 + ,269826 + ,278506 + ,255198 + ,0 + ,264176 + ,269034 + ,265861 + ,269826 + ,253353 + ,0 + ,255198 + ,264176 + ,269034 + ,265861 + ,246057 + ,0 + ,253353 + ,255198 + ,264176 + ,269034 + ,235372 + ,0 + ,246057 + ,253353 + ,255198 + ,264176 + ,258556 + ,0 + ,235372 + ,246057 + ,253353 + ,255198 + ,260993 + ,0 + ,258556 + ,235372 + ,246057 + ,253353 + ,254663 + ,0 + ,260993 + ,258556 + ,235372 + ,246057 + ,250643 + ,0 + ,254663 + ,260993 + ,258556 + ,235372 + ,243422 + ,0 + ,250643 + ,254663 + ,260993 + ,258556 + ,247105 + ,0 + ,243422 + ,250643 + ,254663 + ,260993 + ,248541 + ,0 + ,247105 + ,243422 + ,250643 + ,254663 + ,245039 + ,0 + ,248541 + ,247105 + ,243422 + ,250643 + ,237080 + ,0 + ,245039 + ,248541 + ,247105 + ,243422 + ,237085 + ,0 + ,237080 + ,245039 + ,248541 + ,247105 + ,225554 + ,0 + ,237085 + ,237080 + ,245039 + ,248541 + ,226839 + ,1 + ,225554 + ,237085 + ,237080 + ,245039 + ,247934 + ,1 + ,226839 + ,225554 + ,237085 + ,237080 + ,248333 + ,1 + ,247934 + ,226839 + ,225554 + ,237085 + ,246969 + ,1 + ,248333 + ,247934 + ,226839 + ,225554 + ,245098 + ,1 + ,246969 + ,248333 + ,247934 + ,226839 + ,246263 + ,1 + ,245098 + ,246969 + ,248333 + ,247934 + ,255765 + ,1 + ,246263 + ,245098 + ,246969 + ,248333 + ,264319 + ,1 + ,255765 + ,246263 + ,245098 + ,246969 + ,268347 + ,1 + ,264319 + ,255765 + ,246263 + ,245098 + ,273046 + ,1 + ,268347 + ,264319 + ,255765 + ,246263 + ,273963 + ,1 + ,273046 + ,268347 + ,264319 + ,255765 + ,267430 + ,1 + ,273963 + ,273046 + ,268347 + ,264319 + ,271993 + ,1 + ,267430 + ,273963 + ,273046 + ,268347 + ,292710 + ,1 + ,271993 + ,267430 + ,273963 + ,273046 + ,295881 + ,1 + ,292710 + ,271993 + ,267430 + ,273963) + ,dim=c(6 + ,56) + ,dimnames=list(c('nwwmb' + ,'dummy_variable' + ,'y[t-1]' + ,'y[t-2]' + ,'y[t-3]' + ,'y[t-4] ') + ,1:56)) > y <- array(NA,dim=c(6,56),dimnames=list(c('nwwmb','dummy_variable','y[t-1]','y[t-2]','y[t-3]','y[t-4] '),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 nwwmb dummy_variable y[t-1] y[t-2] y[t-3] y[t-4]\r M1 M2 M3 M4 M5 M6 M7 M8 1 277128 0 277915 276687 283042 286602 1 0 0 0 0 0 0 0 2 277103 0 277128 277915 276687 283042 0 1 0 0 0 0 0 0 3 275037 0 277103 277128 277915 276687 0 0 1 0 0 0 0 0 4 270150 0 275037 277103 277128 277915 0 0 0 1 0 0 0 0 5 267140 0 270150 275037 277103 277128 0 0 0 0 1 0 0 0 6 264993 0 267140 270150 275037 277103 0 0 0 0 0 1 0 0 7 287259 0 264993 267140 270150 275037 0 0 0 0 0 0 1 0 8 291186 0 287259 264993 267140 270150 0 0 0 0 0 0 0 1 9 292300 0 291186 287259 264993 267140 0 0 0 0 0 0 0 0 10 288186 0 292300 291186 287259 264993 0 0 0 0 0 0 0 0 11 281477 0 288186 292300 291186 287259 0 0 0 0 0 0 0 0 12 282656 0 281477 288186 292300 291186 0 0 0 0 0 0 0 0 13 280190 0 282656 281477 288186 292300 1 0 0 0 0 0 0 0 14 280408 0 280190 282656 281477 288186 0 1 0 0 0 0 0 0 15 276836 0 280408 280190 282656 281477 0 0 1 0 0 0 0 0 16 275216 0 276836 280408 280190 282656 0 0 0 1 0 0 0 0 17 274352 0 275216 276836 280408 280190 0 0 0 0 1 0 0 0 18 271311 0 274352 275216 276836 280408 0 0 0 0 0 1 0 0 19 289802 0 271311 274352 275216 276836 0 0 0 0 0 0 1 0 20 290726 0 289802 271311 274352 275216 0 0 0 0 0 0 0 1 21 292300 0 290726 289802 271311 274352 0 0 0 0 0 0 0 0 22 278506 0 292300 290726 289802 271311 0 0 0 0 0 0 0 0 23 269826 0 278506 292300 290726 289802 0 0 0 0 0 0 0 0 24 265861 0 269826 278506 292300 290726 0 0 0 0 0 0 0 0 25 269034 0 265861 269826 278506 292300 1 0 0 0 0 0 0 0 26 264176 0 269034 265861 269826 278506 0 1 0 0 0 0 0 0 27 255198 0 264176 269034 265861 269826 0 0 1 0 0 0 0 0 28 253353 0 255198 264176 269034 265861 0 0 0 1 0 0 0 0 29 246057 0 253353 255198 264176 269034 0 0 0 0 1 0 0 0 30 235372 0 246057 253353 255198 264176 0 0 0 0 0 1 0 0 31 258556 0 235372 246057 253353 255198 0 0 0 0 0 0 1 0 32 260993 0 258556 235372 246057 253353 0 0 0 0 0 0 0 1 33 254663 0 260993 258556 235372 246057 0 0 0 0 0 0 0 0 34 250643 0 254663 260993 258556 235372 0 0 0 0 0 0 0 0 35 243422 0 250643 254663 260993 258556 0 0 0 0 0 0 0 0 36 247105 0 243422 250643 254663 260993 0 0 0 0 0 0 0 0 37 248541 0 247105 243422 250643 254663 1 0 0 0 0 0 0 0 38 245039 0 248541 247105 243422 250643 0 1 0 0 0 0 0 0 39 237080 0 245039 248541 247105 243422 0 0 1 0 0 0 0 0 40 237085 0 237080 245039 248541 247105 0 0 0 1 0 0 0 0 41 225554 0 237085 237080 245039 248541 0 0 0 0 1 0 0 0 42 226839 1 225554 237085 237080 245039 0 0 0 0 0 1 0 0 43 247934 1 226839 225554 237085 237080 0 0 0 0 0 0 1 0 44 248333 1 247934 226839 225554 237085 0 0 0 0 0 0 0 1 45 246969 1 248333 247934 226839 225554 0 0 0 0 0 0 0 0 46 245098 1 246969 248333 247934 226839 0 0 0 0 0 0 0 0 47 246263 1 245098 246969 248333 247934 0 0 0 0 0 0 0 0 48 255765 1 246263 245098 246969 248333 0 0 0 0 0 0 0 0 49 264319 1 255765 246263 245098 246969 1 0 0 0 0 0 0 0 50 268347 1 264319 255765 246263 245098 0 1 0 0 0 0 0 0 51 273046 1 268347 264319 255765 246263 0 0 1 0 0 0 0 0 52 273963 1 273046 268347 264319 255765 0 0 0 1 0 0 0 0 53 267430 1 273963 273046 268347 264319 0 0 0 0 1 0 0 0 54 271993 1 267430 273963 273046 268347 0 0 0 0 0 1 0 0 55 292710 1 271993 267430 273963 273046 0 0 0 0 0 0 1 0 56 295881 1 292710 271993 267430 273963 0 0 0 0 0 0 0 1 M9 M10 M11 t 1 0 0 0 1 2 0 0 0 2 3 0 0 0 3 4 0 0 0 4 5 0 0 0 5 6 0 0 0 6 7 0 0 0 7 8 0 0 0 8 9 1 0 0 9 10 0 1 0 10 11 0 0 1 11 12 0 0 0 12 13 0 0 0 13 14 0 0 0 14 15 0 0 0 15 16 0 0 0 16 17 0 0 0 17 18 0 0 0 18 19 0 0 0 19 20 0 0 0 20 21 1 0 0 21 22 0 1 0 22 23 0 0 1 23 24 0 0 0 24 25 0 0 0 25 26 0 0 0 26 27 0 0 0 27 28 0 0 0 28 29 0 0 0 29 30 0 0 0 30 31 0 0 0 31 32 0 0 0 32 33 1 0 0 33 34 0 1 0 34 35 0 0 1 35 36 0 0 0 36 37 0 0 0 37 38 0 0 0 38 39 0 0 0 39 40 0 0 0 40 41 0 0 0 41 42 0 0 0 42 43 0 0 0 43 44 0 0 0 44 45 1 0 0 45 46 0 1 0 46 47 0 0 1 47 48 0 0 0 48 49 0 0 0 49 50 0 0 0 50 51 0 0 0 51 52 0 0 0 52 53 0 0 0 53 54 0 0 0 54 55 0 0 0 55 56 0 0 0 56 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) dummy_variable `y[t-1]` `y[t-2]` `y[t-3]` 1.938e+04 5.208e+03 9.257e-01 1.709e-01 1.551e-01 `y[t-4]\r` M1 M2 M3 M4 -3.053e-01 8.377e+02 -2.931e+03 -8.038e+03 -5.572e+03 M5 M6 M7 M8 M9 -8.599e+03 -5.579e+03 1.766e+04 1.153e+03 -6.680e+03 M10 M11 t -1.611e+04 -9.459e+03 -9.901e+01 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -5461.9 -2009.5 385.6 2049.1 5224.7 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.938e+04 1.292e+04 1.500 0.141936 dummy_variable 5.208e+03 2.030e+03 2.566 0.014350 * `y[t-1]` 9.257e-01 1.463e-01 6.327 2.03e-07 *** `y[t-2]` 1.709e-01 2.085e-01 0.820 0.417506 `y[t-3]` 1.551e-01 2.142e-01 0.724 0.473358 `y[t-4]\r` -3.053e-01 1.562e-01 -1.955 0.057942 . M1 8.377e+02 2.719e+03 0.308 0.759669 M2 -2.931e+03 2.998e+03 -0.978 0.334330 M3 -8.038e+03 2.789e+03 -2.882 0.006463 ** M4 -5.572e+03 2.547e+03 -2.187 0.034932 * M5 -8.599e+03 2.449e+03 -3.512 0.001166 ** M6 -5.579e+03 2.466e+03 -2.262 0.029494 * M7 1.766e+04 2.403e+03 7.350 8.30e-09 *** M8 1.153e+03 4.661e+03 0.247 0.805994 M9 -6.680e+03 5.009e+03 -1.334 0.190280 M10 -1.611e+04 4.385e+03 -3.674 0.000733 *** M11 -9.459e+03 2.597e+03 -3.642 0.000804 *** t -9.901e+01 5.497e+01 -1.801 0.079596 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3475 on 38 degrees of freedom Multiple R-squared: 0.9746, Adjusted R-squared: 0.9633 F-statistic: 85.85 on 17 and 38 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,] 0.02563042 0.05126084 0.9743696 [2,] 0.59559048 0.80881904 0.4044095 [3,] 0.44733857 0.89467715 0.5526614 [4,] 0.48083412 0.96166823 0.5191659 [5,] 0.46737397 0.93474794 0.5326260 [6,] 0.36825051 0.73650101 0.6317495 [7,] 0.34618817 0.69237635 0.6538118 [8,] 0.45345705 0.90691409 0.5465430 [9,] 0.36202098 0.72404195 0.6379790 [10,] 0.48117075 0.96234150 0.5188293 [11,] 0.56645888 0.86708225 0.4335411 [12,] 0.74521859 0.50956281 0.2547814 [13,] 0.68220302 0.63559396 0.3177970 [14,] 0.63627733 0.72744535 0.3637227 [15,] 0.46498211 0.92996422 0.5350179 > postscript(file="/var/www/html/rcomp/tmp/1eith1258909059.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/29hc51258909059.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/3aua81258909059.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/494nk1258909059.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/55lkw1258909059.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 7 -3944.5014 316.1000 1482.9418 -3357.8653 1399.2640 265.2580 2015.5499 8 9 10 11 12 13 14 1284.3084 2302.6885 1907.7791 -1547.1886 -1788.8014 -3959.9183 1992.0381 15 16 17 18 19 20 21 1614.4376 1638.6417 5224.6626 959.5306 -1570.9801 -993.3664 4703.9505 22 23 24 25 26 27 28 -4970.8983 -2201.6864 -5096.4686 5111.9276 -1002.5569 -2855.1328 370.6724 29 30 31 32 33 34 35 1166.0211 -5461.9448 3260.1693 3242.0846 -1945.4349 2149.8903 -120.3388 36 37 38 39 40 41 42 3299.6539 512.7737 -1187.1489 -3719.8847 2785.3866 -3281.6136 712.2364 43 44 45 46 47 48 49 -2987.0156 -3933.5715 -5061.2041 913.2289 3869.2138 3585.6162 2279.7184 50 51 52 53 54 55 56 -118.4322 3477.6381 -1436.8354 -4508.3341 3524.9198 -717.7235 400.5447 > postscript(file="/var/www/html/rcomp/tmp/6l6sv1258909059.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 -3944.5014 NA 1 316.1000 -3944.5014 2 1482.9418 316.1000 3 -3357.8653 1482.9418 4 1399.2640 -3357.8653 5 265.2580 1399.2640 6 2015.5499 265.2580 7 1284.3084 2015.5499 8 2302.6885 1284.3084 9 1907.7791 2302.6885 10 -1547.1886 1907.7791 11 -1788.8014 -1547.1886 12 -3959.9183 -1788.8014 13 1992.0381 -3959.9183 14 1614.4376 1992.0381 15 1638.6417 1614.4376 16 5224.6626 1638.6417 17 959.5306 5224.6626 18 -1570.9801 959.5306 19 -993.3664 -1570.9801 20 4703.9505 -993.3664 21 -4970.8983 4703.9505 22 -2201.6864 -4970.8983 23 -5096.4686 -2201.6864 24 5111.9276 -5096.4686 25 -1002.5569 5111.9276 26 -2855.1328 -1002.5569 27 370.6724 -2855.1328 28 1166.0211 370.6724 29 -5461.9448 1166.0211 30 3260.1693 -5461.9448 31 3242.0846 3260.1693 32 -1945.4349 3242.0846 33 2149.8903 -1945.4349 34 -120.3388 2149.8903 35 3299.6539 -120.3388 36 512.7737 3299.6539 37 -1187.1489 512.7737 38 -3719.8847 -1187.1489 39 2785.3866 -3719.8847 40 -3281.6136 2785.3866 41 712.2364 -3281.6136 42 -2987.0156 712.2364 43 -3933.5715 -2987.0156 44 -5061.2041 -3933.5715 45 913.2289 -5061.2041 46 3869.2138 913.2289 47 3585.6162 3869.2138 48 2279.7184 3585.6162 49 -118.4322 2279.7184 50 3477.6381 -118.4322 51 -1436.8354 3477.6381 52 -4508.3341 -1436.8354 53 3524.9198 -4508.3341 54 -717.7235 3524.9198 55 400.5447 -717.7235 56 NA 400.5447 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] 316.1000 -3944.5014 [2,] 1482.9418 316.1000 [3,] -3357.8653 1482.9418 [4,] 1399.2640 -3357.8653 [5,] 265.2580 1399.2640 [6,] 2015.5499 265.2580 [7,] 1284.3084 2015.5499 [8,] 2302.6885 1284.3084 [9,] 1907.7791 2302.6885 [10,] -1547.1886 1907.7791 [11,] -1788.8014 -1547.1886 [12,] -3959.9183 -1788.8014 [13,] 1992.0381 -3959.9183 [14,] 1614.4376 1992.0381 [15,] 1638.6417 1614.4376 [16,] 5224.6626 1638.6417 [17,] 959.5306 5224.6626 [18,] -1570.9801 959.5306 [19,] -993.3664 -1570.9801 [20,] 4703.9505 -993.3664 [21,] -4970.8983 4703.9505 [22,] -2201.6864 -4970.8983 [23,] -5096.4686 -2201.6864 [24,] 5111.9276 -5096.4686 [25,] -1002.5569 5111.9276 [26,] -2855.1328 -1002.5569 [27,] 370.6724 -2855.1328 [28,] 1166.0211 370.6724 [29,] -5461.9448 1166.0211 [30,] 3260.1693 -5461.9448 [31,] 3242.0846 3260.1693 [32,] -1945.4349 3242.0846 [33,] 2149.8903 -1945.4349 [34,] -120.3388 2149.8903 [35,] 3299.6539 -120.3388 [36,] 512.7737 3299.6539 [37,] -1187.1489 512.7737 [38,] -3719.8847 -1187.1489 [39,] 2785.3866 -3719.8847 [40,] -3281.6136 2785.3866 [41,] 712.2364 -3281.6136 [42,] -2987.0156 712.2364 [43,] -3933.5715 -2987.0156 [44,] -5061.2041 -3933.5715 [45,] 913.2289 -5061.2041 [46,] 3869.2138 913.2289 [47,] 3585.6162 3869.2138 [48,] 2279.7184 3585.6162 [49,] -118.4322 2279.7184 [50,] 3477.6381 -118.4322 [51,] -1436.8354 3477.6381 [52,] -4508.3341 -1436.8354 [53,] 3524.9198 -4508.3341 [54,] -717.7235 3524.9198 [55,] 400.5447 -717.7235 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 316.1000 -3944.5014 2 1482.9418 316.1000 3 -3357.8653 1482.9418 4 1399.2640 -3357.8653 5 265.2580 1399.2640 6 2015.5499 265.2580 7 1284.3084 2015.5499 8 2302.6885 1284.3084 9 1907.7791 2302.6885 10 -1547.1886 1907.7791 11 -1788.8014 -1547.1886 12 -3959.9183 -1788.8014 13 1992.0381 -3959.9183 14 1614.4376 1992.0381 15 1638.6417 1614.4376 16 5224.6626 1638.6417 17 959.5306 5224.6626 18 -1570.9801 959.5306 19 -993.3664 -1570.9801 20 4703.9505 -993.3664 21 -4970.8983 4703.9505 22 -2201.6864 -4970.8983 23 -5096.4686 -2201.6864 24 5111.9276 -5096.4686 25 -1002.5569 5111.9276 26 -2855.1328 -1002.5569 27 370.6724 -2855.1328 28 1166.0211 370.6724 29 -5461.9448 1166.0211 30 3260.1693 -5461.9448 31 3242.0846 3260.1693 32 -1945.4349 3242.0846 33 2149.8903 -1945.4349 34 -120.3388 2149.8903 35 3299.6539 -120.3388 36 512.7737 3299.6539 37 -1187.1489 512.7737 38 -3719.8847 -1187.1489 39 2785.3866 -3719.8847 40 -3281.6136 2785.3866 41 712.2364 -3281.6136 42 -2987.0156 712.2364 43 -3933.5715 -2987.0156 44 -5061.2041 -3933.5715 45 913.2289 -5061.2041 46 3869.2138 913.2289 47 3585.6162 3869.2138 48 2279.7184 3585.6162 49 -118.4322 2279.7184 50 3477.6381 -118.4322 51 -1436.8354 3477.6381 52 -4508.3341 -1436.8354 53 3524.9198 -4508.3341 54 -717.7235 3524.9198 55 400.5447 -717.7235 > 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/7dg491258909059.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/87hm91258909059.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/9uduu1258909059.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/103ak21258909059.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/11z61m1258909059.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/12kzim1258909059.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/1331yj1258909059.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/14irmm1258909059.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/15hpk41258909059.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/160mbg1258909059.tab") + } > > system("convert tmp/1eith1258909059.ps tmp/1eith1258909059.png") > system("convert tmp/29hc51258909059.ps tmp/29hc51258909059.png") > system("convert tmp/3aua81258909059.ps tmp/3aua81258909059.png") > system("convert tmp/494nk1258909059.ps tmp/494nk1258909059.png") > system("convert tmp/55lkw1258909059.ps tmp/55lkw1258909059.png") > system("convert tmp/6l6sv1258909059.ps tmp/6l6sv1258909059.png") > system("convert tmp/7dg491258909059.ps tmp/7dg491258909059.png") > system("convert tmp/87hm91258909059.ps tmp/87hm91258909059.png") > system("convert tmp/9uduu1258909059.ps tmp/9uduu1258909059.png") > system("convert tmp/103ak21258909059.ps tmp/103ak21258909059.png") > > > proc.time() user system elapsed 2.363 1.608 2.886