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(8587,0,9743,9731,0,8587,9563,0,9731,9998,0,9563,9437,0,9998,10038,0,9437,9918,0,10038,9252,0,9918,9737,0,9252,9035,0,9737,9133,0,9035,9487,0,9133,8700,0,9487,9627,0,8700,8947,0,9627,9283,0,8947,8829,0,9283,9947,0,8829,9628,0,9947,9318,0,9628,9605,0,9318,8640,0,9605,9214,0,8640,9567,0,9214,8547,0,9567,9185,0,8547,9470,0,9185,9123,0,9470,9278,0,9123,10170,0,9278,9434,0,10170,9655,0,9434,9429,0,9655,8739,0,9429,9552,0,8739,9687,1,9552,9019,1,9687,9672,1,9019,9206,1,9672,9069,1,9206,9788,1,9069,10312,1,9788,10105,1,10312,9863,1,10105,9656,1,9863,9295,1,9656,9946,1,9295,9701,1,9946,9049,1,9701,10190,1,9049,9706,1,10190,9765,1,9706,9893,1,9765,9994,1,9893,10433,1,9994,10073,1,10433,10112,1,10073,9266,1,10112,9820,1,9266,10097,1,9820,9115,1,10097,10411,1,9115,9678,1,10411,10408,1,9678,10153,1,10408,10368,1,10153,10581,1,10368,10597,1,10581,10680,1,10597,9738,1,10680,9556,1,9738),dim=c(3,71),dimnames=list(c('births','difference','Y1'),1:71))
> y <- array(NA,dim=c(3,71),dimnames=list(c('births','difference','Y1'),1:71))
> 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
births difference Y1 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 8587 0 9743 1 0 0 0 0 0 0 0 0 0 0 1
2 9731 0 8587 0 1 0 0 0 0 0 0 0 0 0 2
3 9563 0 9731 0 0 1 0 0 0 0 0 0 0 0 3
4 9998 0 9563 0 0 0 1 0 0 0 0 0 0 0 4
5 9437 0 9998 0 0 0 0 1 0 0 0 0 0 0 5
6 10038 0 9437 0 0 0 0 0 1 0 0 0 0 0 6
7 9918 0 10038 0 0 0 0 0 0 1 0 0 0 0 7
8 9252 0 9918 0 0 0 0 0 0 0 1 0 0 0 8
9 9737 0 9252 0 0 0 0 0 0 0 0 1 0 0 9
10 9035 0 9737 0 0 0 0 0 0 0 0 0 1 0 10
11 9133 0 9035 0 0 0 0 0 0 0 0 0 0 1 11
12 9487 0 9133 0 0 0 0 0 0 0 0 0 0 0 12
13 8700 0 9487 1 0 0 0 0 0 0 0 0 0 0 13
14 9627 0 8700 0 1 0 0 0 0 0 0 0 0 0 14
15 8947 0 9627 0 0 1 0 0 0 0 0 0 0 0 15
16 9283 0 8947 0 0 0 1 0 0 0 0 0 0 0 16
17 8829 0 9283 0 0 0 0 1 0 0 0 0 0 0 17
18 9947 0 8829 0 0 0 0 0 1 0 0 0 0 0 18
19 9628 0 9947 0 0 0 0 0 0 1 0 0 0 0 19
20 9318 0 9628 0 0 0 0 0 0 0 1 0 0 0 20
21 9605 0 9318 0 0 0 0 0 0 0 0 1 0 0 21
22 8640 0 9605 0 0 0 0 0 0 0 0 0 1 0 22
23 9214 0 8640 0 0 0 0 0 0 0 0 0 0 1 23
24 9567 0 9214 0 0 0 0 0 0 0 0 0 0 0 24
25 8547 0 9567 1 0 0 0 0 0 0 0 0 0 0 25
26 9185 0 8547 0 1 0 0 0 0 0 0 0 0 0 26
27 9470 0 9185 0 0 1 0 0 0 0 0 0 0 0 27
28 9123 0 9470 0 0 0 1 0 0 0 0 0 0 0 28
29 9278 0 9123 0 0 0 0 1 0 0 0 0 0 0 29
30 10170 0 9278 0 0 0 0 0 1 0 0 0 0 0 30
31 9434 0 10170 0 0 0 0 0 0 1 0 0 0 0 31
32 9655 0 9434 0 0 0 0 0 0 0 1 0 0 0 32
33 9429 0 9655 0 0 0 0 0 0 0 0 1 0 0 33
34 8739 0 9429 0 0 0 0 0 0 0 0 0 1 0 34
35 9552 0 8739 0 0 0 0 0 0 0 0 0 0 1 35
36 9687 1 9552 0 0 0 0 0 0 0 0 0 0 0 36
37 9019 1 9687 1 0 0 0 0 0 0 0 0 0 0 37
38 9672 1 9019 0 1 0 0 0 0 0 0 0 0 0 38
39 9206 1 9672 0 0 1 0 0 0 0 0 0 0 0 39
40 9069 1 9206 0 0 0 1 0 0 0 0 0 0 0 40
41 9788 1 9069 0 0 0 0 1 0 0 0 0 0 0 41
42 10312 1 9788 0 0 0 0 0 1 0 0 0 0 0 42
43 10105 1 10312 0 0 0 0 0 0 1 0 0 0 0 43
44 9863 1 10105 0 0 0 0 0 0 0 1 0 0 0 44
45 9656 1 9863 0 0 0 0 0 0 0 0 1 0 0 45
46 9295 1 9656 0 0 0 0 0 0 0 0 0 1 0 46
47 9946 1 9295 0 0 0 0 0 0 0 0 0 0 1 47
48 9701 1 9946 0 0 0 0 0 0 0 0 0 0 0 48
49 9049 1 9701 1 0 0 0 0 0 0 0 0 0 0 49
50 10190 1 9049 0 1 0 0 0 0 0 0 0 0 0 50
51 9706 1 10190 0 0 1 0 0 0 0 0 0 0 0 51
52 9765 1 9706 0 0 0 1 0 0 0 0 0 0 0 52
53 9893 1 9765 0 0 0 0 1 0 0 0 0 0 0 53
54 9994 1 9893 0 0 0 0 0 1 0 0 0 0 0 54
55 10433 1 9994 0 0 0 0 0 0 1 0 0 0 0 55
56 10073 1 10433 0 0 0 0 0 0 0 1 0 0 0 56
57 10112 1 10073 0 0 0 0 0 0 0 0 1 0 0 57
58 9266 1 10112 0 0 0 0 0 0 0 0 0 1 0 58
59 9820 1 9266 0 0 0 0 0 0 0 0 0 0 1 59
60 10097 1 9820 0 0 0 0 0 0 0 0 0 0 0 60
61 9115 1 10097 1 0 0 0 0 0 0 0 0 0 0 61
62 10411 1 9115 0 1 0 0 0 0 0 0 0 0 0 62
63 9678 1 10411 0 0 1 0 0 0 0 0 0 0 0 63
64 10408 1 9678 0 0 0 1 0 0 0 0 0 0 0 64
65 10153 1 10408 0 0 0 0 1 0 0 0 0 0 0 65
66 10368 1 10153 0 0 0 0 0 1 0 0 0 0 0 66
67 10581 1 10368 0 0 0 0 0 0 1 0 0 0 0 67
68 10597 1 10581 0 0 0 0 0 0 0 1 0 0 0 68
69 10680 1 10597 0 0 0 0 0 0 0 0 1 0 0 69
70 9738 1 10680 0 0 0 0 0 0 0 0 0 1 0 70
71 9556 1 9738 0 0 0 0 0 0 0 0 0 0 1 71
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) difference Y1 M1 M2 M3
6947.2063 173.2363 0.2582 -873.7732 313.8217 -315.4528
M4 M5 M6 M7 M8 M9
-44.9191 -141.3166 439.9457 164.3621 -33.1644 95.9311
M10 M11 t
-680.3390 -73.9005 5.4353
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-600.500 -155.875 -3.481 179.535 605.244
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6947.2063 1183.3254 5.871 2.46e-07 ***
difference 173.2363 141.0730 1.228 0.224587
Y1 0.2582 0.1287 2.007 0.049627 *
M1 -873.7732 171.4620 -5.096 4.24e-06 ***
M2 313.8217 187.8700 1.670 0.100417
M3 -315.4528 173.3992 -1.819 0.074224 .
M4 -44.9191 168.8826 -0.266 0.791233
M5 -141.3166 169.3569 -0.834 0.407584
M6 439.9457 169.1594 2.601 0.011875 *
M7 164.3621 187.2714 0.878 0.383874
M8 -33.1644 181.1332 -0.183 0.855386
M9 95.9311 173.3804 0.553 0.582261
M10 -680.3390 175.8162 -3.870 0.000287 ***
M11 -73.9005 179.5939 -0.411 0.682286
t 5.4353 3.5087 1.549 0.127000
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 278.2 on 56 degrees of freedom
Multiple R-squared: 0.7611, Adjusted R-squared: 0.7014
F-statistic: 12.75 on 14 and 56 DF, p-value: 1.083e-12
> 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.7839113 0.4321773 0.2160887
[2,] 0.6534443 0.6931115 0.3465557
[3,] 0.6328348 0.7343303 0.3671652
[4,] 0.5115193 0.9769614 0.4884807
[5,] 0.4135392 0.8270784 0.5864608
[6,] 0.4235346 0.8470692 0.5764654
[7,] 0.3597667 0.7195333 0.6402333
[8,] 0.2713480 0.5426959 0.7286520
[9,] 0.2764624 0.5529247 0.7235376
[10,] 0.4793082 0.9586164 0.5206918
[11,] 0.4563964 0.9127927 0.5436036
[12,] 0.4731608 0.9463216 0.5268392
[13,] 0.5671614 0.8656773 0.4328386
[14,] 0.5321269 0.9357462 0.4678731
[15,] 0.6028580 0.7942840 0.3971420
[16,] 0.5357905 0.9284190 0.4642095
[17,] 0.4994361 0.9988723 0.5005639
[18,] 0.5356969 0.9286062 0.4643031
[19,] 0.4560957 0.9121914 0.5439043
[20,] 0.4307194 0.8614389 0.5692806
[21,] 0.3726583 0.7453167 0.6273417
[22,] 0.3357037 0.6714075 0.6642963
[23,] 0.5886592 0.8226817 0.4113408
[24,] 0.5949876 0.8100249 0.4050124
[25,] 0.6506872 0.6986255 0.3493128
[26,] 0.5830508 0.8338985 0.4169492
[27,] 0.5164386 0.9671228 0.4835614
[28,] 0.5605997 0.8788007 0.4394003
[29,] 0.4802488 0.9604975 0.5197512
[30,] 0.7799954 0.4400093 0.2200046
[31,] 0.6836039 0.6327923 0.3163961
[32,] 0.6116551 0.7766899 0.3883449
[33,] 0.5553359 0.8893282 0.4446641
[34,] 0.5844929 0.8310141 0.4155071
[35,] 0.4603450 0.9206899 0.5396550
[36,] 0.3153175 0.6306351 0.6846825
> postscript(file="/var/www/html/rcomp/tmp/1vym11291923627.ps",horizontal=F,onefile=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/2vym11291923627.ps",horizontal=F,onefile=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/36q441291923627.ps",horizontal=F,onefile=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/46q441291923627.ps",horizontal=F,onefile=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/56q441291923627.ps",horizontal=F,onefile=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 = 71
Frequency = 1
1 2 3 4 5 6
-7.063278 242.332625 402.843614 605.244495 22.909776 182.036651
7 8 9 10 11 12
177.034338 -265.895919 256.503916 200.134037 -132.515512 116.849603
13 14 15 16 17 18
106.801052 43.938111 -251.531471 -15.955716 -465.733184 182.771208
19 20 21 22 23 24
-154.696750 -190.254350 42.242642 -226.012735 -14.767768 110.716018
25 26 27 28 29 30
-132.074378 -423.787426 320.349514 -376.193391 -40.651642 224.636932
31 32 33 34 35 36
-471.488210 131.604429 -285.978380 -146.800728 232.451875 -94.999440
37 38 39 40 41 42
70.487747 -297.095527 -307.830898 -600.500110 244.829288 -3.481023
43 44 45 46 47 48
-75.605474 -72.076328 -351.133811 112.138914 244.458834 -247.935243
49 50 51 52 53 54
31.650484 147.936745 -6.777803 -98.800242 104.930962 -413.810304
55 56 57 58 59 60
269.264408 -11.973963 -14.569269 -99.802440 60.722195 115.369062
61 62 63 64 65 66
-69.801627 286.675472 -157.052955 486.204965 133.714800 -172.153464
67 68 69 70 71
255.491687 408.596131 352.934902 160.342952 -390.349624
> postscript(file="/var/www/html/rcomp/tmp/6yz371291923627.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 71
Frequency = 1
lag(myerror, k = 1) myerror
0 -7.063278 NA
1 242.332625 -7.063278
2 402.843614 242.332625
3 605.244495 402.843614
4 22.909776 605.244495
5 182.036651 22.909776
6 177.034338 182.036651
7 -265.895919 177.034338
8 256.503916 -265.895919
9 200.134037 256.503916
10 -132.515512 200.134037
11 116.849603 -132.515512
12 106.801052 116.849603
13 43.938111 106.801052
14 -251.531471 43.938111
15 -15.955716 -251.531471
16 -465.733184 -15.955716
17 182.771208 -465.733184
18 -154.696750 182.771208
19 -190.254350 -154.696750
20 42.242642 -190.254350
21 -226.012735 42.242642
22 -14.767768 -226.012735
23 110.716018 -14.767768
24 -132.074378 110.716018
25 -423.787426 -132.074378
26 320.349514 -423.787426
27 -376.193391 320.349514
28 -40.651642 -376.193391
29 224.636932 -40.651642
30 -471.488210 224.636932
31 131.604429 -471.488210
32 -285.978380 131.604429
33 -146.800728 -285.978380
34 232.451875 -146.800728
35 -94.999440 232.451875
36 70.487747 -94.999440
37 -297.095527 70.487747
38 -307.830898 -297.095527
39 -600.500110 -307.830898
40 244.829288 -600.500110
41 -3.481023 244.829288
42 -75.605474 -3.481023
43 -72.076328 -75.605474
44 -351.133811 -72.076328
45 112.138914 -351.133811
46 244.458834 112.138914
47 -247.935243 244.458834
48 31.650484 -247.935243
49 147.936745 31.650484
50 -6.777803 147.936745
51 -98.800242 -6.777803
52 104.930962 -98.800242
53 -413.810304 104.930962
54 269.264408 -413.810304
55 -11.973963 269.264408
56 -14.569269 -11.973963
57 -99.802440 -14.569269
58 60.722195 -99.802440
59 115.369062 60.722195
60 -69.801627 115.369062
61 286.675472 -69.801627
62 -157.052955 286.675472
63 486.204965 -157.052955
64 133.714800 486.204965
65 -172.153464 133.714800
66 255.491687 -172.153464
67 408.596131 255.491687
68 352.934902 408.596131
69 160.342952 352.934902
70 -390.349624 160.342952
71 NA -390.349624
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 242.332625 -7.063278
[2,] 402.843614 242.332625
[3,] 605.244495 402.843614
[4,] 22.909776 605.244495
[5,] 182.036651 22.909776
[6,] 177.034338 182.036651
[7,] -265.895919 177.034338
[8,] 256.503916 -265.895919
[9,] 200.134037 256.503916
[10,] -132.515512 200.134037
[11,] 116.849603 -132.515512
[12,] 106.801052 116.849603
[13,] 43.938111 106.801052
[14,] -251.531471 43.938111
[15,] -15.955716 -251.531471
[16,] -465.733184 -15.955716
[17,] 182.771208 -465.733184
[18,] -154.696750 182.771208
[19,] -190.254350 -154.696750
[20,] 42.242642 -190.254350
[21,] -226.012735 42.242642
[22,] -14.767768 -226.012735
[23,] 110.716018 -14.767768
[24,] -132.074378 110.716018
[25,] -423.787426 -132.074378
[26,] 320.349514 -423.787426
[27,] -376.193391 320.349514
[28,] -40.651642 -376.193391
[29,] 224.636932 -40.651642
[30,] -471.488210 224.636932
[31,] 131.604429 -471.488210
[32,] -285.978380 131.604429
[33,] -146.800728 -285.978380
[34,] 232.451875 -146.800728
[35,] -94.999440 232.451875
[36,] 70.487747 -94.999440
[37,] -297.095527 70.487747
[38,] -307.830898 -297.095527
[39,] -600.500110 -307.830898
[40,] 244.829288 -600.500110
[41,] -3.481023 244.829288
[42,] -75.605474 -3.481023
[43,] -72.076328 -75.605474
[44,] -351.133811 -72.076328
[45,] 112.138914 -351.133811
[46,] 244.458834 112.138914
[47,] -247.935243 244.458834
[48,] 31.650484 -247.935243
[49,] 147.936745 31.650484
[50,] -6.777803 147.936745
[51,] -98.800242 -6.777803
[52,] 104.930962 -98.800242
[53,] -413.810304 104.930962
[54,] 269.264408 -413.810304
[55,] -11.973963 269.264408
[56,] -14.569269 -11.973963
[57,] -99.802440 -14.569269
[58,] 60.722195 -99.802440
[59,] 115.369062 60.722195
[60,] -69.801627 115.369062
[61,] 286.675472 -69.801627
[62,] -157.052955 286.675472
[63,] 486.204965 -157.052955
[64,] 133.714800 486.204965
[65,] -172.153464 133.714800
[66,] 255.491687 -172.153464
[67,] 408.596131 255.491687
[68,] 352.934902 408.596131
[69,] 160.342952 352.934902
[70,] -390.349624 160.342952
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 242.332625 -7.063278
2 402.843614 242.332625
3 605.244495 402.843614
4 22.909776 605.244495
5 182.036651 22.909776
6 177.034338 182.036651
7 -265.895919 177.034338
8 256.503916 -265.895919
9 200.134037 256.503916
10 -132.515512 200.134037
11 116.849603 -132.515512
12 106.801052 116.849603
13 43.938111 106.801052
14 -251.531471 43.938111
15 -15.955716 -251.531471
16 -465.733184 -15.955716
17 182.771208 -465.733184
18 -154.696750 182.771208
19 -190.254350 -154.696750
20 42.242642 -190.254350
21 -226.012735 42.242642
22 -14.767768 -226.012735
23 110.716018 -14.767768
24 -132.074378 110.716018
25 -423.787426 -132.074378
26 320.349514 -423.787426
27 -376.193391 320.349514
28 -40.651642 -376.193391
29 224.636932 -40.651642
30 -471.488210 224.636932
31 131.604429 -471.488210
32 -285.978380 131.604429
33 -146.800728 -285.978380
34 232.451875 -146.800728
35 -94.999440 232.451875
36 70.487747 -94.999440
37 -297.095527 70.487747
38 -307.830898 -297.095527
39 -600.500110 -307.830898
40 244.829288 -600.500110
41 -3.481023 244.829288
42 -75.605474 -3.481023
43 -72.076328 -75.605474
44 -351.133811 -72.076328
45 112.138914 -351.133811
46 244.458834 112.138914
47 -247.935243 244.458834
48 31.650484 -247.935243
49 147.936745 31.650484
50 -6.777803 147.936745
51 -98.800242 -6.777803
52 104.930962 -98.800242
53 -413.810304 104.930962
54 269.264408 -413.810304
55 -11.973963 269.264408
56 -14.569269 -11.973963
57 -99.802440 -14.569269
58 60.722195 -99.802440
59 115.369062 60.722195
60 -69.801627 115.369062
61 286.675472 -69.801627
62 -157.052955 286.675472
63 486.204965 -157.052955
64 133.714800 486.204965
65 -172.153464 133.714800
66 255.491687 -172.153464
67 408.596131 255.491687
68 352.934902 408.596131
69 160.342952 352.934902
70 -390.349624 160.342952
> 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/7r82a1291923627.ps",horizontal=F,onefile=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/8r82a1291923627.ps",horizontal=F,onefile=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/9r82a1291923627.ps",horizontal=F,onefile=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/10kz1v1291923627.ps",horizontal=F,onefile=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/11n0011291923627.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/12rigp1291923627.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/13qtyd1291923628.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/141lxy1291923628.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/154lem1291923628.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/16idbd1291923628.tab")
+ }
>
> try(system("convert tmp/1vym11291923627.ps tmp/1vym11291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/2vym11291923627.ps tmp/2vym11291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/36q441291923627.ps tmp/36q441291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/46q441291923627.ps tmp/46q441291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/56q441291923627.ps tmp/56q441291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/6yz371291923627.ps tmp/6yz371291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/7r82a1291923627.ps tmp/7r82a1291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/8r82a1291923627.ps tmp/8r82a1291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/9r82a1291923627.ps tmp/9r82a1291923627.png",intern=TRUE))
character(0)
> try(system("convert tmp/10kz1v1291923627.ps tmp/10kz1v1291923627.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.640 1.804 10.456