R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> x <- array(list(15
+ ,15
+ ,11
+ ,12
+ ,13
+ ,6
+ ,1
+ ,9
+ ,12
+ ,12
+ ,7
+ ,11
+ ,4
+ ,0
+ ,12
+ ,15
+ ,12
+ ,13
+ ,14
+ ,6
+ ,0
+ ,15
+ ,12
+ ,11
+ ,11
+ ,12
+ ,5
+ ,0
+ ,17
+ ,14
+ ,11
+ ,16
+ ,12
+ ,5
+ ,0
+ ,14
+ ,8
+ ,10
+ ,10
+ ,6
+ ,4
+ ,0
+ ,9
+ ,11
+ ,11
+ ,15
+ ,10
+ ,5
+ ,1
+ ,12
+ ,15
+ ,9
+ ,5
+ ,11
+ ,3
+ ,1
+ ,11
+ ,4
+ ,10
+ ,4
+ ,10
+ ,2
+ ,0
+ ,13
+ ,13
+ ,12
+ ,7
+ ,12
+ ,5
+ ,0
+ ,16
+ ,19
+ ,12
+ ,15
+ ,15
+ ,6
+ ,1
+ ,16
+ ,10
+ ,12
+ ,5
+ ,13
+ ,6
+ ,1
+ ,10
+ ,6
+ ,9
+ ,15
+ ,11
+ ,6
+ ,0
+ ,16
+ ,7
+ ,12
+ ,13
+ ,12
+ ,3
+ ,1
+ ,12
+ ,14
+ ,12
+ ,13
+ ,13
+ ,6
+ ,0
+ ,15
+ ,16
+ ,12
+ ,15
+ ,14
+ ,6
+ ,0
+ ,13
+ ,16
+ ,12
+ ,15
+ ,16
+ ,7
+ ,1
+ ,18
+ ,14
+ ,13
+ ,10
+ ,16
+ ,8
+ ,1
+ ,13
+ ,15
+ ,11
+ ,17
+ ,16
+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7
+ ,10
+ ,3
+ ,0
+ ,12
+ ,16
+ ,12
+ ,12
+ ,15
+ ,8
+ ,1
+ ,13
+ ,12
+ ,12
+ ,10
+ ,13
+ ,4
+ ,1
+ ,14
+ ,12
+ ,10
+ ,14
+ ,14
+ ,5
+ ,1
+ ,14
+ ,8
+ ,7
+ ,9
+ ,15
+ ,4
+ ,1
+ ,12
+ ,13
+ ,12
+ ,14
+ ,14
+ ,6
+ ,0
+ ,13
+ ,12
+ ,13
+ ,14
+ ,12
+ ,5
+ ,1
+ ,17
+ ,12
+ ,12
+ ,15
+ ,13
+ ,6
+ ,1
+ ,16
+ ,12
+ ,12
+ ,6
+ ,14
+ ,5
+ ,1
+ ,15
+ ,4
+ ,8
+ ,6
+ ,4
+ ,4
+ ,1)
+ ,dim=c(7
+ ,77)
+ ,dimnames=list(c('Perceived_happiness'
+ ,'Popularity'
+ ,'Finding_friends'
+ ,'Knowing_people'
+ ,'Liked'
+ ,'Celebrity'
+ ,'Gender')
+ ,1:77))
> y <- array(NA,dim=c(7,77),dimnames=list(c('Perceived_happiness','Popularity','Finding_friends','Knowing_people','Liked','Celebrity','Gender'),1:77))
> 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
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
Liked Perceived_happiness Popularity Finding_friends Knowing_people
1 13 15 15 11 12
2 11 9 12 12 7
3 14 12 15 12 13
4 12 15 12 11 11
5 12 17 14 11 16
6 6 14 8 10 10
7 10 9 11 11 15
8 11 12 15 9 5
9 10 11 4 10 4
10 12 13 13 12 7
11 15 16 19 12 15
12 13 16 10 12 5
13 11 10 6 9 15
14 12 16 7 12 13
15 13 12 14 12 13
16 14 15 16 12 15
17 16 13 16 12 15
18 16 18 14 13 10
19 16 13 15 11 17
20 15 17 14 12 14
21 13 14 12 12 9
22 8 13 9 15 6
23 14 13 12 11 11
24 15 15 14 12 13
25 13 13 12 10 12
26 16 15 14 11 10
27 13 13 10 13 4
28 12 14 14 6 13
29 15 13 16 12 15
30 14 14 8 10 10
31 13 15 11 12 7
32 12 9 8 11 9
33 14 16 13 9 14
34 13 16 11 10 5
35 14 13 16 12 16
36 15 17 16 11 14
37 16 15 13 12 16
38 15 14 14 11 15
39 5 10 5 14 4
40 15 13 14 10 12
41 16 16 14 11 15
42 16 16 14 11 15
43 14 15 11 10 12
44 13 15 15 12 13
45 14 12 16 11 14
46 12 15 11 12 15
47 15 17 10 11 13
48 13 10 8 7 4
49 10 11 9 11 8
50 13 15 12 8 13
51 14 15 14 11 15
52 13 7 12 12 15
53 18 14 14 14 17
54 16 12 16 12 14
55 15 14 13 13 11
56 14 11 11 8 10
57 16 16 15 12 14
58 11 16 6 12 6
59 13 11 12 11 16
60 14 15 13 13 15
61 14 14 8 12 8
62 12 15 9 11 9
63 16 17 10 12 8
64 14 19 16 12 14
65 12 16 14 11 14
66 13 14 12 8 15
67 13 15 12 12 12
68 10 17 8 13 7
69 15 12 16 12 12
70 13 13 12 12 10
71 14 14 12 10 14
72 15 14 8 7 9
73 14 12 13 12 14
74 12 13 12 13 14
75 13 17 12 12 15
76 14 16 12 12 6
77 4 15 4 8 6
Celebrity Gender
1 6 1
2 4 0
3 6 0
4 5 0
5 5 0
6 4 0
7 5 1
8 3 1
9 2 0
10 5 0
11 6 1
12 6 1
13 6 0
14 3 1
15 6 0
16 6 0
17 7 1
18 8 1
19 6 0
20 7 1
21 4 1
22 4 0
23 2 1
24 6 1
25 6 1
26 6 1
27 6 1
28 6 1
29 7 1
30 3 1
31 6 1
32 4 0
33 6 0
34 3 1
35 6 0
36 6 1
37 6 1
38 8 1
39 2 0
40 6 0
41 6 0
42 6 0
43 5 1
44 6 1
45 6 1
46 6 0
47 6 1
48 6 1
49 4 0
50 5 1
51 6 0
52 6 1
53 6 0
54 8 1
55 6 1
56 5 1
57 4 1
58 2 1
59 4 0
60 6 0
61 5 0
62 4 1
63 4 1
64 6 1
65 6 0
66 7 1
67 4 1
68 3 0
69 8 1
70 4 1
71 5 1
72 4 1
73 6 0
74 5 1
75 6 1
76 5 1
77 4 1
> k <- length(x[1,])
> df <- as.data.frame(x)
> (mylm <- lm(df))
Call:
lm(formula = df)
Coefficients:
(Intercept) Perceived_happiness Popularity
3.98258 0.12597 0.30366
Finding_friends Knowing_people Celebrity
0.04251 0.10195 0.30882
Gender
0.81771
> (mysum <- summary(mylm))
Call:
lm(formula = df)
Residuals:
Min 1Q Median 3Q Max
-6.0916 -0.6493 0.1292 0.9615 3.8213
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.98258 1.93583 2.057 0.0434 *
Perceived_happiness 0.12597 0.09349 1.347 0.1822
Popularity 0.30366 0.09800 3.099 0.0028 **
Finding_friends 0.04251 0.13516 0.315 0.7541
Knowing_people 0.10195 0.07569 1.347 0.1823
Celebrity 0.30882 0.19810 1.559 0.1235
Gender 0.81771 0.46007 1.777 0.0799 .
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.808 on 70 degrees of freedom
Multiple R-squared: 0.4952, Adjusted R-squared: 0.4519
F-statistic: 11.44 on 6 and 70 DF, p-value: 7.028e-09
> 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.84192400 0.31615200 0.1580760
[2,] 0.75182069 0.49635863 0.2481793
[3,] 0.62720017 0.74559966 0.3727998
[4,] 0.70929806 0.58140387 0.2907019
[5,] 0.67474630 0.65050741 0.3252537
[6,] 0.57218943 0.85562113 0.4278106
[7,] 0.48419242 0.96838483 0.5158076
[8,] 0.44472690 0.88945379 0.5552731
[9,] 0.35296564 0.70593128 0.6470344
[10,] 0.49338265 0.98676530 0.5066174
[11,] 0.40380255 0.80760510 0.5961974
[12,] 0.32686439 0.65372879 0.6731356
[13,] 0.51269272 0.97461456 0.4873073
[14,] 0.57202820 0.85594360 0.4279718
[15,] 0.49971052 0.99942104 0.5002895
[16,] 0.42333724 0.84667448 0.5766628
[17,] 0.42329591 0.84659183 0.5767041
[18,] 0.35519545 0.71039090 0.6448045
[19,] 0.36690615 0.73381229 0.6330939
[20,] 0.30165995 0.60331990 0.6983401
[21,] 0.38634793 0.77269587 0.6136521
[22,] 0.31713604 0.63427209 0.6828640
[23,] 0.31857218 0.63714437 0.6814278
[24,] 0.28045891 0.56091781 0.7195411
[25,] 0.23373834 0.46747668 0.7662617
[26,] 0.19206094 0.38412187 0.8079391
[27,] 0.15341056 0.30682112 0.8465894
[28,] 0.13925195 0.27850389 0.8607481
[29,] 0.10299343 0.20598687 0.8970066
[30,] 0.22301912 0.44603824 0.7769809
[31,] 0.21134444 0.42268887 0.7886556
[32,] 0.21255171 0.42510343 0.7874483
[33,] 0.21020194 0.42040389 0.7897981
[34,] 0.17093535 0.34187070 0.8290647
[35,] 0.17579507 0.35159015 0.8242049
[36,] 0.15220198 0.30440395 0.8477980
[37,] 0.12201925 0.24403849 0.8779808
[38,] 0.13420865 0.26841730 0.8657913
[39,] 0.12171634 0.24343269 0.8782837
[40,] 0.11584721 0.23169442 0.8841528
[41,] 0.08712045 0.17424089 0.9128796
[42,] 0.06207937 0.12415874 0.9379206
[43,] 0.04533840 0.09067679 0.9546616
[44,] 0.15088787 0.30177575 0.8491121
[45,] 0.11054799 0.22109598 0.8894520
[46,] 0.08550594 0.17101187 0.9144941
[47,] 0.06287381 0.12574762 0.9371262
[48,] 0.04619624 0.09239248 0.9538038
[49,] 0.02972721 0.05945442 0.9702728
[50,] 0.01922730 0.03845459 0.9807727
[51,] 0.01186950 0.02373900 0.9881305
[52,] 0.04803482 0.09606964 0.9519652
[53,] 0.02869160 0.05738320 0.9713084
[54,] 0.15771131 0.31542261 0.8422887
[55,] 0.14919691 0.29839382 0.8508031
[56,] 0.50041823 0.99916353 0.4995818
[57,] 0.50938963 0.98122073 0.4906104
[58,] 0.45609941 0.91219882 0.5439006
> postscript(file="/var/www/html/rcomp/tmp/1sxi61292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(x[,1], type='l', main='Actuals and Interpolation', ylab='value of Actuals and Interpolation (dots)', xlab='time or index')
> points(x[,1]-mysum$resid)
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/237hr1292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/337hr1292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/437hr1292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/58drn1292268190.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 = 77
Frequency = 1
1 2 3 4 5 6
-1.78875001 -0.21934185 0.26242144 -0.64927512 -2.01828474 -4.85536860
7 8 9 10 11 12
-2.81528636 -1.68571212 1.96653160 -0.33571471 -1.47773012 0.27471917
13 14 15 16 17 18
0.17097379 0.29659329 -0.43391507 -0.62305316 0.50235390 0.63822766
19 20 21 22 23 24
1.77116938 -0.29225872 0.12918870 -2.83782380 1.71141988 0.37045475
25 26 27 28 29 30
-0.58330491 1.71880905 0.71207155 -2.24850776 -0.49764610 2.63573874
31 32 33 34 35 36
-0.10686805 1.83392747 0.39144607 0.98254352 -0.47305726 -0.54825277
37 38 39 40 41 42
1.36827487 -0.28260202 -3.38120381 1.62708275 1.90081291 1.90081291
43 44 45 46 47 48
0.77723687 -1.93320874 -0.91839354 -1.10473571 1.37567596 1.95237971
49 50 51 52 53 54
-0.61973192 -0.54335252 0.02678476 -0.21833908 3.82132820 0.42145154
55 56 57 58 59 60
0.96147472 1.57004171 1.45651560 0.62271329 0.65369530 0.24542637
61 62 63 64 65 66
2.95468310 -0.04328174 3.46054793 -1.84270740 -1.99723930 -1.23892023
67 68 69 70 71 72
-0.30262651 -0.74615161 -0.37465288 0.15321276 0.39564965 3.55639736
73 74 75 76 77
0.76780063 -1.60591132 -1.47805754 0.87426639 -6.09158810
> postscript(file="/var/www/html/rcomp/tmp/68drn1292268190.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 = 77
Frequency = 1
lag(myerror, k = 1) myerror
0 -1.78875001 NA
1 -0.21934185 -1.78875001
2 0.26242144 -0.21934185
3 -0.64927512 0.26242144
4 -2.01828474 -0.64927512
5 -4.85536860 -2.01828474
6 -2.81528636 -4.85536860
7 -1.68571212 -2.81528636
8 1.96653160 -1.68571212
9 -0.33571471 1.96653160
10 -1.47773012 -0.33571471
11 0.27471917 -1.47773012
12 0.17097379 0.27471917
13 0.29659329 0.17097379
14 -0.43391507 0.29659329
15 -0.62305316 -0.43391507
16 0.50235390 -0.62305316
17 0.63822766 0.50235390
18 1.77116938 0.63822766
19 -0.29225872 1.77116938
20 0.12918870 -0.29225872
21 -2.83782380 0.12918870
22 1.71141988 -2.83782380
23 0.37045475 1.71141988
24 -0.58330491 0.37045475
25 1.71880905 -0.58330491
26 0.71207155 1.71880905
27 -2.24850776 0.71207155
28 -0.49764610 -2.24850776
29 2.63573874 -0.49764610
30 -0.10686805 2.63573874
31 1.83392747 -0.10686805
32 0.39144607 1.83392747
33 0.98254352 0.39144607
34 -0.47305726 0.98254352
35 -0.54825277 -0.47305726
36 1.36827487 -0.54825277
37 -0.28260202 1.36827487
38 -3.38120381 -0.28260202
39 1.62708275 -3.38120381
40 1.90081291 1.62708275
41 1.90081291 1.90081291
42 0.77723687 1.90081291
43 -1.93320874 0.77723687
44 -0.91839354 -1.93320874
45 -1.10473571 -0.91839354
46 1.37567596 -1.10473571
47 1.95237971 1.37567596
48 -0.61973192 1.95237971
49 -0.54335252 -0.61973192
50 0.02678476 -0.54335252
51 -0.21833908 0.02678476
52 3.82132820 -0.21833908
53 0.42145154 3.82132820
54 0.96147472 0.42145154
55 1.57004171 0.96147472
56 1.45651560 1.57004171
57 0.62271329 1.45651560
58 0.65369530 0.62271329
59 0.24542637 0.65369530
60 2.95468310 0.24542637
61 -0.04328174 2.95468310
62 3.46054793 -0.04328174
63 -1.84270740 3.46054793
64 -1.99723930 -1.84270740
65 -1.23892023 -1.99723930
66 -0.30262651 -1.23892023
67 -0.74615161 -0.30262651
68 -0.37465288 -0.74615161
69 0.15321276 -0.37465288
70 0.39564965 0.15321276
71 3.55639736 0.39564965
72 0.76780063 3.55639736
73 -1.60591132 0.76780063
74 -1.47805754 -1.60591132
75 0.87426639 -1.47805754
76 -6.09158810 0.87426639
77 NA -6.09158810
> dum1 <- dum[2:length(myerror),]
> dum1
lag(myerror, k = 1) myerror
[1,] -0.21934185 -1.78875001
[2,] 0.26242144 -0.21934185
[3,] -0.64927512 0.26242144
[4,] -2.01828474 -0.64927512
[5,] -4.85536860 -2.01828474
[6,] -2.81528636 -4.85536860
[7,] -1.68571212 -2.81528636
[8,] 1.96653160 -1.68571212
[9,] -0.33571471 1.96653160
[10,] -1.47773012 -0.33571471
[11,] 0.27471917 -1.47773012
[12,] 0.17097379 0.27471917
[13,] 0.29659329 0.17097379
[14,] -0.43391507 0.29659329
[15,] -0.62305316 -0.43391507
[16,] 0.50235390 -0.62305316
[17,] 0.63822766 0.50235390
[18,] 1.77116938 0.63822766
[19,] -0.29225872 1.77116938
[20,] 0.12918870 -0.29225872
[21,] -2.83782380 0.12918870
[22,] 1.71141988 -2.83782380
[23,] 0.37045475 1.71141988
[24,] -0.58330491 0.37045475
[25,] 1.71880905 -0.58330491
[26,] 0.71207155 1.71880905
[27,] -2.24850776 0.71207155
[28,] -0.49764610 -2.24850776
[29,] 2.63573874 -0.49764610
[30,] -0.10686805 2.63573874
[31,] 1.83392747 -0.10686805
[32,] 0.39144607 1.83392747
[33,] 0.98254352 0.39144607
[34,] -0.47305726 0.98254352
[35,] -0.54825277 -0.47305726
[36,] 1.36827487 -0.54825277
[37,] -0.28260202 1.36827487
[38,] -3.38120381 -0.28260202
[39,] 1.62708275 -3.38120381
[40,] 1.90081291 1.62708275
[41,] 1.90081291 1.90081291
[42,] 0.77723687 1.90081291
[43,] -1.93320874 0.77723687
[44,] -0.91839354 -1.93320874
[45,] -1.10473571 -0.91839354
[46,] 1.37567596 -1.10473571
[47,] 1.95237971 1.37567596
[48,] -0.61973192 1.95237971
[49,] -0.54335252 -0.61973192
[50,] 0.02678476 -0.54335252
[51,] -0.21833908 0.02678476
[52,] 3.82132820 -0.21833908
[53,] 0.42145154 3.82132820
[54,] 0.96147472 0.42145154
[55,] 1.57004171 0.96147472
[56,] 1.45651560 1.57004171
[57,] 0.62271329 1.45651560
[58,] 0.65369530 0.62271329
[59,] 0.24542637 0.65369530
[60,] 2.95468310 0.24542637
[61,] -0.04328174 2.95468310
[62,] 3.46054793 -0.04328174
[63,] -1.84270740 3.46054793
[64,] -1.99723930 -1.84270740
[65,] -1.23892023 -1.99723930
[66,] -0.30262651 -1.23892023
[67,] -0.74615161 -0.30262651
[68,] -0.37465288 -0.74615161
[69,] 0.15321276 -0.37465288
[70,] 0.39564965 0.15321276
[71,] 3.55639736 0.39564965
[72,] 0.76780063 3.55639736
[73,] -1.60591132 0.76780063
[74,] -1.47805754 -1.60591132
[75,] 0.87426639 -1.47805754
[76,] -6.09158810 0.87426639
> z <- as.data.frame(dum1)
> z
lag(myerror, k = 1) myerror
1 -0.21934185 -1.78875001
2 0.26242144 -0.21934185
3 -0.64927512 0.26242144
4 -2.01828474 -0.64927512
5 -4.85536860 -2.01828474
6 -2.81528636 -4.85536860
7 -1.68571212 -2.81528636
8 1.96653160 -1.68571212
9 -0.33571471 1.96653160
10 -1.47773012 -0.33571471
11 0.27471917 -1.47773012
12 0.17097379 0.27471917
13 0.29659329 0.17097379
14 -0.43391507 0.29659329
15 -0.62305316 -0.43391507
16 0.50235390 -0.62305316
17 0.63822766 0.50235390
18 1.77116938 0.63822766
19 -0.29225872 1.77116938
20 0.12918870 -0.29225872
21 -2.83782380 0.12918870
22 1.71141988 -2.83782380
23 0.37045475 1.71141988
24 -0.58330491 0.37045475
25 1.71880905 -0.58330491
26 0.71207155 1.71880905
27 -2.24850776 0.71207155
28 -0.49764610 -2.24850776
29 2.63573874 -0.49764610
30 -0.10686805 2.63573874
31 1.83392747 -0.10686805
32 0.39144607 1.83392747
33 0.98254352 0.39144607
34 -0.47305726 0.98254352
35 -0.54825277 -0.47305726
36 1.36827487 -0.54825277
37 -0.28260202 1.36827487
38 -3.38120381 -0.28260202
39 1.62708275 -3.38120381
40 1.90081291 1.62708275
41 1.90081291 1.90081291
42 0.77723687 1.90081291
43 -1.93320874 0.77723687
44 -0.91839354 -1.93320874
45 -1.10473571 -0.91839354
46 1.37567596 -1.10473571
47 1.95237971 1.37567596
48 -0.61973192 1.95237971
49 -0.54335252 -0.61973192
50 0.02678476 -0.54335252
51 -0.21833908 0.02678476
52 3.82132820 -0.21833908
53 0.42145154 3.82132820
54 0.96147472 0.42145154
55 1.57004171 0.96147472
56 1.45651560 1.57004171
57 0.62271329 1.45651560
58 0.65369530 0.62271329
59 0.24542637 0.65369530
60 2.95468310 0.24542637
61 -0.04328174 2.95468310
62 3.46054793 -0.04328174
63 -1.84270740 3.46054793
64 -1.99723930 -1.84270740
65 -1.23892023 -1.99723930
66 -0.30262651 -1.23892023
67 -0.74615161 -0.30262651
68 -0.37465288 -0.74615161
69 0.15321276 -0.37465288
70 0.39564965 0.15321276
71 3.55639736 0.39564965
72 0.76780063 3.55639736
73 -1.60591132 0.76780063
74 -1.47805754 -1.60591132
75 0.87426639 -1.47805754
76 -6.09158810 0.87426639
> 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/7j4881292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/8j4881292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
> grid()
> dev.off()
null device
1
> postscript(file="/var/www/html/rcomp/tmp/9uv7t1292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
> opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
> plot(mylm, las = 1, sub='Residual Diagnostics')
> par(opar)
> dev.off()
null device
1
> if (n > n25) {
+ postscript(file="/var/www/html/rcomp/tmp/10uv7t1292268190.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
+ plot(kp3:nmkm3,gqarr[,2], main='Goldfeld-Quandt test',ylab='2-sided p-value',xlab='breakpoint')
+ grid()
+ dev.off()
+ }
null device
1
>
> #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab
> load(file="/var/www/html/rcomp/createtable")
>
> a<-table.start()
> a<-table.row.start(a)
> a<-table.element(a, 'Multiple Linear Regression - Estimated Regression Equation', 1, TRUE)
> a<-table.row.end(a)
> myeq <- colnames(x)[1]
> myeq <- paste(myeq, '[t] = ', sep='')
> for (i in 1:k){
+ if (mysum$coefficients[i,1] > 0) myeq <- paste(myeq, '+', '')
+ myeq <- paste(myeq, mysum$coefficients[i,1], sep=' ')
+ if (rownames(mysum$coefficients)[i] != '(Intercept)') {
+ myeq <- paste(myeq, rownames(mysum$coefficients)[i], sep='')
+ if (rownames(mysum$coefficients)[i] != 't') myeq <- paste(myeq, '[t]', sep='')
+ }
+ }
> myeq <- paste(myeq, ' + e[t]')
> a<-table.row.start(a)
> a<-table.element(a, myeq)
> a<-table.row.end(a)
> a<-table.end(a)
> table.save(a,file="/var/www/html/rcomp/tmp/11xw6h1292268190.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/12iem41292268190.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/13xokv1292268190.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/1407111292268190.tab")
> if (n > n25) {
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'p-values',header=TRUE)
+ a<-table.element(a,'Alternative Hypothesis',3,header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'breakpoint index',header=TRUE)
+ a<-table.element(a,'greater',header=TRUE)
+ a<-table.element(a,'2-sided',header=TRUE)
+ a<-table.element(a,'less',header=TRUE)
+ a<-table.row.end(a)
+ for (mypoint in kp3:nmkm3) {
+ a<-table.row.start(a)
+ a<-table.element(a,mypoint,header=TRUE)
+ a<-table.element(a,gqarr[mypoint-kp3+1,1])
+ a<-table.element(a,gqarr[mypoint-kp3+1,2])
+ a<-table.element(a,gqarr[mypoint-kp3+1,3])
+ a<-table.row.end(a)
+ }
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/153ph71292268190.tab")
+ a<-table.start()
+ a<-table.row.start(a)
+ a<-table.element(a,'Meta Analysis of Goldfeld-Quandt test for Heteroskedasticity',4,TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'Description',header=TRUE)
+ a<-table.element(a,'# significant tests',header=TRUE)
+ a<-table.element(a,'% significant tests',header=TRUE)
+ a<-table.element(a,'OK/NOK',header=TRUE)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'1% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant1)
+ a<-table.element(a,numsignificant1/numgqtests)
+ if (numsignificant1/numgqtests < 0.01) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'5% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant5)
+ a<-table.element(a,numsignificant5/numgqtests)
+ if (numsignificant5/numgqtests < 0.05) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.row.start(a)
+ a<-table.element(a,'10% type I error level',header=TRUE)
+ a<-table.element(a,numsignificant10)
+ a<-table.element(a,numsignificant10/numgqtests)
+ if (numsignificant10/numgqtests < 0.1) dum <- 'OK' else dum <- 'NOK'
+ a<-table.element(a,dum)
+ a<-table.row.end(a)
+ a<-table.end(a)
+ table.save(a,file="/var/www/html/rcomp/tmp/1677fv1292268190.tab")
+ }
>
> try(system("convert tmp/1sxi61292268190.ps tmp/1sxi61292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/237hr1292268190.ps tmp/237hr1292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/337hr1292268190.ps tmp/337hr1292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/437hr1292268190.ps tmp/437hr1292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/58drn1292268190.ps tmp/58drn1292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/68drn1292268190.ps tmp/68drn1292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/7j4881292268190.ps tmp/7j4881292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/8j4881292268190.ps tmp/8j4881292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/9uv7t1292268190.ps tmp/9uv7t1292268190.png",intern=TRUE))
character(0)
> try(system("convert tmp/10uv7t1292268190.ps tmp/10uv7t1292268190.png",intern=TRUE))
character(0)
>
>
> proc.time()
user system elapsed
2.723 1.665 7.773