R version 2.12.1 (2010-12-16) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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 <- c(411 + ,410 + ,415 + ,414 + ,411 + ,408 + ,410 + ,411 + ,416 + ,479 + ,498 + ,502 + ,498 + ,499 + ,506 + ,510 + ,509 + ,502 + ,495 + ,490 + ,490 + ,553 + ,570 + ,573 + ,572 + ,575 + ,580 + ,580 + ,574 + ,563 + ,556 + ,546 + ,545 + ,605 + ,628 + ,631 + ,626 + ,614 + ,606 + ,602 + ,589 + ,574 + ,558 + ,552 + ,546 + ,607 + ,636 + ,631 + ,623 + ,618 + ,605 + ,619 + ,596 + ,570 + ,546 + ,528 + ,506 + ,555 + ,568 + ,564 + ,553 + ,541 + ,542 + ,540 + ,521 + ,505 + ,491 + ,482 + ,478 + ,523 + ,531 + ,532 + ,540 + ,525 + ,533 + ,531 + ,508 + ,495 + ,482 + ,470 + ,466 + ,515 + ,518 + ,516 + ,511 + ,500 + ,498 + ,494 + ,476 + ,458 + ,443 + ,430 + ,424 + ,476 + ,481 + ,470 + ,460 + ,451 + ,450 + ,444 + ,429 + ,421 + ,400 + ,389 + ,384 + ,432 + ,446 + ,431 + ,423 + ,416 + ,416 + ,413 + ,399 + ,386 + ,374 + ,365 + ,365 + ,418 + ,428 + ,424 + ,421 + ,417 + ,423 + ,423 + ,419 + ,406 + ,398 + ,390 + ,391 + ,444 + ,460 + ,455 + ,456 + ,452 + ,459 + ,461 + ,451 + ,443 + ,439 + ,430 + ,436 + ,488 + ,506 + ,502 + ,501 + ,501 + ,515 + ,521 + ,520 + ,512 + ,509 + ,505 + ,511 + ,570 + ,592 + ,594 + ,586 + ,586 + ,592 + ,594 + ,586 + ,572 + ,563 + ,555 + ,554 + ,601 + ,622 + ,617 + ,606 + ,595 + ,599 + ,600 + ,592 + ,575 + ,567 + ,555 + ,555 + ,608 + ,631 + ,629 + ,624 + ,610 + ,616 + ,621 + ,604 + ,584 + ,574 + ,555 + ,545 + ,599 + ,620 + ,608 + ,590 + ,579 + ,580 + ,579 + ,572 + ,560 + ,551 + ,537 + ,541 + ,588 + ,607 + ,599 + ,578 + ,563 + ,566 + ,561 + ,554 + ,540 + ,526 + ,512 + ,505 + ,554 + ,584 + ,569 + ,540 + ,522 + ,526 + ,527 + ,516 + ,503 + ,489 + ,479 + ,475 + ,524 + ,552 + ,532 + ,511 + ,492 + ,492 + ,493 + ,481 + ,462 + ,457 + ,442 + ,439 + ,488 + ,521 + ,501 + ,485 + ,464 + ,460 + ,467 + ,460 + ,448 + ,443 + ,436 + ,431 + ,484 + ,510 + ,513 + ,503 + ,471 + ,471 + ,476 + ,475 + ,470 + ,461 + ,455 + ,456 + ,517 + ,525 + ,523 + ,519 + ,509 + ,512 + ,519 + ,517 + ,510 + ,509 + ,501 + ,507 + ,569 + ,580 + ,578 + ,565 + ,547 + ,555 + ,562 + ,561 + ,555 + ,544 + ,537 + ,543 + ,594 + ,611 + ,613 + ,611 + ,594 + ,595 + ,591 + ,589 + ,584 + ,573 + ,567 + ,569 + ,621 + ,629 + ,628 + ,612 + ,595 + ,597 + ,593 + ,590 + ,580 + ,574 + ,573 + ,573 + ,620 + ,626 + ,620 + ,588 + ,566 + ,557 + ,561 + ,549 + ,532 + ,526 + ,511 + ,499 + ,555 + ,565 + ,542 + ,527 + ,510 + ,514 + ,517 + ,508 + ,493 + ,490 + ,469 + ,478 + ,528 + ,534 + ,518 + ,506 + ,502 + ,516 + ,528 + ,533 + ,536 + ,537 + ,524 + ,536 + ,587 + ,597 + ,581 + ,564 + ,558 + ,575 + ,580 + ,575 + ,563 + ,552 + ,537 + ,545 + ,601 + ,604 + ,586 + ,564 + ,549 + ,551 + ,556 + ,548 + ,540 + ,531 + ,521 + ,519 + ,572 + ,581 + ,563 + ,548 + ,411 + ,410 + ,415 + ,414 + ,411 + ,408 + ,410 + ,411 + ,416 + ,479 + ,498 + ,502 + ,498 + ,499 + ,506 + ,510 + ,509 + ,502 + ,495 + ,490 + ,490 + ,553 + ,570 + ,573 + ,572 + ,575 + ,580 + ,580 + ,574 + ,563 + ,556 + ,546 + ,545 + ,605 + ,628 + ,631 + ,626 + ,614 + ,606 + ,602 + ,589 + ,574 + ,558 + ,552 + ,546 + ,607 + ,636 + ,631 + ,623 + ,618 + ,605 + ,619 + ,596 + ,570 + ,546 + ,528 + ,506 + ,555 + ,568 + ,564 + ,553 + ,541 + ,542 + ,540 + ,521 + ,505 + ,491 + ,482 + ,478 + ,523 + ,531 + ,532 + ,540 + ,525 + ,533 + ,531 + ,508 + ,495 + ,482 + ,470 + ,466 + ,515 + ,518 + ,516 + ,511 + ,500 + ,498 + ,494 + ,476 + ,458 + ,443 + ,430 + ,424 + ,476 + ,481 + ,470 + ,460 + ,451 + ,450 + ,444 + ,429 + ,421 + ,400 + ,389 + ,384 + ,432 + ,446 + ,431 + ,423 + ,416 + ,416 + ,413 + ,399 + ,386 + ,374 + ,365 + ,365 + ,418 + ,428 + ,424 + ,421 + ,417 + ,423 + ,423 + ,419 + ,406 + ,398 + ,390 + ,391 + ,444 + ,460 + ,455 + ,456 + ,452 + ,459 + ,461 + ,451 + ,443 + ,439 + ,430 + ,436 + ,488 + ,506 + ,502 + ,501 + ,501 + ,515 + ,521 + ,520 + ,512 + ,509 + ,505 + ,511 + ,570 + ,592 + ,594 + ,586 + ,586 + ,592 + ,594 + ,586 + ,572 + ,563 + ,555 + ,554 + ,601 + ,622 + ,617 + ,606 + ,595 + ,599 + ,600 + ,592 + ,575 + ,567 + ,555 + ,555 + ,608 + ,631 + ,629 + ,624 + ,610 + ,616 + ,621 + ,604 + ,584 + ,574 + ,555 + ,545 + ,599 + ,620 + ,608 + ,590 + ,579 + ,580 + ,579 + ,572 + ,560 + ,551 + ,537 + ,541 + ,588 + ,607 + ,599 + ,578 + ,563 + ,566 + ,561 + ,554 + ,540 + ,526 + ,512 + ,505 + ,554 + ,584 + ,569 + ,540 + ,522 + ,526 + ,527 + ,516 + ,503 + ,489 + ,479 + ,475 + ,524 + ,552 + ,532 + ,511 + ,492 + ,492 + ,493 + ,481 + ,462 + ,457 + ,442 + ,439 + ,488 + ,521 + ,501 + ,485 + ,464 + ,460 + ,467 + ,460 + ,448 + ,443 + ,436 + ,431 + ,484 + ,510 + ,513 + ,503 + ,471 + ,471 + ,476 + ,475 + ,470 + ,461 + ,455 + ,456 + ,517 + ,525 + ,523 + ,519 + ,509 + ,512 + ,519 + ,517 + ,510 + ,509 + ,501 + ,507 + ,569 + ,580 + ,578 + ,565 + ,547 + ,555 + ,562 + ,561 + ,555 + ,544 + ,537 + ,543 + ,594 + ,611 + ,613 + ,611 + ,594 + ,595 + ,591 + ,589 + ,584 + ,573 + ,567 + ,569 + ,621 + ,629 + ,628 + ,612 + ,595 + ,597 + ,593 + ,590 + ,580 + ,574 + ,573 + ,573 + ,620 + ,626 + ,620 + ,588 + ,566 + ,557 + ,561 + ,549 + ,532 + ,526 + ,511 + ,499 + ,555 + ,565 + ,542 + ,527 + ,510 + ,514 + ,517 + ,508 + ,493 + ,490 + ,469 + ,478 + ,528 + ,534 + ,518 + ,506 + ,502 + ,516 + ,528 + ,533 + ,536 + ,537 + ,524 + ,536 + ,587 + ,597 + ,581 + ,564 + ,558 + ,575 + ,580 + ,575 + ,563 + ,552 + ,537 + ,545 + ,601 + ,604 + ,586 + ,564 + ,549 + ,551 + ,556 + ,548 + ,540 + ,531 + ,521 + ,519 + ,572 + ,581 + ,563 + ,548) > par10 = 'FALSE' > par9 = '0' > par8 = '2' > par7 = '1' > par6 = '1' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '1.0' > par1 = '12' > par1 <- as.numeric(par1) #cut off periods > par2 <- as.numeric(par2) #lambda > par3 <- as.numeric(par3) #degree of non-seasonal differencing > par4 <- as.numeric(par4) #degree of seasonal differencing > par5 <- as.numeric(par5) #seasonal period > par6 <- as.numeric(par6) #p > par7 <- as.numeric(par7) #q > par8 <- as.numeric(par8) #P > par9 <- as.numeric(par9) #Q > if (par10 == 'TRUE') par10 <- TRUE > if (par10 == 'FALSE') par10 <- FALSE > if (par2 == 0) x <- log(x) > if (par2 != 0) x <- x^par2 > lx <- length(x) > first <- lx - 2*par1 > nx <- lx - par1 > nx1 <- nx + 1 > fx <- lx - nx > if (fx < 1) { + fx <- par5 + nx1 <- lx + fx - 1 + first <- lx - 2*fx + } > first <- 1 > if (fx < 3) fx <- round(lx/10,0) > (arima.out <- arima(x[1:nx], order=c(par6,par3,par7), seasonal=list(order=c(par8,par4,par9), period=par5), include.mean=par10, method='ML')) Call: arima(x = x[1:nx], order = c(par6, par3, par7), seasonal = list(order = c(par8, par4, par9), period = par5), include.mean = par10, method = "ML") Coefficients: ar1 ma1 sar1 sar2 0.8394 -0.7196 -0.3896 -0.2076 s.e. 0.0617 0.0777 0.0369 0.0362 sigma^2 estimated as 83.16: log likelihood = -2617.95, aic = 5245.91 > (forecast <- predict(arima.out,par1)) $pred Time Series: Start = 735 End = 746 Frequency = 1 [1] 554.8835 567.6342 572.6495 567.9312 557.4440 549.7897 533.4895 542.0736 [9] 595.6233 600.2724 582.8437 563.6549 $se Time Series: Start = 735 End = 746 Frequency = 1 [1] 9.119443 13.691029 17.643419 21.280436 24.702474 27.954678 31.061775 [8] 34.039609 36.899693 39.651216 42.301990 44.858923 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 735 End = 746 Frequency = 1 [1] 537.0094 540.7998 538.0684 526.2215 509.0271 494.9985 472.6085 475.3560 [9] 523.2999 522.5560 499.9318 475.7315 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 735 End = 746 Frequency = 1 [1] 572.7576 594.4686 607.2306 609.6408 605.8608 604.5808 594.3706 608.7913 [9] 667.9467 677.9888 665.7556 651.5784 > if (par2 == 0) { + x <- exp(x) + forecast$pred <- exp(forecast$pred) + lb <- exp(lb) + ub <- exp(ub) + } > if (par2 != 0) { + x <- x^(1/par2) + forecast$pred <- forecast$pred^(1/par2) + lb <- lb^(1/par2) + ub <- ub^(1/par2) + } > if (par2 < 0) { + olb <- lb + lb <- ub + ub <- olb + } > (actandfor <- c(x[1:nx], forecast$pred)) [1] 411.0000 410.0000 415.0000 414.0000 411.0000 408.0000 410.0000 411.0000 [9] 416.0000 479.0000 498.0000 502.0000 498.0000 499.0000 506.0000 510.0000 [17] 509.0000 502.0000 495.0000 490.0000 490.0000 553.0000 570.0000 573.0000 [25] 572.0000 575.0000 580.0000 580.0000 574.0000 563.0000 556.0000 546.0000 [33] 545.0000 605.0000 628.0000 631.0000 626.0000 614.0000 606.0000 602.0000 [41] 589.0000 574.0000 558.0000 552.0000 546.0000 607.0000 636.0000 631.0000 [49] 623.0000 618.0000 605.0000 619.0000 596.0000 570.0000 546.0000 528.0000 [57] 506.0000 555.0000 568.0000 564.0000 553.0000 541.0000 542.0000 540.0000 [65] 521.0000 505.0000 491.0000 482.0000 478.0000 523.0000 531.0000 532.0000 [73] 540.0000 525.0000 533.0000 531.0000 508.0000 495.0000 482.0000 470.0000 [81] 466.0000 515.0000 518.0000 516.0000 511.0000 500.0000 498.0000 494.0000 [89] 476.0000 458.0000 443.0000 430.0000 424.0000 476.0000 481.0000 470.0000 [97] 460.0000 451.0000 450.0000 444.0000 429.0000 421.0000 400.0000 389.0000 [105] 384.0000 432.0000 446.0000 431.0000 423.0000 416.0000 416.0000 413.0000 [113] 399.0000 386.0000 374.0000 365.0000 365.0000 418.0000 428.0000 424.0000 [121] 421.0000 417.0000 423.0000 423.0000 419.0000 406.0000 398.0000 390.0000 [129] 391.0000 444.0000 460.0000 455.0000 456.0000 452.0000 459.0000 461.0000 [137] 451.0000 443.0000 439.0000 430.0000 436.0000 488.0000 506.0000 502.0000 [145] 501.0000 501.0000 515.0000 521.0000 520.0000 512.0000 509.0000 505.0000 [153] 511.0000 570.0000 592.0000 594.0000 586.0000 586.0000 592.0000 594.0000 [161] 586.0000 572.0000 563.0000 555.0000 554.0000 601.0000 622.0000 617.0000 [169] 606.0000 595.0000 599.0000 600.0000 592.0000 575.0000 567.0000 555.0000 [177] 555.0000 608.0000 631.0000 629.0000 624.0000 610.0000 616.0000 621.0000 [185] 604.0000 584.0000 574.0000 555.0000 545.0000 599.0000 620.0000 608.0000 [193] 590.0000 579.0000 580.0000 579.0000 572.0000 560.0000 551.0000 537.0000 [201] 541.0000 588.0000 607.0000 599.0000 578.0000 563.0000 566.0000 561.0000 [209] 554.0000 540.0000 526.0000 512.0000 505.0000 554.0000 584.0000 569.0000 [217] 540.0000 522.0000 526.0000 527.0000 516.0000 503.0000 489.0000 479.0000 [225] 475.0000 524.0000 552.0000 532.0000 511.0000 492.0000 492.0000 493.0000 [233] 481.0000 462.0000 457.0000 442.0000 439.0000 488.0000 521.0000 501.0000 [241] 485.0000 464.0000 460.0000 467.0000 460.0000 448.0000 443.0000 436.0000 [249] 431.0000 484.0000 510.0000 513.0000 503.0000 471.0000 471.0000 476.0000 [257] 475.0000 470.0000 461.0000 455.0000 456.0000 517.0000 525.0000 523.0000 [265] 519.0000 509.0000 512.0000 519.0000 517.0000 510.0000 509.0000 501.0000 [273] 507.0000 569.0000 580.0000 578.0000 565.0000 547.0000 555.0000 562.0000 [281] 561.0000 555.0000 544.0000 537.0000 543.0000 594.0000 611.0000 613.0000 [289] 611.0000 594.0000 595.0000 591.0000 589.0000 584.0000 573.0000 567.0000 [297] 569.0000 621.0000 629.0000 628.0000 612.0000 595.0000 597.0000 593.0000 [305] 590.0000 580.0000 574.0000 573.0000 573.0000 620.0000 626.0000 620.0000 [313] 588.0000 566.0000 557.0000 561.0000 549.0000 532.0000 526.0000 511.0000 [321] 499.0000 555.0000 565.0000 542.0000 527.0000 510.0000 514.0000 517.0000 [329] 508.0000 493.0000 490.0000 469.0000 478.0000 528.0000 534.0000 518.0000 [337] 506.0000 502.0000 516.0000 528.0000 533.0000 536.0000 537.0000 524.0000 [345] 536.0000 587.0000 597.0000 581.0000 564.0000 558.0000 575.0000 580.0000 [353] 575.0000 563.0000 552.0000 537.0000 545.0000 601.0000 604.0000 586.0000 [361] 564.0000 549.0000 551.0000 556.0000 548.0000 540.0000 531.0000 521.0000 [369] 519.0000 572.0000 581.0000 563.0000 548.0000 411.0000 410.0000 415.0000 [377] 414.0000 411.0000 408.0000 410.0000 411.0000 416.0000 479.0000 498.0000 [385] 502.0000 498.0000 499.0000 506.0000 510.0000 509.0000 502.0000 495.0000 [393] 490.0000 490.0000 553.0000 570.0000 573.0000 572.0000 575.0000 580.0000 [401] 580.0000 574.0000 563.0000 556.0000 546.0000 545.0000 605.0000 628.0000 [409] 631.0000 626.0000 614.0000 606.0000 602.0000 589.0000 574.0000 558.0000 [417] 552.0000 546.0000 607.0000 636.0000 631.0000 623.0000 618.0000 605.0000 [425] 619.0000 596.0000 570.0000 546.0000 528.0000 506.0000 555.0000 568.0000 [433] 564.0000 553.0000 541.0000 542.0000 540.0000 521.0000 505.0000 491.0000 [441] 482.0000 478.0000 523.0000 531.0000 532.0000 540.0000 525.0000 533.0000 [449] 531.0000 508.0000 495.0000 482.0000 470.0000 466.0000 515.0000 518.0000 [457] 516.0000 511.0000 500.0000 498.0000 494.0000 476.0000 458.0000 443.0000 [465] 430.0000 424.0000 476.0000 481.0000 470.0000 460.0000 451.0000 450.0000 [473] 444.0000 429.0000 421.0000 400.0000 389.0000 384.0000 432.0000 446.0000 [481] 431.0000 423.0000 416.0000 416.0000 413.0000 399.0000 386.0000 374.0000 [489] 365.0000 365.0000 418.0000 428.0000 424.0000 421.0000 417.0000 423.0000 [497] 423.0000 419.0000 406.0000 398.0000 390.0000 391.0000 444.0000 460.0000 [505] 455.0000 456.0000 452.0000 459.0000 461.0000 451.0000 443.0000 439.0000 [513] 430.0000 436.0000 488.0000 506.0000 502.0000 501.0000 501.0000 515.0000 [521] 521.0000 520.0000 512.0000 509.0000 505.0000 511.0000 570.0000 592.0000 [529] 594.0000 586.0000 586.0000 592.0000 594.0000 586.0000 572.0000 563.0000 [537] 555.0000 554.0000 601.0000 622.0000 617.0000 606.0000 595.0000 599.0000 [545] 600.0000 592.0000 575.0000 567.0000 555.0000 555.0000 608.0000 631.0000 [553] 629.0000 624.0000 610.0000 616.0000 621.0000 604.0000 584.0000 574.0000 [561] 555.0000 545.0000 599.0000 620.0000 608.0000 590.0000 579.0000 580.0000 [569] 579.0000 572.0000 560.0000 551.0000 537.0000 541.0000 588.0000 607.0000 [577] 599.0000 578.0000 563.0000 566.0000 561.0000 554.0000 540.0000 526.0000 [585] 512.0000 505.0000 554.0000 584.0000 569.0000 540.0000 522.0000 526.0000 [593] 527.0000 516.0000 503.0000 489.0000 479.0000 475.0000 524.0000 552.0000 [601] 532.0000 511.0000 492.0000 492.0000 493.0000 481.0000 462.0000 457.0000 [609] 442.0000 439.0000 488.0000 521.0000 501.0000 485.0000 464.0000 460.0000 [617] 467.0000 460.0000 448.0000 443.0000 436.0000 431.0000 484.0000 510.0000 [625] 513.0000 503.0000 471.0000 471.0000 476.0000 475.0000 470.0000 461.0000 [633] 455.0000 456.0000 517.0000 525.0000 523.0000 519.0000 509.0000 512.0000 [641] 519.0000 517.0000 510.0000 509.0000 501.0000 507.0000 569.0000 580.0000 [649] 578.0000 565.0000 547.0000 555.0000 562.0000 561.0000 555.0000 544.0000 [657] 537.0000 543.0000 594.0000 611.0000 613.0000 611.0000 594.0000 595.0000 [665] 591.0000 589.0000 584.0000 573.0000 567.0000 569.0000 621.0000 629.0000 [673] 628.0000 612.0000 595.0000 597.0000 593.0000 590.0000 580.0000 574.0000 [681] 573.0000 573.0000 620.0000 626.0000 620.0000 588.0000 566.0000 557.0000 [689] 561.0000 549.0000 532.0000 526.0000 511.0000 499.0000 555.0000 565.0000 [697] 542.0000 527.0000 510.0000 514.0000 517.0000 508.0000 493.0000 490.0000 [705] 469.0000 478.0000 528.0000 534.0000 518.0000 506.0000 502.0000 516.0000 [713] 528.0000 533.0000 536.0000 537.0000 524.0000 536.0000 587.0000 597.0000 [721] 581.0000 564.0000 558.0000 575.0000 580.0000 575.0000 563.0000 552.0000 [729] 537.0000 545.0000 601.0000 604.0000 586.0000 564.0000 554.8835 567.6342 [737] 572.6495 567.9312 557.4440 549.7897 533.4895 542.0736 595.6233 600.2724 [745] 582.8437 563.6549 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 735 End = 746 Frequency = 1 [1] 0.01643488 0.02411946 0.03081015 0.03747010 0.04431382 0.05084613 [7] 0.05822378 0.06279517 0.06195139 0.06605537 0.07257862 0.07958579 > postscript(file="/var/www/rcomp/tmp/1c2vv1323208769.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mar=c(4,4,2,2),las=1) > ylim <- c( min(x[first:nx],lb), max(x[first:nx],ub)) > plot(x,ylim=ylim,type='n',xlim=c(first,lx)) > usr <- par('usr') > rect(usr[1],usr[3],nx+1,usr[4],border=NA,col='lemonchiffon') > rect(nx1,usr[3],usr[2],usr[4],border=NA,col='lavender') > abline(h= (-3:3)*2 , col ='gray', lty =3) > polygon( c(nx1:lx,lx:nx1), c(lb,rev(ub)), col = 'orange', lty=2,border=NA) > lines(nx1:lx, lb , lty=2) > lines(nx1:lx, ub , lty=2) > lines(x, lwd=2) > lines(nx1:lx, forecast$pred , lwd=2 , col ='white') > box() > par(opar) > dev.off() null device 1 > prob.dec <- array(NA, dim=fx) > prob.sdec <- array(NA, dim=fx) > prob.ldec <- array(NA, dim=fx) > prob.pval <- array(NA, dim=fx) > perf.pe <- array(0, dim=fx) > perf.mape <- array(0, dim=fx) > perf.mape1 <- array(0, dim=fx) > perf.se <- array(0, dim=fx) > perf.mse <- array(0, dim=fx) > perf.mse1 <- array(0, dim=fx) > perf.rmse <- array(0, dim=fx) > for (i in 1:fx) { + locSD <- (ub[i] - forecast$pred[i]) / 1.96 + perf.pe[i] = (x[nx+i] - forecast$pred[i]) / forecast$pred[i] + perf.se[i] = (x[nx+i] - forecast$pred[i])^2 + prob.dec[i] = pnorm((x[nx+i-1] - forecast$pred[i]) / locSD) + prob.sdec[i] = pnorm((x[nx+i-par5] - forecast$pred[i]) / locSD) + prob.ldec[i] = pnorm((x[nx] - forecast$pred[i]) / locSD) + prob.pval[i] = pnorm(abs(x[nx+i] - forecast$pred[i]) / locSD) + } > perf.mape[1] = abs(perf.pe[1]) > perf.mse[1] = abs(perf.se[1]) > for (i in 2:fx) { + perf.mape[i] = perf.mape[i-1] + abs(perf.pe[i]) + perf.mape1[i] = perf.mape[i] / i + perf.mse[i] = perf.mse[i-1] + perf.se[i] + perf.mse1[i] = perf.mse[i] / i + } > perf.rmse = sqrt(perf.mse1) > postscript(file="/var/www/rcomp/tmp/2obk11323208769.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(forecast$pred, pch=19, type='b',main='ARIMA Extrapolation Forecast', ylab='Forecast and 95% CI', xlab='time',ylim=c(min(lb),max(ub))) > dum <- forecast$pred > dum[1:par1] <- x[(nx+1):lx] > lines(dum, lty=1) > lines(ub,lty=3) > lines(lb,lty=3) > dev.off() null device 1 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Univariate ARIMA Extrapolation Forecast',9,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'time',1,header=TRUE) > a<-table.element(a,'Y[t]',1,header=TRUE) > a<-table.element(a,'F[t]',1,header=TRUE) > a<-table.element(a,'95% LB',1,header=TRUE) > a<-table.element(a,'95% UB',1,header=TRUE) > a<-table.element(a,'p-value
(H0: Y[t] = F[t])',1,header=TRUE) > a<-table.element(a,'P(F[t]>Y[t-1])',1,header=TRUE) > a<-table.element(a,'P(F[t]>Y[t-s])',1,header=TRUE) > mylab <- paste('P(F[t]>Y[',nx,sep='') > mylab <- paste(mylab,'])',sep='') > a<-table.element(a,mylab,1,header=TRUE) > a<-table.row.end(a) > for (i in (nx-par5):nx) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.row.end(a) + } > for (i in 1:fx) { + a<-table.row.start(a) + a<-table.element(a,nx+i,header=TRUE) + a<-table.element(a,round(x[nx+i],4)) + a<-table.element(a,round(forecast$pred[i],4)) + a<-table.element(a,round(lb[i],4)) + a<-table.element(a,round(ub[i],4)) + a<-table.element(a,round((1-prob.pval[i]),4)) + a<-table.element(a,round((1-prob.dec[i]),4)) + a<-table.element(a,round((1-prob.sdec[i]),4)) + a<-table.element(a,round((1-prob.ldec[i]),4)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/35ajo1323208769.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Univariate ARIMA Extrapolation Forecast Performance',7,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'time',1,header=TRUE) > a<-table.element(a,'% S.E.',1,header=TRUE) > a<-table.element(a,'PE',1,header=TRUE) > a<-table.element(a,'MAPE',1,header=TRUE) > a<-table.element(a,'Sq.E',1,header=TRUE) > a<-table.element(a,'MSE',1,header=TRUE) > a<-table.element(a,'RMSE',1,header=TRUE) > a<-table.row.end(a) > for (i in 1:fx) { + a<-table.row.start(a) + a<-table.element(a,nx+i,header=TRUE) + a<-table.element(a,round(perc.se[i],4)) + a<-table.element(a,round(perf.pe[i],4)) + a<-table.element(a,round(perf.mape1[i],4)) + a<-table.element(a,round(perf.se[i],4)) + a<-table.element(a,round(perf.mse1[i],4)) + a<-table.element(a,round(perf.rmse[i],4)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/rcomp/tmp/4xwym1323208769.tab") > > try(system("convert tmp/1c2vv1323208769.ps tmp/1c2vv1323208769.png",intern=TRUE)) character(0) > try(system("convert tmp/2obk11323208769.ps tmp/2obk11323208769.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 9.056 0.440 11.832