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(6654000
+ ,5712000
+ ,3
+ ,0.3
+ ,3.3
+ ,38.6
+ ,645
+ ,3
+ ,5
+ ,3
+ ,1000
+ ,6600
+ ,6.3
+ ,2
+ ,8.3
+ ,4.5
+ ,42
+ ,3
+ ,1
+ ,3
+ ,3385
+ ,44500
+ ,9.3
+ ,3.2
+ ,12.5
+ ,14
+ ,60
+ ,1
+ ,1
+ ,1
+ ,0.92
+ ,5700
+ ,13
+ ,3.5
+ ,16.5
+ ,0
+ ,25
+ ,5
+ ,2
+ ,3
+ ,2547000
+ ,4603000
+ ,2.1
+ ,1.8
+ ,3.9
+ ,69
+ ,624
+ ,3
+ ,5
+ ,4
+ ,10550
+ ,179500
+ ,9.1
+ ,0.7
+ ,9.8
+ ,27
+ ,180
+ ,4
+ ,4
+ ,4
+ ,0.023
+ ,0.3
+ ,15.8
+ ,3.9
+ ,19.7
+ ,19
+ ,35
+ ,1
+ ,1
+ ,1
+ ,160000
+ ,169000
+ ,5.2
+ ,1
+ ,6.2
+ ,30.4
+ ,392
+ ,4
+ ,5
+ ,4
+ ,3300
+ ,25600
+ ,10.9
+ ,3.6
+ ,14.5
+ ,28
+ ,63
+ ,1
+ ,2
+ ,1
+ ,52160
+ ,440000
+ ,8.3
+ ,1.4
+ ,9.7
+ ,50
+ ,230
+ ,1
+ ,1
+ ,1
+ ,0.425
+ ,6400
+ ,11
+ ,1.5
+ ,12.5
+ ,7
+ ,112
+ ,5
+ ,4
+ ,4
+ ,465000
+ ,423000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,2
+ ,4190
+ ,58000
+ ,9.7
+ ,0.6
+ ,10.3
+ ,24
+ ,210
+ ,4
+ ,3
+ ,4
+ ,3500
+ ,3900
+ ,12.8
+ ,6.6
+ ,19.4
+ ,3
+ ,14
+ ,2
+ ,1
+ ,1)
+ ,dim=c(10
+ ,58)
+ ,dimnames=list(c('gewicht'
+ ,'brein'
+ ,'nietdroomslaap'
+ ,'droomslaap'
+ ,'totaleslaap'
+ ,'levensduur'
+ ,'drachttijd'
+ ,'jager?'
+ ,'blootgesteldheidslaap'
+ ,'algemeengevaar')
+ ,1:58))
> y <- array(NA,dim=c(10,58),dimnames=list(c('gewicht','brein','nietdroomslaap','droomslaap','totaleslaap','levensduur','drachttijd','jager?','blootgesteldheidslaap','algemeengevaar'),1:58))
> 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 = '5'
> #'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
totaleslaap gewicht brein nietdroomslaap droomslaap levensduur
1 3.3 6.654e+06 5.712e+06 3.0 0.3 38.6
2 8.3 1.000e+03 6.600e+03 6.3 2.0 4.5
3 12.5 3.385e+03 4.450e+04 9.3 3.2 14.0
4 16.5 9.200e-01 5.700e+03 13.0 3.5 0.0
5 3.9 2.547e+06 4.603e+06 2.1 1.8 69.0
6 9.8 1.055e+04 1.795e+05 9.1 0.7 27.0
7 19.7 2.300e-02 3.000e-01 15.8 3.9 19.0
8 6.2 1.600e+05 1.690e+05 5.2 1.0 30.4
9 14.5 3.300e+03 2.560e+04 10.9 3.6 28.0
10 9.7 5.216e+04 4.400e+05 8.3 1.4 50.0
11 12.5 4.250e-01 6.400e+03 11.0 1.5 7.0
12 3.9 4.650e+05 4.230e+05 3.2 0.7 30.0
13 10.3 5.500e-01 2.400e+03 7.6 2.7 0.0
14 3.1 1.871e+05 4.190e+05 2.4 0.7 40.0
15 8.4 7.500e-02 1.200e+03 6.3 2.1 3.5
16 8.6 3.000e+03 2.500e+04 8.6 0.0 50.0
17 10.7 7.850e-01 3.500e+03 6.6 4.1 6.0
18 10.7 2.000e-01 5.000e+03 9.5 1.2 10.4
19 6.1 1.410e+03 1.750e+04 4.8 1.3 34.0
20 18.1 6.000e+04 8.100e+04 12.0 6.1 7.0
21 3.8 2.766e+04 1.150e+05 3.3 0.5 20.0
22 14.4 1.200e-01 1.000e+03 11.0 3.4 3.9
23 12.0 2.070e+05 4.060e+05 8.4 3.6 39.3
24 6.2 8.500e+04 3.250e+05 4.7 1.5 41.0
25 13.0 3.633e+04 1.195e+05 9.8 3.2 16.2
26 13.8 1.010e-01 4.000e+03 10.4 3.4 9.0
27 8.2 1.040e+03 5.500e+03 7.4 0.8 7.6
28 2.9 5.210e+05 6.550e+05 2.1 0.8 46.0
29 10.8 1.000e+05 1.570e+05 8.0 2.8 22.4
30 9.1 5.000e-03 1.400e-01 7.7 1.4 2.6
31 19.9 1.000e-02 2.500e-01 17.9 2.0 24.0
32 8.0 6.200e+04 1.320e+06 6.1 1.9 100.0
33 10.6 1.220e-01 3.000e+03 8.2 2.4 0.0
34 11.2 1.350e+03 8.100e+03 8.4 2.8 0.0
35 13.2 2.300e-02 4.000e-01 11.9 1.3 3.2
36 12.8 4.800e-02 3.300e-01 10.8 2.0 2.0
37 19.4 1.700e+03 6.300e+03 13.8 5.6 5.0
38 17.4 3.500e+03 1.080e+04 14.3 3.1 6.5
39 17.0 4.800e-01 1.550e+04 15.2 1.8 12.0
40 10.9 1.000e+04 1.150e+05 10.0 0.9 20.2
41 13.7 1.620e+03 1.140e+04 11.9 1.8 13.0
42 8.4 1.920e+05 1.800e+05 6.5 1.9 27.0
43 8.4 2.500e+03 1.210e+04 7.5 0.9 18.0
44 12.5 4.288e+03 3.920e+04 8.0 4.5 13.7
45 13.2 2.800e-01 1.900e+03 10.6 2.6 4.7
46 9.8 4.235e+03 5.040e+04 7.4 2.4 9.8
47 9.6 6.800e+03 1.790e+05 8.4 1.2 29.0
48 6.6 7.500e-01 1.230e+04 5.7 0.9 7.0
49 5.4 3.600e+03 2.100e+04 4.9 0.5 6.0
50 2.6 1.483e+04 9.820e+04 2.0 0.6 17.0
51 3.8 5.550e+04 1.750e+05 3.2 0.6 20.0
52 11.0 1.400e+03 1.250e+04 8.0 3.0 12.7
53 10.3 6.000e-02 1.000e+03 8.1 2.2 3.5
54 13.3 9.000e-01 2.600e+03 11.0 2.3 4.5
55 5.4 2.000e+03 1.230e+04 4.9 0.5 7.5
56 15.8 1.040e-01 2.500e+03 13.2 2.6 2.3
57 10.3 4.190e+03 5.800e+04 9.7 0.6 24.0
58 19.4 3.500e+03 3.900e+03 12.8 6.6 3.0
drachttijd jager? blootgesteldheidslaap algemeengevaar
1 645.0 3 5 3
2 42.0 3 1 3
3 60.0 1 1 1
4 25.0 5 2 3
5 624.0 3 5 4
6 180.0 4 4 4
7 35.0 1 1 1
8 392.0 4 5 4
9 63.0 1 2 1
10 230.0 1 1 1
11 112.0 5 4 4
12 281.0 5 5 5
13 0.0 2 1 2
14 365.0 5 5 5
15 42.0 1 1 1
16 28.0 2 2 2
17 42.0 2 2 2
18 120.0 2 2 2
19 0.0 1 2 1
20 0.0 1 1 1
21 148.0 5 5 5
22 16.0 3 1 2
23 252.0 1 4 1
24 310.0 1 3 1
25 63.0 1 1 1
26 28.0 5 1 3
27 68.0 5 3 4
28 336.0 5 5 5
29 100.0 1 1 1
30 21.5 5 2 4
31 50.0 1 1 1
32 267.0 1 1 1
33 30.0 2 1 1
34 45.0 3 1 3
35 19.0 4 1 3
36 30.0 4 1 3
37 12.0 2 1 1
38 120.0 2 1 1
39 140.0 2 2 2
40 170.0 4 4 4
41 17.0 2 1 2
42 115.0 4 4 4
43 31.0 5 5 5
44 63.0 2 2 2
45 21.0 3 1 3
46 52.0 1 1 1
47 164.0 2 3 2
48 225.0 2 2 2
49 225.0 3 2 3
50 150.0 5 5 5
51 151.0 5 5 5
52 90.0 2 2 2
53 0.0 3 1 2
54 60.0 2 1 2
55 200.0 3 1 3
56 46.0 3 2 2
57 210.0 4 3 4
58 14.0 2 1 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) gewicht brein
1.877e-15 9.168e-22 -6.873e-22
nietdroomslaap droomslaap levensduur
1.000e+00 1.000e+00 -1.153e-18
drachttijd `jager?` blootgesteldheidslaap
-7.788e-19 -5.060e-16 -6.441e-17
algemeengevaar
6.079e-16
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-2.264e-15 -5.332e-16 3.981e-17 5.966e-16 1.894e-15
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.877e-15 7.918e-16 2.371e+00 0.0218 *
gewicht 9.168e-22 5.117e-22 1.792e+00 0.0795 .
brein -6.873e-22 5.739e-22 -1.198e+00 0.2370
nietdroomslaap 1.000e+00 4.918e-17 2.033e+16 <2e-16 ***
droomslaap 1.000e+00 1.314e-16 7.612e+15 <2e-16 ***
levensduur -1.153e-18 1.204e-17 -9.600e-02 0.9242
drachttijd -7.788e-19 2.060e-18 -3.780e-01 0.7071
`jager?` -5.060e-16 2.874e-16 -1.761e+00 0.0846 .
blootgesteldheidslaap -6.441e-17 1.847e-16 -3.490e-01 0.7288
algemeengevaar 6.079e-16 3.893e-16 1.562e+00 0.1249
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 9.507e-16 on 48 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: 1
F-statistic: 1.487e+32 on 9 and 48 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,] 4.198079e-01 8.396158e-01 0.580192109
[2,] 4.453630e-01 8.907261e-01 0.554636969
[3,] 1.490778e-01 2.981555e-01 0.850922244
[4,] 4.245543e-01 8.491086e-01 0.575445712
[5,] 3.696795e-02 7.393590e-02 0.963032050
[6,] 1.297032e-01 2.594064e-01 0.870296806
[7,] 1.581574e-01 3.163148e-01 0.841842602
[8,] 6.823403e-01 6.353193e-01 0.317659669
[9,] 5.847682e-02 1.169536e-01 0.941523179
[10,] 6.534790e-02 1.306958e-01 0.934652103
[11,] 4.941836e-01 9.883671e-01 0.505816440
[12,] 5.041058e-02 1.008212e-01 0.949589422
[13,] 1.658697e-01 3.317394e-01 0.834130283
[14,] 1.216000e-01 2.431999e-01 0.878400035
[15,] 6.092241e-01 7.815519e-01 0.390775942
[16,] 6.532464e-04 1.306493e-03 0.999346754
[17,] 1.778411e-01 3.556822e-01 0.822158920
[18,] 6.446995e-01 7.106011e-01 0.355300547
[19,] 3.507868e-03 7.015736e-03 0.996492132
[20,] 3.572699e-01 7.145398e-01 0.642730102
[21,] 2.844483e-01 5.688965e-01 0.715551742
[22,] 3.848936e-02 7.697872e-02 0.961510638
[23,] 1.049429e-01 2.098859e-01 0.895057068
[24,] 5.116870e-03 1.023374e-02 0.994883130
[25,] 4.494306e-02 8.988612e-02 0.955056942
[26,] 3.354721e-05 6.709442e-05 0.999966453
[27,] 3.392241e-02 6.784483e-02 0.966077587
[28,] 5.434237e-01 9.131526e-01 0.456576306
[29,] 9.943556e-01 1.128884e-02 0.005644422
[30,] 4.297695e-01 8.595391e-01 0.570230460
[31,] 1.331112e-02 2.662224e-02 0.986688881
[32,] 2.581924e-02 5.163848e-02 0.974180759
[33,] 4.037556e-01 8.075111e-01 0.596244438
> postscript(file="/var/www/rcomp/tmp/1noz31321987984.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/2rkq71321987984.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/3f0q51321987984.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/4kcn31321987984.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/5jk781321987984.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 = 58
Frequency = 1
1 2 3 4 5
2.474774e-17 1.095963e-15 -1.484413e-15 -2.264306e-15 -1.744133e-17
6 7 8 9 10
1.090327e-15 -7.851027e-16 -2.869590e-17 4.594282e-16 -1.431527e-15
11 12 13 14 15
5.426192e-16 -6.809841e-16 4.248506e-16 1.674772e-16 3.704288e-16
16 17 18 19 20
5.487772e-17 -2.047608e-16 -7.010781e-16 -4.788163e-17 9.866651e-16
21 22 23 24 25
9.070688e-16 6.145611e-16 -7.542581e-17 6.317868e-16 -5.953781e-16
26 27 28 29 30
1.774166e-15 -7.771096e-16 1.809116e-16 7.434192e-16 -5.403983e-16
31 32 33 34 35
6.520524e-16 2.127404e-16 7.540688e-16 -1.210686e-15 -5.115900e-16
36 37 38 39 40
-3.052864e-18 -3.987168e-16 -1.585131e-15 8.637083e-16 4.462097e-16
41 42 43 44 45
-1.819589e-15 -2.099106e-16 -4.768312e-16 2.893372e-19 -1.328637e-16
46 47 48 49 50
3.614345e-16 -6.491478e-16 -8.527448e-16 3.920980e-16 -1.780842e-15
51 52 53 54 55
4.454531e-16 7.888276e-17 1.065476e-15 9.634664e-16 1.022118e-16
56 57 58
1.893701e-15 1.056105e-15 -9.158915e-17
> postscript(file="/var/www/rcomp/tmp/6ndeu1321987984.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 = 58
Frequency = 1
lag(myerror, k = 1) myerror
0 2.474774e-17 NA
1 1.095963e-15 2.474774e-17
2 -1.484413e-15 1.095963e-15
3 -2.264306e-15 -1.484413e-15
4 -1.744133e-17 -2.264306e-15
5 1.090327e-15 -1.744133e-17
6 -7.851027e-16 1.090327e-15
7 -2.869590e-17 -7.851027e-16
8 4.594282e-16 -2.869590e-17
9 -1.431527e-15 4.594282e-16
10 5.426192e-16 -1.431527e-15
11 -6.809841e-16 5.426192e-16
12 4.248506e-16 -6.809841e-16
13 1.674772e-16 4.248506e-16
14 3.704288e-16 1.674772e-16
15 5.487772e-17 3.704288e-16
16 -2.047608e-16 5.487772e-17
17 -7.010781e-16 -2.047608e-16
18 -4.788163e-17 -7.010781e-16
19 9.866651e-16 -4.788163e-17
20 9.070688e-16 9.866651e-16
21 6.145611e-16 9.070688e-16
22 -7.542581e-17 6.145611e-16
23 6.317868e-16 -7.542581e-17
24 -5.953781e-16 6.317868e-16
25 1.774166e-15 -5.953781e-16
26 -7.771096e-16 1.774166e-15
27 1.809116e-16 -7.771096e-16
28 7.434192e-16 1.809116e-16
29 -5.403983e-16 7.434192e-16
30 6.520524e-16 -5.403983e-16
31 2.127404e-16 6.520524e-16
32 7.540688e-16 2.127404e-16
33 -1.210686e-15 7.540688e-16
34 -5.115900e-16 -1.210686e-15
35 -3.052864e-18 -5.115900e-16
36 -3.987168e-16 -3.052864e-18
37 -1.585131e-15 -3.987168e-16
38 8.637083e-16 -1.585131e-15
39 4.462097e-16 8.637083e-16
40 -1.819589e-15 4.462097e-16
41 -2.099106e-16 -1.819589e-15
42 -4.768312e-16 -2.099106e-16
43 2.893372e-19 -4.768312e-16
44 -1.328637e-16 2.893372e-19
45 3.614345e-16 -1.328637e-16
46 -6.491478e-16 3.614345e-16
47 -8.527448e-16 -6.491478e-16
48 3.920980e-16 -8.527448e-16
49 -1.780842e-15 3.920980e-16
50 4.454531e-16 -1.780842e-15
51 7.888276e-17 4.454531e-16
52 1.065476e-15 7.888276e-17
53 9.634664e-16 1.065476e-15
54 1.022118e-16 9.634664e-16
55 1.893701e-15 1.022118e-16
56 1.056105e-15 1.893701e-15
57 -9.158915e-17 1.056105e-15
58 NA -9.158915e-17
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] 1.095963e-15 2.474774e-17
[2,] -1.484413e-15 1.095963e-15
[3,] -2.264306e-15 -1.484413e-15
[4,] -1.744133e-17 -2.264306e-15
[5,] 1.090327e-15 -1.744133e-17
[6,] -7.851027e-16 1.090327e-15
[7,] -2.869590e-17 -7.851027e-16
[8,] 4.594282e-16 -2.869590e-17
[9,] -1.431527e-15 4.594282e-16
[10,] 5.426192e-16 -1.431527e-15
[11,] -6.809841e-16 5.426192e-16
[12,] 4.248506e-16 -6.809841e-16
[13,] 1.674772e-16 4.248506e-16
[14,] 3.704288e-16 1.674772e-16
[15,] 5.487772e-17 3.704288e-16
[16,] -2.047608e-16 5.487772e-17
[17,] -7.010781e-16 -2.047608e-16
[18,] -4.788163e-17 -7.010781e-16
[19,] 9.866651e-16 -4.788163e-17
[20,] 9.070688e-16 9.866651e-16
[21,] 6.145611e-16 9.070688e-16
[22,] -7.542581e-17 6.145611e-16
[23,] 6.317868e-16 -7.542581e-17
[24,] -5.953781e-16 6.317868e-16
[25,] 1.774166e-15 -5.953781e-16
[26,] -7.771096e-16 1.774166e-15
[27,] 1.809116e-16 -7.771096e-16
[28,] 7.434192e-16 1.809116e-16
[29,] -5.403983e-16 7.434192e-16
[30,] 6.520524e-16 -5.403983e-16
[31,] 2.127404e-16 6.520524e-16
[32,] 7.540688e-16 2.127404e-16
[33,] -1.210686e-15 7.540688e-16
[34,] -5.115900e-16 -1.210686e-15
[35,] -3.052864e-18 -5.115900e-16
[36,] -3.987168e-16 -3.052864e-18
[37,] -1.585131e-15 -3.987168e-16
[38,] 8.637083e-16 -1.585131e-15
[39,] 4.462097e-16 8.637083e-16
[40,] -1.819589e-15 4.462097e-16
[41,] -2.099106e-16 -1.819589e-15
[42,] -4.768312e-16 -2.099106e-16
[43,] 2.893372e-19 -4.768312e-16
[44,] -1.328637e-16 2.893372e-19
[45,] 3.614345e-16 -1.328637e-16
[46,] -6.491478e-16 3.614345e-16
[47,] -8.527448e-16 -6.491478e-16
[48,] 3.920980e-16 -8.527448e-16
[49,] -1.780842e-15 3.920980e-16
[50,] 4.454531e-16 -1.780842e-15
[51,] 7.888276e-17 4.454531e-16
[52,] 1.065476e-15 7.888276e-17
[53,] 9.634664e-16 1.065476e-15
[54,] 1.022118e-16 9.634664e-16
[55,] 1.893701e-15 1.022118e-16
[56,] 1.056105e-15 1.893701e-15
[57,] -9.158915e-17 1.056105e-15
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 1.095963e-15 2.474774e-17
2 -1.484413e-15 1.095963e-15
3 -2.264306e-15 -1.484413e-15
4 -1.744133e-17 -2.264306e-15
5 1.090327e-15 -1.744133e-17
6 -7.851027e-16 1.090327e-15
7 -2.869590e-17 -7.851027e-16
8 4.594282e-16 -2.869590e-17
9 -1.431527e-15 4.594282e-16
10 5.426192e-16 -1.431527e-15
11 -6.809841e-16 5.426192e-16
12 4.248506e-16 -6.809841e-16
13 1.674772e-16 4.248506e-16
14 3.704288e-16 1.674772e-16
15 5.487772e-17 3.704288e-16
16 -2.047608e-16 5.487772e-17
17 -7.010781e-16 -2.047608e-16
18 -4.788163e-17 -7.010781e-16
19 9.866651e-16 -4.788163e-17
20 9.070688e-16 9.866651e-16
21 6.145611e-16 9.070688e-16
22 -7.542581e-17 6.145611e-16
23 6.317868e-16 -7.542581e-17
24 -5.953781e-16 6.317868e-16
25 1.774166e-15 -5.953781e-16
26 -7.771096e-16 1.774166e-15
27 1.809116e-16 -7.771096e-16
28 7.434192e-16 1.809116e-16
29 -5.403983e-16 7.434192e-16
30 6.520524e-16 -5.403983e-16
31 2.127404e-16 6.520524e-16
32 7.540688e-16 2.127404e-16
33 -1.210686e-15 7.540688e-16
34 -5.115900e-16 -1.210686e-15
35 -3.052864e-18 -5.115900e-16
36 -3.987168e-16 -3.052864e-18
37 -1.585131e-15 -3.987168e-16
38 8.637083e-16 -1.585131e-15
39 4.462097e-16 8.637083e-16
40 -1.819589e-15 4.462097e-16
41 -2.099106e-16 -1.819589e-15
42 -4.768312e-16 -2.099106e-16
43 2.893372e-19 -4.768312e-16
44 -1.328637e-16 2.893372e-19
45 3.614345e-16 -1.328637e-16
46 -6.491478e-16 3.614345e-16
47 -8.527448e-16 -6.491478e-16
48 3.920980e-16 -8.527448e-16
49 -1.780842e-15 3.920980e-16
50 4.454531e-16 -1.780842e-15
51 7.888276e-17 4.454531e-16
52 1.065476e-15 7.888276e-17
53 9.634664e-16 1.065476e-15
54 1.022118e-16 9.634664e-16
55 1.893701e-15 1.022118e-16
56 1.056105e-15 1.893701e-15
57 -9.158915e-17 1.056105e-15
> 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/7qi3t1321987984.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/8vb5i1321987984.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/905ls1321987984.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')
Warning messages:
1: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced
2: In sqrt(crit * p * (1 - hh)/hh) : NaNs produced
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/rcomp/tmp/10pbz51321987984.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/11cpax1321987984.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/122x0l1321987984.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/13i7u61321987984.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/14k80a1321987984.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/15r44m1321987984.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/16fa4g1321987984.tab")
+ }
>
> try(system("convert tmp/1noz31321987984.ps tmp/1noz31321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/2rkq71321987984.ps tmp/2rkq71321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/3f0q51321987984.ps tmp/3f0q51321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/4kcn31321987984.ps tmp/4kcn31321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/5jk781321987984.ps tmp/5jk781321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/6ndeu1321987984.ps tmp/6ndeu1321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/7qi3t1321987984.ps tmp/7qi3t1321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/8vb5i1321987984.ps tmp/8vb5i1321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/905ls1321987984.ps tmp/905ls1321987984.png",intern=TRUE))
character(0)
> try(system("convert tmp/10pbz51321987984.ps tmp/10pbz51321987984.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
3.080 0.310 3.345