R version 2.12.0 (2010-10-15)
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 <- array(list(104.37
+ ,167.16
+ ,101.56
+ ,100.93
+ ,104.89
+ ,179.84
+ ,102.13
+ ,101.18
+ ,105.15
+ ,174.44
+ ,102.39
+ ,101.11
+ ,105.72
+ ,180.35
+ ,102.42
+ ,102.42
+ ,106.38
+ ,193.17
+ ,103.87
+ ,102.37
+ ,106.40
+ ,195.16
+ ,104.44
+ ,101.95
+ ,106.47
+ ,202.43
+ ,104.97
+ ,102.20
+ ,106.59
+ ,189.91
+ ,105.17
+ ,103.35
+ ,106.76
+ ,195.98
+ ,105.35
+ ,103.65
+ ,107.35
+ ,212.09
+ ,104.65
+ ,102.06
+ ,107.81
+ ,205.81
+ ,106.62
+ ,102.66
+ ,108.03
+ ,204.31
+ ,107.05
+ ,102.32
+ ,109.08
+ ,196.07
+ ,112.30
+ ,102.21
+ ,109.86
+ ,199.98
+ ,114.70
+ ,102.33
+ ,110.29
+ ,199.1
+ ,115.40
+ ,104.41
+ ,110.34
+ ,198.31
+ ,115.64
+ ,104.33
+ ,110.59
+ ,195.72
+ ,115.66
+ ,105.27
+ ,110.64
+ ,223.04
+ ,114.50
+ ,105.34
+ ,110.83
+ ,238.41
+ ,115.14
+ ,104.88
+ ,111.51
+ ,259.73
+ ,115.41
+ ,105.49
+ ,113.32
+ ,326.54
+ ,119.32
+ ,105.90
+ ,115.89
+ ,335.15
+ ,124.77
+ ,105.39
+ ,116.51
+ ,321.81
+ ,130.96
+ ,104.40
+ ,117.44
+ ,368.62
+ ,141.02
+ ,106.19
+ ,118.25
+ ,369.59
+ ,150.60
+ ,106.54
+ ,118.65
+ ,425
+ ,151.10
+ ,108.26
+ ,118.52
+ ,439.72
+ ,157.19
+ ,106.95
+ ,119.07
+ ,362.23
+ ,157.28
+ ,108.32
+ ,119.12
+ ,328.76
+ ,156.54
+ ,108.35
+ ,119.28
+ ,348.55
+ ,159.62
+ ,109.29
+ ,119.30
+ ,328.18
+ ,163.77
+ ,109.46
+ ,119.44
+ ,329.34
+ ,165.08
+ ,109.50
+ ,119.57
+ ,295.55
+ ,164.75
+ ,109.84
+ ,119.93
+ ,237.38
+ ,163.93
+ ,108.73
+ ,120.03
+ ,226.85
+ ,157.51
+ ,109.38
+ ,119.66
+ ,220.14
+ ,153.36
+ ,109.97
+ ,119.46
+ ,239.36
+ ,156.83
+ ,111.10
+ ,119.48
+ ,224.69
+ ,154.98
+ ,110.53
+ ,119.56
+ ,230.98
+ ,155.02
+ ,110.23
+ ,119.43
+ ,233.47
+ ,153.34
+ ,109.41
+ ,119.57
+ ,256.7
+ ,153.19
+ ,108.94
+ ,119.59
+ ,253.41
+ ,152.80
+ ,109.81
+ ,119.50
+ ,224.95
+ ,152.97
+ ,109.20
+ ,119.54
+ ,210.37
+ ,152.96
+ ,109.45
+ ,119.56
+ ,191.09
+ ,152.35
+ ,110.61
+ ,119.61
+ ,198.85
+ ,151.88
+ ,109.44
+ ,119.64
+ ,211.04
+ ,150.27
+ ,109.77
+ ,119.60
+ ,206.25
+ ,148.80
+ ,108.04
+ ,119.71
+ ,201.19
+ ,149.28
+ ,109.65
+ ,119.72
+ ,194.37
+ ,148.64
+ ,111.69
+ ,119.66
+ ,191.08
+ ,150.36
+ ,111.65
+ ,119.76
+ ,192.87
+ ,149.69
+ ,112.04
+ ,119.80
+ ,181.61
+ ,152.94
+ ,111.42
+ ,119.88
+ ,157.67
+ ,155.18
+ ,112.25
+ ,119.78
+ ,196.14
+ ,156.32
+ ,111.46
+ ,120.08
+ ,246.35
+ ,156.25
+ ,111.62
+ ,120.22
+ ,271.9
+ ,155.52
+ ,111.77)
+ ,dim=c(4
+ ,57)
+ ,dimnames=list(c('Brood'
+ ,'Tarwe'
+ ,'Meel'
+ ,'Water')
+ ,1:57))
> y <- array(NA,dim=c(4,57),dimnames=list(c('Brood','Tarwe','Meel','Water'),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 = 'No Linear Trend'
> par2 = 'Do not include Seasonal 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
> 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
Brood Tarwe Meel Water
1 104.37 167.16 101.56 100.93
2 104.89 179.84 102.13 101.18
3 105.15 174.44 102.39 101.11
4 105.72 180.35 102.42 102.42
5 106.38 193.17 103.87 102.37
6 106.40 195.16 104.44 101.95
7 106.47 202.43 104.97 102.20
8 106.59 189.91 105.17 103.35
9 106.76 195.98 105.35 103.65
10 107.35 212.09 104.65 102.06
11 107.81 205.81 106.62 102.66
12 108.03 204.31 107.05 102.32
13 109.08 196.07 112.30 102.21
14 109.86 199.98 114.70 102.33
15 110.29 199.10 115.40 104.41
16 110.34 198.31 115.64 104.33
17 110.59 195.72 115.66 105.27
18 110.64 223.04 114.50 105.34
19 110.83 238.41 115.14 104.88
20 111.51 259.73 115.41 105.49
21 113.32 326.54 119.32 105.90
22 115.89 335.15 124.77 105.39
23 116.51 321.81 130.96 104.40
24 117.44 368.62 141.02 106.19
25 118.25 369.59 150.60 106.54
26 118.65 425.00 151.10 108.26
27 118.52 439.72 157.19 106.95
28 119.07 362.23 157.28 108.32
29 119.12 328.76 156.54 108.35
30 119.28 348.55 159.62 109.29
31 119.30 328.18 163.77 109.46
32 119.44 329.34 165.08 109.50
33 119.57 295.55 164.75 109.84
34 119.93 237.38 163.93 108.73
35 120.03 226.85 157.51 109.38
36 119.66 220.14 153.36 109.97
37 119.46 239.36 156.83 111.10
38 119.48 224.69 154.98 110.53
39 119.56 230.98 155.02 110.23
40 119.43 233.47 153.34 109.41
41 119.57 256.70 153.19 108.94
42 119.59 253.41 152.80 109.81
43 119.50 224.95 152.97 109.20
44 119.54 210.37 152.96 109.45
45 119.56 191.09 152.35 110.61
46 119.61 198.85 151.88 109.44
47 119.64 211.04 150.27 109.77
48 119.60 206.25 148.80 108.04
49 119.71 201.19 149.28 109.65
50 119.72 194.37 148.64 111.69
51 119.66 191.08 150.36 111.65
52 119.76 192.87 149.69 112.04
53 119.80 181.61 152.94 111.42
54 119.88 157.67 155.18 112.25
55 119.78 196.14 156.32 111.46
56 120.08 246.35 156.25 111.62
57 120.22 271.90 155.52 111.77
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Tarwe Meel Water
27.275181 0.007115 0.145572 0.618723
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-1.9598 -0.7556 0.0306 0.5031 3.2862
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 27.275181 11.325497 2.408 0.0195 *
Tarwe 0.007115 0.002911 2.444 0.0179 *
Meel 0.145572 0.021506 6.769 1.06e-08 ***
Water 0.618723 0.127504 4.853 1.11e-05 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.1 on 53 degrees of freedom
Multiple R-squared: 0.9639, Adjusted R-squared: 0.9619
F-statistic: 472.3 on 3 and 53 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,] 7.317600e-03 1.463520e-02 9.926824e-01
[2,] 4.451915e-03 8.903829e-03 9.955481e-01
[3,] 1.694698e-03 3.389397e-03 9.983053e-01
[4,] 7.274612e-04 1.454922e-03 9.992725e-01
[5,] 9.263575e-04 1.852715e-03 9.990736e-01
[6,] 5.818512e-04 1.163702e-03 9.994181e-01
[7,] 1.786625e-04 3.573251e-04 9.998213e-01
[8,] 5.328633e-05 1.065727e-04 9.999467e-01
[9,] 1.700265e-05 3.400530e-05 9.999830e-01
[10,] 6.308843e-06 1.261769e-05 9.999937e-01
[11,] 4.798733e-06 9.597467e-06 9.999952e-01
[12,] 1.093524e-05 2.187048e-05 9.999891e-01
[13,] 2.984265e-04 5.968530e-04 9.997016e-01
[14,] 1.571271e-02 3.142543e-02 9.842873e-01
[15,] 7.062043e-01 5.875914e-01 2.937957e-01
[16,] 8.037785e-01 3.924431e-01 1.962215e-01
[17,] 9.630230e-01 7.395397e-02 3.697698e-02
[18,] 1.000000e+00 2.658130e-08 1.329065e-08
[19,] 1.000000e+00 1.973707e-11 9.868534e-12
[20,] 1.000000e+00 6.063308e-13 3.031654e-13
[21,] 1.000000e+00 9.557055e-14 4.778528e-14
[22,] 1.000000e+00 3.330541e-13 1.665271e-13
[23,] 1.000000e+00 1.243876e-12 6.219382e-13
[24,] 1.000000e+00 3.981602e-12 1.990801e-12
[25,] 1.000000e+00 6.694649e-12 3.347325e-12
[26,] 1.000000e+00 1.338546e-11 6.692731e-12
[27,] 1.000000e+00 2.214668e-11 1.107334e-11
[28,] 1.000000e+00 3.123525e-11 1.561763e-11
[29,] 1.000000e+00 3.476448e-12 1.738224e-12
[30,] 1.000000e+00 1.624818e-11 8.124092e-12
[31,] 1.000000e+00 1.448635e-11 7.243176e-12
[32,] 1.000000e+00 2.600788e-11 1.300394e-11
[33,] 1.000000e+00 9.856488e-11 4.928244e-11
[34,] 1.000000e+00 1.806114e-10 9.030568e-11
[35,] 1.000000e+00 9.195414e-10 4.597707e-10
[36,] 1.000000e+00 1.709559e-09 8.547795e-10
[37,] 1.000000e+00 3.116396e-09 1.558198e-09
[38,] 1.000000e+00 8.634092e-09 4.317046e-09
[39,] 1.000000e+00 2.153814e-08 1.076907e-08
[40,] 9.999999e-01 1.842604e-07 9.213021e-08
[41,] 9.999992e-01 1.521966e-06 7.609829e-07
[42,] 9.999916e-01 1.683842e-05 8.419212e-06
[43,] 9.999653e-01 6.941958e-05 3.470979e-05
[44,] 9.994646e-01 1.070706e-03 5.353530e-04
> postscript(file="/var/www/rcomp/tmp/1li3p1292687472.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/rcomp/tmp/2li3p1292687472.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/rcomp/tmp/3ju9h1292687472.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/rcomp/tmp/4ju9h1292687472.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/rcomp/tmp/5ju9h1292687472.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 = 57
Frequency = 1
1 2 3 4 5
-1.326639e+00 -1.134520e+00 -8.306345e-01 -1.117581e+00 -7.289452e-01
6 7 8 9 10
-5.462174e-01 -7.597809e-01 -1.291341e+00 -1.376352e+00 1.846880e-01
11 12 13 14 15
3.136210e-02 4.098051e-01 8.222422e-01 1.150801e+00 1.982177e-01
16 17 18 19 20
2.683995e-01 -4.768266e-02 -6.652415e-02 2.055576e-01 3.171302e-01
21 22 23 24 25
8.288821e-01 2.859798e+00 3.286163e+00 1.311117e+00 5.030808e-01
26 27 28 29 30
-6.281772e-01 -9.389241e-01 -6.982986e-01 -3.209822e-01 -1.331759e+00
31 32 33 34 35
-1.876125e+00 -1.959827e+00 -1.751723e+00 -1.716639e-01 5.356653e-01
36 37 38 39 40
4.524879e-01 -1.088564e+00 -3.421993e-01 -1.271615e-01 4.770352e-01
41 42 43 44 45
7.643785e-01 3.262724e-01 7.914525e-01 7.819710e-01 3.102374e-01
46 47 48 49 50
1.097346e+00 1.070801e+00 2.349267e+00 1.429252e+00 3.187504e-01
51 52 53 54 55
5.652508e-02 1.972487e-05 3.063869e-02 -5.586389e-01 -6.095319e-01
56 57
-7.556052e-01 -7.839462e-01
> postscript(file="/var/www/rcomp/tmp/6611d1292687472.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 = 57
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.326639e+00 NA
1 -1.134520e+00 -1.326639e+00
2 -8.306345e-01 -1.134520e+00
3 -1.117581e+00 -8.306345e-01
4 -7.289452e-01 -1.117581e+00
5 -5.462174e-01 -7.289452e-01
6 -7.597809e-01 -5.462174e-01
7 -1.291341e+00 -7.597809e-01
8 -1.376352e+00 -1.291341e+00
9 1.846880e-01 -1.376352e+00
10 3.136210e-02 1.846880e-01
11 4.098051e-01 3.136210e-02
12 8.222422e-01 4.098051e-01
13 1.150801e+00 8.222422e-01
14 1.982177e-01 1.150801e+00
15 2.683995e-01 1.982177e-01
16 -4.768266e-02 2.683995e-01
17 -6.652415e-02 -4.768266e-02
18 2.055576e-01 -6.652415e-02
19 3.171302e-01 2.055576e-01
20 8.288821e-01 3.171302e-01
21 2.859798e+00 8.288821e-01
22 3.286163e+00 2.859798e+00
23 1.311117e+00 3.286163e+00
24 5.030808e-01 1.311117e+00
25 -6.281772e-01 5.030808e-01
26 -9.389241e-01 -6.281772e-01
27 -6.982986e-01 -9.389241e-01
28 -3.209822e-01 -6.982986e-01
29 -1.331759e+00 -3.209822e-01
30 -1.876125e+00 -1.331759e+00
31 -1.959827e+00 -1.876125e+00
32 -1.751723e+00 -1.959827e+00
33 -1.716639e-01 -1.751723e+00
34 5.356653e-01 -1.716639e-01
35 4.524879e-01 5.356653e-01
36 -1.088564e+00 4.524879e-01
37 -3.421993e-01 -1.088564e+00
38 -1.271615e-01 -3.421993e-01
39 4.770352e-01 -1.271615e-01
40 7.643785e-01 4.770352e-01
41 3.262724e-01 7.643785e-01
42 7.914525e-01 3.262724e-01
43 7.819710e-01 7.914525e-01
44 3.102374e-01 7.819710e-01
45 1.097346e+00 3.102374e-01
46 1.070801e+00 1.097346e+00
47 2.349267e+00 1.070801e+00
48 1.429252e+00 2.349267e+00
49 3.187504e-01 1.429252e+00
50 5.652508e-02 3.187504e-01
51 1.972487e-05 5.652508e-02
52 3.063869e-02 1.972487e-05
53 -5.586389e-01 3.063869e-02
54 -6.095319e-01 -5.586389e-01
55 -7.556052e-01 -6.095319e-01
56 -7.839462e-01 -7.556052e-01
57 NA -7.839462e-01
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -1.134520e+00 -1.326639e+00
[2,] -8.306345e-01 -1.134520e+00
[3,] -1.117581e+00 -8.306345e-01
[4,] -7.289452e-01 -1.117581e+00
[5,] -5.462174e-01 -7.289452e-01
[6,] -7.597809e-01 -5.462174e-01
[7,] -1.291341e+00 -7.597809e-01
[8,] -1.376352e+00 -1.291341e+00
[9,] 1.846880e-01 -1.376352e+00
[10,] 3.136210e-02 1.846880e-01
[11,] 4.098051e-01 3.136210e-02
[12,] 8.222422e-01 4.098051e-01
[13,] 1.150801e+00 8.222422e-01
[14,] 1.982177e-01 1.150801e+00
[15,] 2.683995e-01 1.982177e-01
[16,] -4.768266e-02 2.683995e-01
[17,] -6.652415e-02 -4.768266e-02
[18,] 2.055576e-01 -6.652415e-02
[19,] 3.171302e-01 2.055576e-01
[20,] 8.288821e-01 3.171302e-01
[21,] 2.859798e+00 8.288821e-01
[22,] 3.286163e+00 2.859798e+00
[23,] 1.311117e+00 3.286163e+00
[24,] 5.030808e-01 1.311117e+00
[25,] -6.281772e-01 5.030808e-01
[26,] -9.389241e-01 -6.281772e-01
[27,] -6.982986e-01 -9.389241e-01
[28,] -3.209822e-01 -6.982986e-01
[29,] -1.331759e+00 -3.209822e-01
[30,] -1.876125e+00 -1.331759e+00
[31,] -1.959827e+00 -1.876125e+00
[32,] -1.751723e+00 -1.959827e+00
[33,] -1.716639e-01 -1.751723e+00
[34,] 5.356653e-01 -1.716639e-01
[35,] 4.524879e-01 5.356653e-01
[36,] -1.088564e+00 4.524879e-01
[37,] -3.421993e-01 -1.088564e+00
[38,] -1.271615e-01 -3.421993e-01
[39,] 4.770352e-01 -1.271615e-01
[40,] 7.643785e-01 4.770352e-01
[41,] 3.262724e-01 7.643785e-01
[42,] 7.914525e-01 3.262724e-01
[43,] 7.819710e-01 7.914525e-01
[44,] 3.102374e-01 7.819710e-01
[45,] 1.097346e+00 3.102374e-01
[46,] 1.070801e+00 1.097346e+00
[47,] 2.349267e+00 1.070801e+00
[48,] 1.429252e+00 2.349267e+00
[49,] 3.187504e-01 1.429252e+00
[50,] 5.652508e-02 3.187504e-01
[51,] 1.972487e-05 5.652508e-02
[52,] 3.063869e-02 1.972487e-05
[53,] -5.586389e-01 3.063869e-02
[54,] -6.095319e-01 -5.586389e-01
[55,] -7.556052e-01 -6.095319e-01
[56,] -7.839462e-01 -7.556052e-01
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -1.134520e+00 -1.326639e+00
2 -8.306345e-01 -1.134520e+00
3 -1.117581e+00 -8.306345e-01
4 -7.289452e-01 -1.117581e+00
5 -5.462174e-01 -7.289452e-01
6 -7.597809e-01 -5.462174e-01
7 -1.291341e+00 -7.597809e-01
8 -1.376352e+00 -1.291341e+00
9 1.846880e-01 -1.376352e+00
10 3.136210e-02 1.846880e-01
11 4.098051e-01 3.136210e-02
12 8.222422e-01 4.098051e-01
13 1.150801e+00 8.222422e-01
14 1.982177e-01 1.150801e+00
15 2.683995e-01 1.982177e-01
16 -4.768266e-02 2.683995e-01
17 -6.652415e-02 -4.768266e-02
18 2.055576e-01 -6.652415e-02
19 3.171302e-01 2.055576e-01
20 8.288821e-01 3.171302e-01
21 2.859798e+00 8.288821e-01
22 3.286163e+00 2.859798e+00
23 1.311117e+00 3.286163e+00
24 5.030808e-01 1.311117e+00
25 -6.281772e-01 5.030808e-01
26 -9.389241e-01 -6.281772e-01
27 -6.982986e-01 -9.389241e-01
28 -3.209822e-01 -6.982986e-01
29 -1.331759e+00 -3.209822e-01
30 -1.876125e+00 -1.331759e+00
31 -1.959827e+00 -1.876125e+00
32 -1.751723e+00 -1.959827e+00
33 -1.716639e-01 -1.751723e+00
34 5.356653e-01 -1.716639e-01
35 4.524879e-01 5.356653e-01
36 -1.088564e+00 4.524879e-01
37 -3.421993e-01 -1.088564e+00
38 -1.271615e-01 -3.421993e-01
39 4.770352e-01 -1.271615e-01
40 7.643785e-01 4.770352e-01
41 3.262724e-01 7.643785e-01
42 7.914525e-01 3.262724e-01
43 7.819710e-01 7.914525e-01
44 3.102374e-01 7.819710e-01
45 1.097346e+00 3.102374e-01
46 1.070801e+00 1.097346e+00
47 2.349267e+00 1.070801e+00
48 1.429252e+00 2.349267e+00
49 3.187504e-01 1.429252e+00
50 5.652508e-02 3.187504e-01
51 1.972487e-05 5.652508e-02
52 3.063869e-02 1.972487e-05
53 -5.586389e-01 3.063869e-02
54 -6.095319e-01 -5.586389e-01
55 -7.556052e-01 -6.095319e-01
56 -7.839462e-01 -7.556052e-01
> 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/rcomp/tmp/7za0g1292687472.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/rcomp/tmp/8za0g1292687472.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/rcomp/tmp/9za0g1292687472.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/rcomp/tmp/10a1i11292687472.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/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, '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/rcomp/tmp/11v1y71292687472.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/rcomp/tmp/12h2fv1292687472.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/rcomp/tmp/13vcdl1292687472.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/rcomp/tmp/14gutr1292687472.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/rcomp/tmp/151d9x1292687472.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/rcomp/tmp/165vql1292687472.tab")
+ }
>
> try(system("convert tmp/1li3p1292687472.ps tmp/1li3p1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/2li3p1292687472.ps tmp/2li3p1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/3ju9h1292687472.ps tmp/3ju9h1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/4ju9h1292687472.ps tmp/4ju9h1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/5ju9h1292687472.ps tmp/5ju9h1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/6611d1292687472.ps tmp/6611d1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/7za0g1292687472.ps tmp/7za0g1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/8za0g1292687472.ps tmp/8za0g1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/9za0g1292687472.ps tmp/9za0g1292687472.png",intern=TRUE))
character(0)
> try(system("convert tmp/10a1i11292687472.ps tmp/10a1i11292687472.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.06 0.84 3.88