R version 2.6.0 (2007-10-03)
Copyright (C) 2007 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(8.1,8.3,8.2,8.1,7.7,7.6,7.7,8.2,8.4,8.4,8.6,8.4,8.5,8.7,8.7,8.6,7.4,7.3,7.4,9,9.2,9.2,8.5,8.3,8.3,8.6,8.6,8.5,8.1,8.1,8,8.6,8.7,8.7,8.6,8.4,8.4,8.7,8.7,8.5,8.3,8.3,8.3,8.1,8.2,8.1,8.1,7.9,7.7,8.1,8,7.7,7.8,7.6,7.4,7.7,7.8,7.5,7.2,7),dim=c(1,60),dimnames=list(c('Werkl'),1:60))
> y <- array(NA,dim=c(1,60),dimnames=list(c('Werkl'),1:60))
> 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 = '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)
> 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
Werkl t
1 8.1 1
2 8.3 2
3 8.2 3
4 8.1 4
5 7.7 5
6 7.6 6
7 7.7 7
8 8.2 8
9 8.4 9
10 8.4 10
11 8.6 11
12 8.4 12
13 8.5 13
14 8.7 14
15 8.7 15
16 8.6 16
17 7.4 17
18 7.3 18
19 7.4 19
20 9.0 20
21 9.2 21
22 9.2 22
23 8.5 23
24 8.3 24
25 8.3 25
26 8.6 26
27 8.6 27
28 8.5 28
29 8.1 29
30 8.1 30
31 8.0 31
32 8.6 32
33 8.7 33
34 8.7 34
35 8.6 35
36 8.4 36
37 8.4 37
38 8.7 38
39 8.7 39
40 8.5 40
41 8.3 41
42 8.3 42
43 8.3 43
44 8.1 44
45 8.2 45
46 8.1 46
47 8.1 47
48 7.9 48
49 7.7 49
50 8.1 50
51 8.0 51
52 7.7 52
53 7.8 53
54 7.6 54
55 7.4 55
56 7.7 56
57 7.8 57
58 7.5 58
59 7.2 59
60 7.0 60
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) t
8.46881 -0.00947
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-0.99837 -0.24941 0.05314 0.28610 0.93951
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.468814 0.120319 70.39 < 2e-16 ***
t -0.009469 0.003430 -2.76 0.00772 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.4602 on 58 degrees of freedom
Multiple R-Squared: 0.1161, Adjusted R-squared: 0.1009
F-statistic: 7.62 on 1 and 58 DF, p-value: 0.007716
> postscript(file="/var/www/html/rcomp/tmp/1exz31198242892.ps",horizontal=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/2lhh91198242892.ps",horizontal=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/36pzz1198242892.ps",horizontal=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/45hta1198242892.ps",horizontal=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/58ypg1198242892.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
> grid()
> dev.off()
null device
1
> (myerror <- as.ts(mysum$resid))
Time Series:
Start = 1
End = 60
Frequency = 1
1 2 3 4 5 6
-0.35934426 -0.14987497 -0.24040567 -0.33093637 -0.72146707 -0.81199778
7 8 9 10 11 12
-0.70252848 -0.19305918 0.01641011 0.02587941 0.23534871 0.04481801
13 14 15 16 17 18
0.15428730 0.36375660 0.37322590 0.28269519 -0.90783551 -0.99836621
19 20 21 22 23 24
-0.88889692 0.72057238 0.93004168 0.93951098 0.24898027 0.05844957
25 26 27 28 29 30
0.06791887 0.37738816 0.38685746 0.29632676 -0.09420395 -0.08473465
31 32 33 34 35 36
-0.17526535 0.43420395 0.54367324 0.55314254 0.46261184 0.27208113
37 38 39 40 41 42
0.28155043 0.59101973 0.60048902 0.40995832 0.21942762 0.22889692
43 44 45 46 47 48
0.23836621 0.04783551 0.15730481 0.06677410 0.07624340 -0.11428730
49 50 51 52 53 54
-0.30481801 0.10465129 0.01412059 -0.27641011 -0.16694082 -0.35747152
55 56 57 58 59 60
-0.54800222 -0.23853293 -0.12906363 -0.41959433 -0.71012503 -0.90065574
> postscript(file="/var/www/html/rcomp/tmp/6fdl11198242892.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> dum <- cbind(lag(myerror,k=1),myerror)
> dum
Time Series:
Start = 0
End = 60
Frequency = 1
lag(myerror, k = 1) myerror
0 -0.35934426 NA
1 -0.14987497 -0.35934426
2 -0.24040567 -0.14987497
3 -0.33093637 -0.24040567
4 -0.72146707 -0.33093637
5 -0.81199778 -0.72146707
6 -0.70252848 -0.81199778
7 -0.19305918 -0.70252848
8 0.01641011 -0.19305918
9 0.02587941 0.01641011
10 0.23534871 0.02587941
11 0.04481801 0.23534871
12 0.15428730 0.04481801
13 0.36375660 0.15428730
14 0.37322590 0.36375660
15 0.28269519 0.37322590
16 -0.90783551 0.28269519
17 -0.99836621 -0.90783551
18 -0.88889692 -0.99836621
19 0.72057238 -0.88889692
20 0.93004168 0.72057238
21 0.93951098 0.93004168
22 0.24898027 0.93951098
23 0.05844957 0.24898027
24 0.06791887 0.05844957
25 0.37738816 0.06791887
26 0.38685746 0.37738816
27 0.29632676 0.38685746
28 -0.09420395 0.29632676
29 -0.08473465 -0.09420395
30 -0.17526535 -0.08473465
31 0.43420395 -0.17526535
32 0.54367324 0.43420395
33 0.55314254 0.54367324
34 0.46261184 0.55314254
35 0.27208113 0.46261184
36 0.28155043 0.27208113
37 0.59101973 0.28155043
38 0.60048902 0.59101973
39 0.40995832 0.60048902
40 0.21942762 0.40995832
41 0.22889692 0.21942762
42 0.23836621 0.22889692
43 0.04783551 0.23836621
44 0.15730481 0.04783551
45 0.06677410 0.15730481
46 0.07624340 0.06677410
47 -0.11428730 0.07624340
48 -0.30481801 -0.11428730
49 0.10465129 -0.30481801
50 0.01412059 0.10465129
51 -0.27641011 0.01412059
52 -0.16694082 -0.27641011
53 -0.35747152 -0.16694082
54 -0.54800222 -0.35747152
55 -0.23853293 -0.54800222
56 -0.12906363 -0.23853293
57 -0.41959433 -0.12906363
58 -0.71012503 -0.41959433
59 -0.90065574 -0.71012503
60 NA -0.90065574
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.14987497 -0.35934426
[2,] -0.24040567 -0.14987497
[3,] -0.33093637 -0.24040567
[4,] -0.72146707 -0.33093637
[5,] -0.81199778 -0.72146707
[6,] -0.70252848 -0.81199778
[7,] -0.19305918 -0.70252848
[8,] 0.01641011 -0.19305918
[9,] 0.02587941 0.01641011
[10,] 0.23534871 0.02587941
[11,] 0.04481801 0.23534871
[12,] 0.15428730 0.04481801
[13,] 0.36375660 0.15428730
[14,] 0.37322590 0.36375660
[15,] 0.28269519 0.37322590
[16,] -0.90783551 0.28269519
[17,] -0.99836621 -0.90783551
[18,] -0.88889692 -0.99836621
[19,] 0.72057238 -0.88889692
[20,] 0.93004168 0.72057238
[21,] 0.93951098 0.93004168
[22,] 0.24898027 0.93951098
[23,] 0.05844957 0.24898027
[24,] 0.06791887 0.05844957
[25,] 0.37738816 0.06791887
[26,] 0.38685746 0.37738816
[27,] 0.29632676 0.38685746
[28,] -0.09420395 0.29632676
[29,] -0.08473465 -0.09420395
[30,] -0.17526535 -0.08473465
[31,] 0.43420395 -0.17526535
[32,] 0.54367324 0.43420395
[33,] 0.55314254 0.54367324
[34,] 0.46261184 0.55314254
[35,] 0.27208113 0.46261184
[36,] 0.28155043 0.27208113
[37,] 0.59101973 0.28155043
[38,] 0.60048902 0.59101973
[39,] 0.40995832 0.60048902
[40,] 0.21942762 0.40995832
[41,] 0.22889692 0.21942762
[42,] 0.23836621 0.22889692
[43,] 0.04783551 0.23836621
[44,] 0.15730481 0.04783551
[45,] 0.06677410 0.15730481
[46,] 0.07624340 0.06677410
[47,] -0.11428730 0.07624340
[48,] -0.30481801 -0.11428730
[49,] 0.10465129 -0.30481801
[50,] 0.01412059 0.10465129
[51,] -0.27641011 0.01412059
[52,] -0.16694082 -0.27641011
[53,] -0.35747152 -0.16694082
[54,] -0.54800222 -0.35747152
[55,] -0.23853293 -0.54800222
[56,] -0.12906363 -0.23853293
[57,] -0.41959433 -0.12906363
[58,] -0.71012503 -0.41959433
[59,] -0.90065574 -0.71012503
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.14987497 -0.35934426
2 -0.24040567 -0.14987497
3 -0.33093637 -0.24040567
4 -0.72146707 -0.33093637
5 -0.81199778 -0.72146707
6 -0.70252848 -0.81199778
7 -0.19305918 -0.70252848
8 0.01641011 -0.19305918
9 0.02587941 0.01641011
10 0.23534871 0.02587941
11 0.04481801 0.23534871
12 0.15428730 0.04481801
13 0.36375660 0.15428730
14 0.37322590 0.36375660
15 0.28269519 0.37322590
16 -0.90783551 0.28269519
17 -0.99836621 -0.90783551
18 -0.88889692 -0.99836621
19 0.72057238 -0.88889692
20 0.93004168 0.72057238
21 0.93951098 0.93004168
22 0.24898027 0.93951098
23 0.05844957 0.24898027
24 0.06791887 0.05844957
25 0.37738816 0.06791887
26 0.38685746 0.37738816
27 0.29632676 0.38685746
28 -0.09420395 0.29632676
29 -0.08473465 -0.09420395
30 -0.17526535 -0.08473465
31 0.43420395 -0.17526535
32 0.54367324 0.43420395
33 0.55314254 0.54367324
34 0.46261184 0.55314254
35 0.27208113 0.46261184
36 0.28155043 0.27208113
37 0.59101973 0.28155043
38 0.60048902 0.59101973
39 0.40995832 0.60048902
40 0.21942762 0.40995832
41 0.22889692 0.21942762
42 0.23836621 0.22889692
43 0.04783551 0.23836621
44 0.15730481 0.04783551
45 0.06677410 0.15730481
46 0.07624340 0.06677410
47 -0.11428730 0.07624340
48 -0.30481801 -0.11428730
49 0.10465129 -0.30481801
50 0.01412059 0.10465129
51 -0.27641011 0.01412059
52 -0.16694082 -0.27641011
53 -0.35747152 -0.16694082
54 -0.54800222 -0.35747152
55 -0.23853293 -0.54800222
56 -0.12906363 -0.23853293
57 -0.41959433 -0.12906363
58 -0.71012503 -0.41959433
59 -0.90065574 -0.71012503
> 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/7xu8v1198242892.ps",horizontal=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/8jpo21198242892.ps",horizontal=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/93r0f1198242892.ps",horizontal=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
> 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/10xh9s1198242893.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/110rt21198242893.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/12dy0m1198242893.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/13egqa1198242893.tab")
>
> system("convert tmp/1exz31198242892.ps tmp/1exz31198242892.png")
> system("convert tmp/2lhh91198242892.ps tmp/2lhh91198242892.png")
> system("convert tmp/36pzz1198242892.ps tmp/36pzz1198242892.png")
> system("convert tmp/45hta1198242892.ps tmp/45hta1198242892.png")
> system("convert tmp/58ypg1198242892.ps tmp/58ypg1198242892.png")
> system("convert tmp/6fdl11198242892.ps tmp/6fdl11198242892.png")
> system("convert tmp/7xu8v1198242892.ps tmp/7xu8v1198242892.png")
> system("convert tmp/8jpo21198242892.ps tmp/8jpo21198242892.png")
> system("convert tmp/93r0f1198242892.ps tmp/93r0f1198242892.png")
>
>
> proc.time()
user system elapsed
2.214 1.446 2.558