R version 2.8.0 (2008-10-20)
Copyright (C) 2008 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.
Natural language support but running in an English locale
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(37,0,30,0,47,0,35,0,30,0,43,0,82,0,40,0,47,0,19,0,52,0,136,0,80,0,42,0,54,0,66,0,81,0,63,0,137,0,72,0,107,0,58,0,36,0,52,0,79,0,77,0,54,0,84,0,48,0,96,0,83,0,66,0,61,0,53,0,30,0,74,0,69,0,59,0,42,0,65,0,70,0,100,0,63,0,105,0,82,0,81,0,75,0,102,0,121,1,98,1,76,1,77,1,63,1,37,1,35,1,23,1,40,1,29,1,37,1,51,1,20,1,28,1,13,1,22,1,25,1,13,1,16,1,13,1,16,1,17,1,9,1,17,1,25,1,14,1,8,1,7,1,10,1,7,1,10,1,3,1),dim=c(2,80),dimnames=list(c('y','x'),1:80))
> y <- array(NA,dim=c(2,80),dimnames=list(c('y','x'),1:80))
> 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 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 t
1 37 0 1 0 0 0 0 0 0 0 0 0 0 1
2 30 0 0 1 0 0 0 0 0 0 0 0 0 2
3 47 0 0 0 1 0 0 0 0 0 0 0 0 3
4 35 0 0 0 0 1 0 0 0 0 0 0 0 4
5 30 0 0 0 0 0 1 0 0 0 0 0 0 5
6 43 0 0 0 0 0 0 1 0 0 0 0 0 6
7 82 0 0 0 0 0 0 0 1 0 0 0 0 7
8 40 0 0 0 0 0 0 0 0 1 0 0 0 8
9 47 0 0 0 0 0 0 0 0 0 1 0 0 9
10 19 0 0 0 0 0 0 0 0 0 0 1 0 10
11 52 0 0 0 0 0 0 0 0 0 0 0 1 11
12 136 0 0 0 0 0 0 0 0 0 0 0 0 12
13 80 0 1 0 0 0 0 0 0 0 0 0 0 13
14 42 0 0 1 0 0 0 0 0 0 0 0 0 14
15 54 0 0 0 1 0 0 0 0 0 0 0 0 15
16 66 0 0 0 0 1 0 0 0 0 0 0 0 16
17 81 0 0 0 0 0 1 0 0 0 0 0 0 17
18 63 0 0 0 0 0 0 1 0 0 0 0 0 18
19 137 0 0 0 0 0 0 0 1 0 0 0 0 19
20 72 0 0 0 0 0 0 0 0 1 0 0 0 20
21 107 0 0 0 0 0 0 0 0 0 1 0 0 21
22 58 0 0 0 0 0 0 0 0 0 0 1 0 22
23 36 0 0 0 0 0 0 0 0 0 0 0 1 23
24 52 0 0 0 0 0 0 0 0 0 0 0 0 24
25 79 0 1 0 0 0 0 0 0 0 0 0 0 25
26 77 0 0 1 0 0 0 0 0 0 0 0 0 26
27 54 0 0 0 1 0 0 0 0 0 0 0 0 27
28 84 0 0 0 0 1 0 0 0 0 0 0 0 28
29 48 0 0 0 0 0 1 0 0 0 0 0 0 29
30 96 0 0 0 0 0 0 1 0 0 0 0 0 30
31 83 0 0 0 0 0 0 0 1 0 0 0 0 31
32 66 0 0 0 0 0 0 0 0 1 0 0 0 32
33 61 0 0 0 0 0 0 0 0 0 1 0 0 33
34 53 0 0 0 0 0 0 0 0 0 0 1 0 34
35 30 0 0 0 0 0 0 0 0 0 0 0 1 35
36 74 0 0 0 0 0 0 0 0 0 0 0 0 36
37 69 0 1 0 0 0 0 0 0 0 0 0 0 37
38 59 0 0 1 0 0 0 0 0 0 0 0 0 38
39 42 0 0 0 1 0 0 0 0 0 0 0 0 39
40 65 0 0 0 0 1 0 0 0 0 0 0 0 40
41 70 0 0 0 0 0 1 0 0 0 0 0 0 41
42 100 0 0 0 0 0 0 1 0 0 0 0 0 42
43 63 0 0 0 0 0 0 0 1 0 0 0 0 43
44 105 0 0 0 0 0 0 0 0 1 0 0 0 44
45 82 0 0 0 0 0 0 0 0 0 1 0 0 45
46 81 0 0 0 0 0 0 0 0 0 0 1 0 46
47 75 0 0 0 0 0 0 0 0 0 0 0 1 47
48 102 0 0 0 0 0 0 0 0 0 0 0 0 48
49 121 1 1 0 0 0 0 0 0 0 0 0 0 49
50 98 1 0 1 0 0 0 0 0 0 0 0 0 50
51 76 1 0 0 1 0 0 0 0 0 0 0 0 51
52 77 1 0 0 0 1 0 0 0 0 0 0 0 52
53 63 1 0 0 0 0 1 0 0 0 0 0 0 53
54 37 1 0 0 0 0 0 1 0 0 0 0 0 54
55 35 1 0 0 0 0 0 0 1 0 0 0 0 55
56 23 1 0 0 0 0 0 0 0 1 0 0 0 56
57 40 1 0 0 0 0 0 0 0 0 1 0 0 57
58 29 1 0 0 0 0 0 0 0 0 0 1 0 58
59 37 1 0 0 0 0 0 0 0 0 0 0 1 59
60 51 1 0 0 0 0 0 0 0 0 0 0 0 60
61 20 1 1 0 0 0 0 0 0 0 0 0 0 61
62 28 1 0 1 0 0 0 0 0 0 0 0 0 62
63 13 1 0 0 1 0 0 0 0 0 0 0 0 63
64 22 1 0 0 0 1 0 0 0 0 0 0 0 64
65 25 1 0 0 0 0 1 0 0 0 0 0 0 65
66 13 1 0 0 0 0 0 1 0 0 0 0 0 66
67 16 1 0 0 0 0 0 0 1 0 0 0 0 67
68 13 1 0 0 0 0 0 0 0 1 0 0 0 68
69 16 1 0 0 0 0 0 0 0 0 1 0 0 69
70 17 1 0 0 0 0 0 0 0 0 0 1 0 70
71 9 1 0 0 0 0 0 0 0 0 0 0 1 71
72 17 1 0 0 0 0 0 0 0 0 0 0 0 72
73 25 1 1 0 0 0 0 0 0 0 0 0 0 73
74 14 1 0 1 0 0 0 0 0 0 0 0 0 74
75 8 1 0 0 1 0 0 0 0 0 0 0 0 75
76 7 1 0 0 0 1 0 0 0 0 0 0 0 76
77 10 1 0 0 0 0 1 0 0 0 0 0 0 77
78 7 1 0 0 0 0 0 1 0 0 0 0 0 78
79 10 1 0 0 0 0 0 0 1 0 0 0 0 79
80 3 1 0 0 0 0 0 0 0 1 0 0 0 80
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) x M1 M2 M3 M4
84.78546 -33.98670 -7.36514 -19.18761 -26.86721 -17.97539
M5 M6 M7 M8 M9 M10
-22.08357 -17.47746 -7.87135 -22.69381 -13.27071 -29.23603
M11 t
-32.20135 -0.03468
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-40.386 -16.542 -3.280 9.737 79.266
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 84.78546 13.62522 6.223 3.8e-08 ***
x -33.98670 12.18953 -2.788 0.00692 **
M1 -7.36514 15.51957 -0.475 0.63666
M2 -19.18761 15.48361 -1.239 0.21965
M3 -26.86721 15.45189 -1.739 0.08674 .
M4 -17.97539 15.42443 -1.165 0.24806
M5 -22.08357 15.40127 -1.434 0.15633
M6 -17.47746 15.38242 -1.136 0.25998
M7 -7.87135 15.36790 -0.512 0.61022
M8 -22.69381 15.35772 -1.478 0.14425
M9 -13.27071 15.93645 -0.833 0.40800
M10 -29.23603 15.92596 -1.836 0.07090 .
M11 -32.20135 15.91967 -2.023 0.04715 *
t -0.03468 0.25855 -0.134 0.89371
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 27.57 on 66 degrees of freedom
Multiple R-squared: 0.3767, Adjusted R-squared: 0.2539
F-statistic: 3.068 on 13 and 66 DF, p-value: 0.001359
> 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.25507558 5.101512e-01 7.449244e-01
[2,] 0.14169908 2.833982e-01 8.583009e-01
[3,] 0.15105041 3.021008e-01 8.489496e-01
[4,] 0.07975175 1.595035e-01 9.202483e-01
[5,] 0.08438419 1.687684e-01 9.156158e-01
[6,] 0.04730001 9.460002e-02 9.527000e-01
[7,] 0.16087412 3.217482e-01 8.391259e-01
[8,] 0.88592649 2.281470e-01 1.140735e-01
[9,] 0.84858588 3.028282e-01 1.514141e-01
[10,] 0.80118219 3.976356e-01 1.988178e-01
[11,] 0.78701971 4.259606e-01 2.129803e-01
[12,] 0.71981580 5.603684e-01 2.801842e-01
[13,] 0.76745060 4.650988e-01 2.325494e-01
[14,] 0.71556532 5.688694e-01 2.844347e-01
[15,] 0.76509569 4.698086e-01 2.349043e-01
[16,] 0.71876808 5.624638e-01 2.812319e-01
[17,] 0.72978055 5.404389e-01 2.702195e-01
[18,] 0.70207815 5.958437e-01 2.979218e-01
[19,] 0.79915195 4.016961e-01 2.008480e-01
[20,] 0.82054874 3.589025e-01 1.794513e-01
[21,] 0.82726539 3.454692e-01 1.727346e-01
[22,] 0.85093437 2.981313e-01 1.490656e-01
[23,] 0.91648871 1.670226e-01 8.351129e-02
[24,] 0.92748237 1.450353e-01 7.251763e-02
[25,] 0.93327705 1.334459e-01 6.672295e-02
[26,] 0.91462912 1.707418e-01 8.537088e-02
[27,] 0.95381018 9.237963e-02 4.618982e-02
[28,] 0.95357676 9.284648e-02 4.642324e-02
[29,] 0.93031401 1.393720e-01 6.968599e-02
[30,] 0.90770280 1.845944e-01 9.229720e-02
[31,] 0.88247208 2.350558e-01 1.175279e-01
[32,] 0.83478213 3.304357e-01 1.652179e-01
[33,] 0.96226985 7.546030e-02 3.773015e-02
[34,] 0.98909871 2.180258e-02 1.090129e-02
[35,] 0.99701534 5.969316e-03 2.984658e-03
[36,] 0.99980355 3.928980e-04 1.964490e-04
[37,] 0.99995459 9.082158e-05 4.541079e-05
[38,] 0.99994623 1.075431e-04 5.377156e-05
[39,] 0.99991771 1.645830e-04 8.229150e-05
[40,] 0.99982149 3.570119e-04 1.785060e-04
[41,] 0.99963323 7.335478e-04 3.667739e-04
[42,] 0.99879571 2.408570e-03 1.204285e-03
[43,] 0.99823773 3.524537e-03 1.762269e-03
[44,] 0.99970558 5.888499e-04 2.944250e-04
[45,] 0.99988002 2.399680e-04 1.199840e-04
[46,] 0.99931061 1.378789e-03 6.893947e-04
[47,] 0.99646513 7.069742e-03 3.534871e-03
> postscript(file="/var/www/html/freestat/rcomp/tmp/1egud1291134353.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/freestat/rcomp/tmp/2egud1291134353.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/freestat/rcomp/tmp/3egud1291134353.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/freestat/rcomp/tmp/4oqty1291134353.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/freestat/rcomp/tmp/5oqty1291134353.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 = 80
Frequency = 1
1 2 3 4 5 6
-40.3856383 -35.5284954 -10.8142097 -31.6713526 -32.5284954 -24.0999240
7 8 9 10 11 12
5.3286474 -21.8142097 -24.2026342 -36.2026342 -0.2026342 51.6306991
13 14 15 16 17 18
3.0305218 -23.1123354 -3.3980496 -0.2551925 18.8876646 -3.6837639
19 20 21 22 23 24
60.7448075 10.6019504 36.2135258 3.2135258 -15.7864742 -31.9531408
25 26 27 28 29 30
2.4466819 12.3038247 -2.9818896 18.1609676 -13.6961753 29.7323961
31 32 33 34 35 36
7.1609676 5.0181104 -9.3703141 -1.3703141 -21.3703141 -9.5369807
37 38 39 40 41 42
-7.1371581 -5.2800152 -14.5657295 -0.4228723 8.7199848 34.1485562
43 44 45 46 47 48
-12.4228723 44.4342705 12.0458460 27.0458460 24.0458460 18.8791793
49 50 51 52 53 54
79.2657042 68.1228470 53.8371327 45.9799899 36.1228470 5.5514184
55 56 57 58 59 60
-6.0200101 -3.1628673 4.4487082 9.4487082 20.4487082 2.2820415
61 62 63 64 65 66
-21.3181358 -1.4609929 -8.7467072 -8.6038501 -1.4609929 -18.0324215
67 68 69 70 71 72
-24.6038501 -12.7467072 -19.1351317 -2.1351317 -7.1351317 -31.3017984
73 74 75 76 77 78
-15.9019757 -15.0448328 -13.3305471 -23.1876900 -16.0448328 -23.6162614
79 80
-30.1876900 -22.3305471
> postscript(file="/var/www/html/freestat/rcomp/tmp/6oqty1291134353.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 = 80
Frequency = 1
lag(myerror, k = 1) myerror
0 -40.3856383 NA
1 -35.5284954 -40.3856383
2 -10.8142097 -35.5284954
3 -31.6713526 -10.8142097
4 -32.5284954 -31.6713526
5 -24.0999240 -32.5284954
6 5.3286474 -24.0999240
7 -21.8142097 5.3286474
8 -24.2026342 -21.8142097
9 -36.2026342 -24.2026342
10 -0.2026342 -36.2026342
11 51.6306991 -0.2026342
12 3.0305218 51.6306991
13 -23.1123354 3.0305218
14 -3.3980496 -23.1123354
15 -0.2551925 -3.3980496
16 18.8876646 -0.2551925
17 -3.6837639 18.8876646
18 60.7448075 -3.6837639
19 10.6019504 60.7448075
20 36.2135258 10.6019504
21 3.2135258 36.2135258
22 -15.7864742 3.2135258
23 -31.9531408 -15.7864742
24 2.4466819 -31.9531408
25 12.3038247 2.4466819
26 -2.9818896 12.3038247
27 18.1609676 -2.9818896
28 -13.6961753 18.1609676
29 29.7323961 -13.6961753
30 7.1609676 29.7323961
31 5.0181104 7.1609676
32 -9.3703141 5.0181104
33 -1.3703141 -9.3703141
34 -21.3703141 -1.3703141
35 -9.5369807 -21.3703141
36 -7.1371581 -9.5369807
37 -5.2800152 -7.1371581
38 -14.5657295 -5.2800152
39 -0.4228723 -14.5657295
40 8.7199848 -0.4228723
41 34.1485562 8.7199848
42 -12.4228723 34.1485562
43 44.4342705 -12.4228723
44 12.0458460 44.4342705
45 27.0458460 12.0458460
46 24.0458460 27.0458460
47 18.8791793 24.0458460
48 79.2657042 18.8791793
49 68.1228470 79.2657042
50 53.8371327 68.1228470
51 45.9799899 53.8371327
52 36.1228470 45.9799899
53 5.5514184 36.1228470
54 -6.0200101 5.5514184
55 -3.1628673 -6.0200101
56 4.4487082 -3.1628673
57 9.4487082 4.4487082
58 20.4487082 9.4487082
59 2.2820415 20.4487082
60 -21.3181358 2.2820415
61 -1.4609929 -21.3181358
62 -8.7467072 -1.4609929
63 -8.6038501 -8.7467072
64 -1.4609929 -8.6038501
65 -18.0324215 -1.4609929
66 -24.6038501 -18.0324215
67 -12.7467072 -24.6038501
68 -19.1351317 -12.7467072
69 -2.1351317 -19.1351317
70 -7.1351317 -2.1351317
71 -31.3017984 -7.1351317
72 -15.9019757 -31.3017984
73 -15.0448328 -15.9019757
74 -13.3305471 -15.0448328
75 -23.1876900 -13.3305471
76 -16.0448328 -23.1876900
77 -23.6162614 -16.0448328
78 -30.1876900 -23.6162614
79 -22.3305471 -30.1876900
80 NA -22.3305471
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -35.5284954 -40.3856383
[2,] -10.8142097 -35.5284954
[3,] -31.6713526 -10.8142097
[4,] -32.5284954 -31.6713526
[5,] -24.0999240 -32.5284954
[6,] 5.3286474 -24.0999240
[7,] -21.8142097 5.3286474
[8,] -24.2026342 -21.8142097
[9,] -36.2026342 -24.2026342
[10,] -0.2026342 -36.2026342
[11,] 51.6306991 -0.2026342
[12,] 3.0305218 51.6306991
[13,] -23.1123354 3.0305218
[14,] -3.3980496 -23.1123354
[15,] -0.2551925 -3.3980496
[16,] 18.8876646 -0.2551925
[17,] -3.6837639 18.8876646
[18,] 60.7448075 -3.6837639
[19,] 10.6019504 60.7448075
[20,] 36.2135258 10.6019504
[21,] 3.2135258 36.2135258
[22,] -15.7864742 3.2135258
[23,] -31.9531408 -15.7864742
[24,] 2.4466819 -31.9531408
[25,] 12.3038247 2.4466819
[26,] -2.9818896 12.3038247
[27,] 18.1609676 -2.9818896
[28,] -13.6961753 18.1609676
[29,] 29.7323961 -13.6961753
[30,] 7.1609676 29.7323961
[31,] 5.0181104 7.1609676
[32,] -9.3703141 5.0181104
[33,] -1.3703141 -9.3703141
[34,] -21.3703141 -1.3703141
[35,] -9.5369807 -21.3703141
[36,] -7.1371581 -9.5369807
[37,] -5.2800152 -7.1371581
[38,] -14.5657295 -5.2800152
[39,] -0.4228723 -14.5657295
[40,] 8.7199848 -0.4228723
[41,] 34.1485562 8.7199848
[42,] -12.4228723 34.1485562
[43,] 44.4342705 -12.4228723
[44,] 12.0458460 44.4342705
[45,] 27.0458460 12.0458460
[46,] 24.0458460 27.0458460
[47,] 18.8791793 24.0458460
[48,] 79.2657042 18.8791793
[49,] 68.1228470 79.2657042
[50,] 53.8371327 68.1228470
[51,] 45.9799899 53.8371327
[52,] 36.1228470 45.9799899
[53,] 5.5514184 36.1228470
[54,] -6.0200101 5.5514184
[55,] -3.1628673 -6.0200101
[56,] 4.4487082 -3.1628673
[57,] 9.4487082 4.4487082
[58,] 20.4487082 9.4487082
[59,] 2.2820415 20.4487082
[60,] -21.3181358 2.2820415
[61,] -1.4609929 -21.3181358
[62,] -8.7467072 -1.4609929
[63,] -8.6038501 -8.7467072
[64,] -1.4609929 -8.6038501
[65,] -18.0324215 -1.4609929
[66,] -24.6038501 -18.0324215
[67,] -12.7467072 -24.6038501
[68,] -19.1351317 -12.7467072
[69,] -2.1351317 -19.1351317
[70,] -7.1351317 -2.1351317
[71,] -31.3017984 -7.1351317
[72,] -15.9019757 -31.3017984
[73,] -15.0448328 -15.9019757
[74,] -13.3305471 -15.0448328
[75,] -23.1876900 -13.3305471
[76,] -16.0448328 -23.1876900
[77,] -23.6162614 -16.0448328
[78,] -30.1876900 -23.6162614
[79,] -22.3305471 -30.1876900
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -35.5284954 -40.3856383
2 -10.8142097 -35.5284954
3 -31.6713526 -10.8142097
4 -32.5284954 -31.6713526
5 -24.0999240 -32.5284954
6 5.3286474 -24.0999240
7 -21.8142097 5.3286474
8 -24.2026342 -21.8142097
9 -36.2026342 -24.2026342
10 -0.2026342 -36.2026342
11 51.6306991 -0.2026342
12 3.0305218 51.6306991
13 -23.1123354 3.0305218
14 -3.3980496 -23.1123354
15 -0.2551925 -3.3980496
16 18.8876646 -0.2551925
17 -3.6837639 18.8876646
18 60.7448075 -3.6837639
19 10.6019504 60.7448075
20 36.2135258 10.6019504
21 3.2135258 36.2135258
22 -15.7864742 3.2135258
23 -31.9531408 -15.7864742
24 2.4466819 -31.9531408
25 12.3038247 2.4466819
26 -2.9818896 12.3038247
27 18.1609676 -2.9818896
28 -13.6961753 18.1609676
29 29.7323961 -13.6961753
30 7.1609676 29.7323961
31 5.0181104 7.1609676
32 -9.3703141 5.0181104
33 -1.3703141 -9.3703141
34 -21.3703141 -1.3703141
35 -9.5369807 -21.3703141
36 -7.1371581 -9.5369807
37 -5.2800152 -7.1371581
38 -14.5657295 -5.2800152
39 -0.4228723 -14.5657295
40 8.7199848 -0.4228723
41 34.1485562 8.7199848
42 -12.4228723 34.1485562
43 44.4342705 -12.4228723
44 12.0458460 44.4342705
45 27.0458460 12.0458460
46 24.0458460 27.0458460
47 18.8791793 24.0458460
48 79.2657042 18.8791793
49 68.1228470 79.2657042
50 53.8371327 68.1228470
51 45.9799899 53.8371327
52 36.1228470 45.9799899
53 5.5514184 36.1228470
54 -6.0200101 5.5514184
55 -3.1628673 -6.0200101
56 4.4487082 -3.1628673
57 9.4487082 4.4487082
58 20.4487082 9.4487082
59 2.2820415 20.4487082
60 -21.3181358 2.2820415
61 -1.4609929 -21.3181358
62 -8.7467072 -1.4609929
63 -8.6038501 -8.7467072
64 -1.4609929 -8.6038501
65 -18.0324215 -1.4609929
66 -24.6038501 -18.0324215
67 -12.7467072 -24.6038501
68 -19.1351317 -12.7467072
69 -2.1351317 -19.1351317
70 -7.1351317 -2.1351317
71 -31.3017984 -7.1351317
72 -15.9019757 -31.3017984
73 -15.0448328 -15.9019757
74 -13.3305471 -15.0448328
75 -23.1876900 -13.3305471
76 -16.0448328 -23.1876900
77 -23.6162614 -16.0448328
78 -30.1876900 -23.6162614
79 -22.3305471 -30.1876900
> 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/freestat/rcomp/tmp/7hzaj1291134353.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/freestat/rcomp/tmp/8aqsm1291134353.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/freestat/rcomp/tmp/9aqsm1291134353.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/freestat/rcomp/tmp/10aqsm1291134353.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/11607v1291134353.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/freestat/rcomp/tmp/122tqe1291134354.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/freestat/rcomp/tmp/13yk6m1291134354.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/freestat/rcomp/tmp/141l5s1291134354.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/freestat/rcomp/tmp/15nlly1291134354.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/freestat/rcomp/tmp/16842m1291134354.tab")
+ }
>
> try(system("convert tmp/1egud1291134353.ps tmp/1egud1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/2egud1291134353.ps tmp/2egud1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/3egud1291134353.ps tmp/3egud1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/4oqty1291134353.ps tmp/4oqty1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/5oqty1291134353.ps tmp/5oqty1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/6oqty1291134353.ps tmp/6oqty1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/7hzaj1291134353.ps tmp/7hzaj1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/8aqsm1291134353.ps tmp/8aqsm1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/9aqsm1291134353.ps tmp/9aqsm1291134353.png",intern=TRUE))
character(0)
> try(system("convert tmp/10aqsm1291134353.ps tmp/10aqsm1291134353.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
4.102 2.539 4.446