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(900.1 + ,33 + ,880.4 + ,849.4 + ,819.3 + ,785.8 + ,937.2 + ,31.3 + ,900.1 + ,880.4 + ,849.4 + ,819.3 + ,948.9 + ,29 + ,937.2 + ,900.1 + ,880.4 + ,849.4 + ,952.6 + ,28.7 + ,948.9 + ,937.2 + ,900.1 + ,880.4 + ,947.3 + ,28 + ,952.6 + ,948.9 + ,937.2 + ,900.1 + ,974.2 + ,29.7 + ,947.3 + ,952.6 + ,948.9 + ,937.2 + ,1000.8 + ,30.7 + ,974.2 + ,947.3 + ,952.6 + ,948.9 + ,1032.8 + ,24 + ,1000.8 + ,974.2 + ,947.3 + ,952.6 + ,1050.7 + ,29 + ,1032.8 + ,1000.8 + ,974.2 + ,947.3 + ,1057.3 + ,33 + ,1050.7 + ,1032.8 + ,1000.8 + ,974.2 + ,1075.4 + ,28 + ,1057.3 + ,1050.7 + ,1032.8 + ,1000.8 + ,1118.4 + ,28.7 + ,1075.4 + ,1057.3 + ,1050.7 + ,1032.8 + ,1179.8 + ,31.7 + ,1118.4 + ,1075.4 + ,1057.3 + ,1050.7 + ,1227 + ,34 + ,1179.8 + ,1118.4 + ,1075.4 + ,1057.3 + ,1257.8 + ,35.3 + ,1227 + ,1179.8 + ,1118.4 + ,1075.4 + ,1251.5 + ,27 + ,1257.8 + ,1227 + ,1179.8 + ,1118.4 + ,1236.3 + ,31.3 + ,1251.5 + ,1257.8 + ,1227 + ,1179.8 + ,1170.6 + ,38.7 + ,1236.3 + ,1251.5 + ,1257.8 + ,1227 + ,1213.1 + ,37.3 + ,1170.6 + ,1236.3 + ,1251.5 + ,1257.8 + ,1265.5 + ,37.3 + ,1213.1 + ,1170.6 + ,1236.3 + ,1251.5 + ,1300.8 + ,37.7 + ,1265.5 + ,1213.1 + ,1170.6 + ,1236.3 + ,1348.4 + ,34.7 + ,1300.8 + ,1265.5 + ,1213.1 + ,1170.6 + ,1371.9 + ,34.7 + ,1348.4 + ,1300.8 + ,1265.5 + ,1213.1 + ,1403.3 + ,33.7 + ,1371.9 + ,1348.4 + ,1300.8 + ,1265.5 + ,1451.8 + ,38.3 + ,1403.3 + ,1371.9 + ,1348.4 + ,1300.8 + ,1474.2 + ,38 + ,1451.8 + ,1403.3 + ,1371.9 + ,1348.4 + ,1438.2 + ,38.3 + ,1474.2 + ,1451.8 + ,1403.3 + ,1371.9 + ,1513.6 + ,42.7 + ,1438.2 + ,1474.2 + ,1451.8 + ,1403.3 + ,1562.2 + ,41.7 + ,1513.6 + ,1438.2 + ,1474.2 + ,1451.8 + ,1546.2 + ,39.7 + ,1562.2 + ,1513.6 + ,1438.2 + ,1474.2 + ,1527.5 + ,39.3 + ,1546.2 + ,1562.2 + ,1513.6 + ,1438.2 + ,1418.7 + ,39.3 + ,1527.5 + ,1546.2 + ,1562.2 + ,1513.6 + ,1448.5 + ,37.7 + ,1418.7 + ,1527.5 + ,1546.2 + ,1562.2 + ,1492.1 + ,38.3 + ,1448.5 + ,1418.7 + ,1527.5 + ,1546.2 + ,1395.4 + ,37.7 + ,1492.1 + ,1448.5 + ,1418.7 + ,1527.5 + ,1403.7 + ,37 + ,1395.4 + ,1492.1 + ,1448.5 + ,1418.7 + ,1316.6 + ,34.3 + ,1403.7 + ,1395.4 + ,1492.1 + ,1448.5 + ,1274.5 + ,29.7 + ,1316.6 + ,1403.7 + ,1395.4 + ,1492.1 + ,1264.4 + ,34.7 + ,1274.5 + ,1316.6 + ,1403.7 + ,1395.4 + ,1323.9 + ,32 + ,1264.4 + ,1274.5 + ,1316.6 + ,1403.7 + ,1332.1 + ,30.3 + ,1323.9 + ,1264.4 + ,1274.5 + ,1316.6 + ,1250.2 + ,28.3 + ,1332.1 + ,1323.9 + ,1264.4 + ,1274.5 + ,1096.7 + ,31.3 + ,1250.2 + ,1332.1 + ,1323.9 + ,1264.4 + ,1080.8 + ,17.7 + ,1096.7 + ,1250.2 + ,1332.1 + ,1323.9 + ,1039.2 + ,15.7 + ,1080.8 + ,1096.7 + ,1250.2 + ,1332.1 + ,792 + ,14.3 + ,1039.2 + ,1080.8 + ,1096.7 + ,1250.2 + ,746.6 + ,13.3 + ,792 + ,1039.2 + ,1080.8 + ,1096.7 + ,688.8 + ,11 + ,746.6 + ,792 + ,1039.2 + ,1080.8 + ,715.8 + ,2.7 + ,688.8 + ,746.6 + ,792 + ,1039.2 + ,672.9 + ,3.3 + ,715.8 + ,688.8 + ,746.6 + ,792 + ,629.5 + ,3.7 + ,672.9 + ,715.8 + ,688.8 + ,746.6 + ,681.2 + ,1.4 + ,629.5 + ,672.9 + ,715.8 + ,688.8 + ,755.4 + ,7.1 + ,681.2 + ,629.5 + ,672.9 + ,715.8 + ,760.6 + ,8.1 + ,755.4 + ,681.2 + ,629.5 + ,672.9 + ,765.9 + ,12.4 + ,760.6 + ,755.4 + ,681.2 + ,629.5 + ,836.8 + ,12.4 + ,765.9 + ,760.6 + ,755.4 + ,681.2 + ,904.9 + ,9.2 + ,836.8 + ,765.9 + ,760.6 + ,755.4) + ,dim=c(6 + ,57) + ,dimnames=list(c('Y' + ,'X' + ,'Y1' + ,'Y2' + ,'Y3' + ,'Y4') + ,1:57)) > y <- array(NA,dim=c(6,57),dimnames=list(c('Y','X','Y1','Y2','Y3','Y4'),1:57)) > 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 900.1 33.0 880.4 849.4 819.3 785.8 1 0 0 0 0 0 0 0 0 0 0 2 937.2 31.3 900.1 880.4 849.4 819.3 0 1 0 0 0 0 0 0 0 0 0 3 948.9 29.0 937.2 900.1 880.4 849.4 0 0 1 0 0 0 0 0 0 0 0 4 952.6 28.7 948.9 937.2 900.1 880.4 0 0 0 1 0 0 0 0 0 0 0 5 947.3 28.0 952.6 948.9 937.2 900.1 0 0 0 0 1 0 0 0 0 0 0 6 974.2 29.7 947.3 952.6 948.9 937.2 0 0 0 0 0 1 0 0 0 0 0 7 1000.8 30.7 974.2 947.3 952.6 948.9 0 0 0 0 0 0 1 0 0 0 0 8 1032.8 24.0 1000.8 974.2 947.3 952.6 0 0 0 0 0 0 0 1 0 0 0 9 1050.7 29.0 1032.8 1000.8 974.2 947.3 0 0 0 0 0 0 0 0 1 0 0 10 1057.3 33.0 1050.7 1032.8 1000.8 974.2 0 0 0 0 0 0 0 0 0 1 0 11 1075.4 28.0 1057.3 1050.7 1032.8 1000.8 0 0 0 0 0 0 0 0 0 0 1 12 1118.4 28.7 1075.4 1057.3 1050.7 1032.8 0 0 0 0 0 0 0 0 0 0 0 13 1179.8 31.7 1118.4 1075.4 1057.3 1050.7 1 0 0 0 0 0 0 0 0 0 0 14 1227.0 34.0 1179.8 1118.4 1075.4 1057.3 0 1 0 0 0 0 0 0 0 0 0 15 1257.8 35.3 1227.0 1179.8 1118.4 1075.4 0 0 1 0 0 0 0 0 0 0 0 16 1251.5 27.0 1257.8 1227.0 1179.8 1118.4 0 0 0 1 0 0 0 0 0 0 0 17 1236.3 31.3 1251.5 1257.8 1227.0 1179.8 0 0 0 0 1 0 0 0 0 0 0 18 1170.6 38.7 1236.3 1251.5 1257.8 1227.0 0 0 0 0 0 1 0 0 0 0 0 19 1213.1 37.3 1170.6 1236.3 1251.5 1257.8 0 0 0 0 0 0 1 0 0 0 0 20 1265.5 37.3 1213.1 1170.6 1236.3 1251.5 0 0 0 0 0 0 0 1 0 0 0 21 1300.8 37.7 1265.5 1213.1 1170.6 1236.3 0 0 0 0 0 0 0 0 1 0 0 22 1348.4 34.7 1300.8 1265.5 1213.1 1170.6 0 0 0 0 0 0 0 0 0 1 0 23 1371.9 34.7 1348.4 1300.8 1265.5 1213.1 0 0 0 0 0 0 0 0 0 0 1 24 1403.3 33.7 1371.9 1348.4 1300.8 1265.5 0 0 0 0 0 0 0 0 0 0 0 25 1451.8 38.3 1403.3 1371.9 1348.4 1300.8 1 0 0 0 0 0 0 0 0 0 0 26 1474.2 38.0 1451.8 1403.3 1371.9 1348.4 0 1 0 0 0 0 0 0 0 0 0 27 1438.2 38.3 1474.2 1451.8 1403.3 1371.9 0 0 1 0 0 0 0 0 0 0 0 28 1513.6 42.7 1438.2 1474.2 1451.8 1403.3 0 0 0 1 0 0 0 0 0 0 0 29 1562.2 41.7 1513.6 1438.2 1474.2 1451.8 0 0 0 0 1 0 0 0 0 0 0 30 1546.2 39.7 1562.2 1513.6 1438.2 1474.2 0 0 0 0 0 1 0 0 0 0 0 31 1527.5 39.3 1546.2 1562.2 1513.6 1438.2 0 0 0 0 0 0 1 0 0 0 0 32 1418.7 39.3 1527.5 1546.2 1562.2 1513.6 0 0 0 0 0 0 0 1 0 0 0 33 1448.5 37.7 1418.7 1527.5 1546.2 1562.2 0 0 0 0 0 0 0 0 1 0 0 34 1492.1 38.3 1448.5 1418.7 1527.5 1546.2 0 0 0 0 0 0 0 0 0 1 0 35 1395.4 37.7 1492.1 1448.5 1418.7 1527.5 0 0 0 0 0 0 0 0 0 0 1 36 1403.7 37.0 1395.4 1492.1 1448.5 1418.7 0 0 0 0 0 0 0 0 0 0 0 37 1316.6 34.3 1403.7 1395.4 1492.1 1448.5 1 0 0 0 0 0 0 0 0 0 0 38 1274.5 29.7 1316.6 1403.7 1395.4 1492.1 0 1 0 0 0 0 0 0 0 0 0 39 1264.4 34.7 1274.5 1316.6 1403.7 1395.4 0 0 1 0 0 0 0 0 0 0 0 40 1323.9 32.0 1264.4 1274.5 1316.6 1403.7 0 0 0 1 0 0 0 0 0 0 0 41 1332.1 30.3 1323.9 1264.4 1274.5 1316.6 0 0 0 0 1 0 0 0 0 0 0 42 1250.2 28.3 1332.1 1323.9 1264.4 1274.5 0 0 0 0 0 1 0 0 0 0 0 43 1096.7 31.3 1250.2 1332.1 1323.9 1264.4 0 0 0 0 0 0 1 0 0 0 0 44 1080.8 17.7 1096.7 1250.2 1332.1 1323.9 0 0 0 0 0 0 0 1 0 0 0 45 1039.2 15.7 1080.8 1096.7 1250.2 1332.1 0 0 0 0 0 0 0 0 1 0 0 46 792.0 14.3 1039.2 1080.8 1096.7 1250.2 0 0 0 0 0 0 0 0 0 1 0 47 746.6 13.3 792.0 1039.2 1080.8 1096.7 0 0 0 0 0 0 0 0 0 0 1 48 688.8 11.0 746.6 792.0 1039.2 1080.8 0 0 0 0 0 0 0 0 0 0 0 49 715.8 2.7 688.8 746.6 792.0 1039.2 1 0 0 0 0 0 0 0 0 0 0 50 672.9 3.3 715.8 688.8 746.6 792.0 0 1 0 0 0 0 0 0 0 0 0 51 629.5 3.7 672.9 715.8 688.8 746.6 0 0 1 0 0 0 0 0 0 0 0 52 681.2 1.4 629.5 672.9 715.8 688.8 0 0 0 1 0 0 0 0 0 0 0 53 755.4 7.1 681.2 629.5 672.9 715.8 0 0 0 0 1 0 0 0 0 0 0 54 760.6 8.1 755.4 681.2 629.5 672.9 0 0 0 0 0 1 0 0 0 0 0 55 765.9 12.4 760.6 755.4 681.2 629.5 0 0 0 0 0 0 1 0 0 0 0 56 836.8 12.4 765.9 760.6 755.4 681.2 0 0 0 0 0 0 0 1 0 0 0 57 904.9 9.2 836.8 765.9 760.6 755.4 0 0 0 0 0 0 0 0 1 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 57 57 > k <- length(x[1,]) > df <- as.data.frame(x) > (mylm <- lm(df)) Call: lm(formula = df) Coefficients: (Intercept) X Y1 Y2 Y3 Y4 89.73117 6.02273 1.03931 -0.14931 -0.03970 -0.09415 M1 M2 M3 M4 M5 M6 -9.91199 -18.00632 -37.75743 20.77361 -4.61820 -57.07722 M7 M8 M9 M10 M11 t -54.63009 -4.68642 9.28293 -50.79586 -29.81918 1.37270 > (mysum <- summary(mylm)) Call: lm(formula = df) Residuals: Min 1Q Median 3Q Max -153.635 -18.954 9.997 27.295 88.424 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 89.73117 47.45805 1.891 0.0661 . X 6.02273 2.51439 2.395 0.0215 * Y1 1.03931 0.16611 6.257 2.28e-07 *** Y2 -0.14931 0.23482 -0.636 0.5286 Y3 -0.03970 0.24233 -0.164 0.8707 Y4 -0.09415 0.15661 -0.601 0.5512 M1 -9.91199 38.07506 -0.260 0.7960 M2 -18.00632 38.21460 -0.471 0.6401 M3 -37.75743 37.88625 -0.997 0.3251 M4 20.77361 37.45093 0.555 0.5823 M5 -4.61820 38.04822 -0.121 0.9040 M6 -57.07722 39.34799 -1.451 0.1549 M7 -54.63009 39.05607 -1.399 0.1698 M8 -4.68642 37.05144 -0.126 0.9000 M9 9.28293 37.80429 0.246 0.8073 M10 -50.79586 39.98677 -1.270 0.2115 M11 -29.81918 39.95095 -0.746 0.4599 t 1.37270 0.92382 1.486 0.1453 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 55.05 on 39 degrees of freedom Multiple R-squared: 0.9704, Adjusted R-squared: 0.9576 F-statistic: 75.31 on 17 and 39 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,] 6.257037e-02 0.1251407491 0.9374296 [2,] 2.622969e-02 0.0524593893 0.9737703 [3,] 7.304448e-03 0.0146088954 0.9926956 [4,] 1.832219e-03 0.0036644389 0.9981678 [5,] 4.496160e-04 0.0008992320 0.9995504 [6,] 9.672486e-05 0.0001934497 0.9999033 [7,] 2.371350e-04 0.0004742700 0.9997629 [8,] 2.695871e-04 0.0005391743 0.9997304 [9,] 4.428661e-04 0.0008857322 0.9995571 [10,] 2.204523e-04 0.0004409045 0.9997795 [11,] 1.913298e-04 0.0003826597 0.9998087 [12,] 1.576488e-03 0.0031529751 0.9984235 [13,] 1.956045e-02 0.0391208959 0.9804396 [14,] 1.867441e-01 0.3734881668 0.8132559 [15,] 4.682211e-01 0.9364422491 0.5317789 [16,] 4.130901e-01 0.8261801075 0.5869099 > postscript(file="/var/www/html/rcomp/tmp/1ufkd1258556748.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/2azff1258556748.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/3wmx31258556748.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/4cr5l1258556748.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/5lk2c1258556748.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 = 57 Frequency = 1 1 2 3 4 5 6 -61.5172770 -18.9537888 -6.5754830 -63.8921362 -39.7281042 38.0378587 7 8 9 10 11 12 27.2949917 24.8397545 -31.4333597 -0.4552664 24.9969649 18.4865613 13 14 15 16 17 18 30.3172168 14.3332721 19.2055225 -15.4869111 -13.7645127 -52.4229504 19 20 21 22 23 24 63.3519526 9.2586464 -25.3456628 65.6661585 28.6978818 23.9470323 25 26 27 28 29 30 29.3693514 19.9941938 -12.0141150 22.6234554 22.9817460 31.5411650 31 32 33 34 35 36 34.9194621 -99.1225115 39.1972276 88.4244320 -73.9552128 5.3191376 37 38 39 40 41 42 -75.5084150 8.8474197 8.9869923 26.3796402 -4.3814064 -27.1526711 43 44 45 46 47 48 -114.7859698 53.1397530 -0.6301179 -153.6353241 20.2603661 -47.7527312 49 50 51 52 53 54 77.3391238 -24.2210969 -9.6029167 30.3759517 34.8922772 9.9965978 55 56 57 -10.7804366 11.8843577 18.2119128 > postscript(file="/var/www/html/rcomp/tmp/68i991258556748.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 = 57 Frequency = 1 lag(myerror, k = 1) myerror 0 -61.5172770 NA 1 -18.9537888 -61.5172770 2 -6.5754830 -18.9537888 3 -63.8921362 -6.5754830 4 -39.7281042 -63.8921362 5 38.0378587 -39.7281042 6 27.2949917 38.0378587 7 24.8397545 27.2949917 8 -31.4333597 24.8397545 9 -0.4552664 -31.4333597 10 24.9969649 -0.4552664 11 18.4865613 24.9969649 12 30.3172168 18.4865613 13 14.3332721 30.3172168 14 19.2055225 14.3332721 15 -15.4869111 19.2055225 16 -13.7645127 -15.4869111 17 -52.4229504 -13.7645127 18 63.3519526 -52.4229504 19 9.2586464 63.3519526 20 -25.3456628 9.2586464 21 65.6661585 -25.3456628 22 28.6978818 65.6661585 23 23.9470323 28.6978818 24 29.3693514 23.9470323 25 19.9941938 29.3693514 26 -12.0141150 19.9941938 27 22.6234554 -12.0141150 28 22.9817460 22.6234554 29 31.5411650 22.9817460 30 34.9194621 31.5411650 31 -99.1225115 34.9194621 32 39.1972276 -99.1225115 33 88.4244320 39.1972276 34 -73.9552128 88.4244320 35 5.3191376 -73.9552128 36 -75.5084150 5.3191376 37 8.8474197 -75.5084150 38 8.9869923 8.8474197 39 26.3796402 8.9869923 40 -4.3814064 26.3796402 41 -27.1526711 -4.3814064 42 -114.7859698 -27.1526711 43 53.1397530 -114.7859698 44 -0.6301179 53.1397530 45 -153.6353241 -0.6301179 46 20.2603661 -153.6353241 47 -47.7527312 20.2603661 48 77.3391238 -47.7527312 49 -24.2210969 77.3391238 50 -9.6029167 -24.2210969 51 30.3759517 -9.6029167 52 34.8922772 30.3759517 53 9.9965978 34.8922772 54 -10.7804366 9.9965978 55 11.8843577 -10.7804366 56 18.2119128 11.8843577 57 NA 18.2119128 > dum1 <- dum[2:length(myerror),] > dum1 lag(myerror, k = 1) myerror [1,] -18.9537888 -61.5172770 [2,] -6.5754830 -18.9537888 [3,] -63.8921362 -6.5754830 [4,] -39.7281042 -63.8921362 [5,] 38.0378587 -39.7281042 [6,] 27.2949917 38.0378587 [7,] 24.8397545 27.2949917 [8,] -31.4333597 24.8397545 [9,] -0.4552664 -31.4333597 [10,] 24.9969649 -0.4552664 [11,] 18.4865613 24.9969649 [12,] 30.3172168 18.4865613 [13,] 14.3332721 30.3172168 [14,] 19.2055225 14.3332721 [15,] -15.4869111 19.2055225 [16,] -13.7645127 -15.4869111 [17,] -52.4229504 -13.7645127 [18,] 63.3519526 -52.4229504 [19,] 9.2586464 63.3519526 [20,] -25.3456628 9.2586464 [21,] 65.6661585 -25.3456628 [22,] 28.6978818 65.6661585 [23,] 23.9470323 28.6978818 [24,] 29.3693514 23.9470323 [25,] 19.9941938 29.3693514 [26,] -12.0141150 19.9941938 [27,] 22.6234554 -12.0141150 [28,] 22.9817460 22.6234554 [29,] 31.5411650 22.9817460 [30,] 34.9194621 31.5411650 [31,] -99.1225115 34.9194621 [32,] 39.1972276 -99.1225115 [33,] 88.4244320 39.1972276 [34,] -73.9552128 88.4244320 [35,] 5.3191376 -73.9552128 [36,] -75.5084150 5.3191376 [37,] 8.8474197 -75.5084150 [38,] 8.9869923 8.8474197 [39,] 26.3796402 8.9869923 [40,] -4.3814064 26.3796402 [41,] -27.1526711 -4.3814064 [42,] -114.7859698 -27.1526711 [43,] 53.1397530 -114.7859698 [44,] -0.6301179 53.1397530 [45,] -153.6353241 -0.6301179 [46,] 20.2603661 -153.6353241 [47,] -47.7527312 20.2603661 [48,] 77.3391238 -47.7527312 [49,] -24.2210969 77.3391238 [50,] -9.6029167 -24.2210969 [51,] 30.3759517 -9.6029167 [52,] 34.8922772 30.3759517 [53,] 9.9965978 34.8922772 [54,] -10.7804366 9.9965978 [55,] 11.8843577 -10.7804366 [56,] 18.2119128 11.8843577 > z <- as.data.frame(dum1) > z lag(myerror, k = 1) myerror 1 -18.9537888 -61.5172770 2 -6.5754830 -18.9537888 3 -63.8921362 -6.5754830 4 -39.7281042 -63.8921362 5 38.0378587 -39.7281042 6 27.2949917 38.0378587 7 24.8397545 27.2949917 8 -31.4333597 24.8397545 9 -0.4552664 -31.4333597 10 24.9969649 -0.4552664 11 18.4865613 24.9969649 12 30.3172168 18.4865613 13 14.3332721 30.3172168 14 19.2055225 14.3332721 15 -15.4869111 19.2055225 16 -13.7645127 -15.4869111 17 -52.4229504 -13.7645127 18 63.3519526 -52.4229504 19 9.2586464 63.3519526 20 -25.3456628 9.2586464 21 65.6661585 -25.3456628 22 28.6978818 65.6661585 23 23.9470323 28.6978818 24 29.3693514 23.9470323 25 19.9941938 29.3693514 26 -12.0141150 19.9941938 27 22.6234554 -12.0141150 28 22.9817460 22.6234554 29 31.5411650 22.9817460 30 34.9194621 31.5411650 31 -99.1225115 34.9194621 32 39.1972276 -99.1225115 33 88.4244320 39.1972276 34 -73.9552128 88.4244320 35 5.3191376 -73.9552128 36 -75.5084150 5.3191376 37 8.8474197 -75.5084150 38 8.9869923 8.8474197 39 26.3796402 8.9869923 40 -4.3814064 26.3796402 41 -27.1526711 -4.3814064 42 -114.7859698 -27.1526711 43 53.1397530 -114.7859698 44 -0.6301179 53.1397530 45 -153.6353241 -0.6301179 46 20.2603661 -153.6353241 47 -47.7527312 20.2603661 48 77.3391238 -47.7527312 49 -24.2210969 77.3391238 50 -9.6029167 -24.2210969 51 30.3759517 -9.6029167 52 34.8922772 30.3759517 53 9.9965978 34.8922772 54 -10.7804366 9.9965978 55 11.8843577 -10.7804366 56 18.2119128 11.8843577 > 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/7g69m1258556748.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/8qe7g1258556748.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/9nvdx1258556748.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/105i1v1258556748.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/11skgx1258556748.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/12uxyy1258556748.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/134ngb1258556748.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/144qcj1258556749.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/15y0t41258556749.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/16ta211258556749.tab") + } > > system("convert tmp/1ufkd1258556748.ps tmp/1ufkd1258556748.png") > system("convert tmp/2azff1258556748.ps tmp/2azff1258556748.png") > system("convert tmp/3wmx31258556748.ps tmp/3wmx31258556748.png") > system("convert tmp/4cr5l1258556748.ps tmp/4cr5l1258556748.png") > system("convert tmp/5lk2c1258556748.ps tmp/5lk2c1258556748.png") > system("convert tmp/68i991258556748.ps tmp/68i991258556748.png") > system("convert tmp/7g69m1258556748.ps tmp/7g69m1258556748.png") > system("convert tmp/8qe7g1258556748.ps tmp/8qe7g1258556748.png") > system("convert tmp/9nvdx1258556748.ps tmp/9nvdx1258556748.png") > system("convert tmp/105i1v1258556748.ps tmp/105i1v1258556748.png") > > > proc.time() user system elapsed 2.366 1.589 2.826