Home » date » 2007 » Nov » 15 » attachments

Workshop 6, question 3

R Software Module: rwasp_multipleregression.wasp (opens new window with default values)
Title produced by software: Multiple Regression
Date of computation: Thu, 15 Nov 2007 08:41:05 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro.htm/, Retrieved Thu, 15 Nov 2007 16:38:32 +0100
 
User-defined keywords:
Workshop 6, question 3, eigen model, lineair, seasonality, war iraq, oorlog irak
 
Dataseries X:
» Textbox « » Textfile « » CSV «
108.4 106.7 0 117 100.6 0 103.8 101.2 0 100.8 93.1 0 110.6 84.2 0 104 85.8 0 112.6 91.8 1 107.3 92.4 1 98.9 80.3 1 109.8 79.7 1 104.9 62.5 1 102.2 57.1 1 123.9 100.8 1 124.9 100.7 1 112.7 86.2 1 121.9 83.2 1 100.6 71.7 1 104.3 77.5 1 120.4 89.8 1 107.5 80.3 1 102.9 78.7 1 125.6 93.8 1 107.5 57.6 1 108.8 60.6 1 128.4 91 1 121.1 85.3 1 119.5 77.4 1 128.7 77.3 1 108.7 68.3 1 105.5 69.9 1 119.8 81.7 1 111.3 75.1 1 110.6 69.9 1 120.1 84 1 97.5 54.3 1 107.7 60 1 127.3 89.9 1 117.2 77 1 119.8 85.3 1 116.2 77.6 1 111 69.2 1 112.4 75.5 1 130.6 85.7 1 109.1 72.2 1 118.8 79.9 1 123.9 85.3 1 101.6 52.2 1 112.8 61.2 1 128 82.4 1 129.6 85.4 1 125.8 78.2 1 119.5 70.2 1 115.7 70.2 1 113.6 69.3 1 129.7 77.5 1 112 66.1 1 116.8 69 1 126.3 75.3 1 112.9 58.2 1 115.9 59.7 1
 
Text written by user:
 
Output produced by software:

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!


Summary of compuational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Multiple Linear Regression - Estimated Regression Equation
Y[t] = + 40.9669725515544 + 0.362886468119393X[t] -10.2431896256701Z[t] + 24.1331561763916M1[t] + 20.5212629928483M2[t] + 18.7260702690305M3[t] + 13.2450227500879M4[t] + 8.92253073784375M5[t] + 12.5941839304749M6[t] + 19.3210338289674M7[t] + 16.3220050747697M8[t] + 14.9020708358594M9[t] + 19.0724885897504M10[t] -1.38884984263954M11[t] -0.298127595988762t + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)40.966972551554413.1921713.10540.0032840.001642
X0.3628864681193930.1323682.74150.0087430.004372
Z-10.24318962567012.36306-4.33478.1e-054.1e-05
M124.13315617639163.5893856.723500
M220.52126299284833.469375.91500
M318.72607026903053.0722366.095300
M413.24502275008793.1211114.24370.0001085.4e-05
M58.922530737843752.8066743.1790.0026730.001337
M612.59418393047492.7923244.51034.6e-052.3e-05
M719.32103382896743.3511915.76541e-060
M816.32200507476972.769035.894500
M914.90207083585942.7668365.3863e-061e-06
M1019.07248858975043.1946215.970200
M11-1.388849842639542.822796-0.4920.6251020.312551
t-0.2981275959887620.048477-6.149900


Multiple Linear Regression - Regression Statistics
Multiple R0.954063310173485
R-squared0.910236799819187
Adjusted R-squared0.882310470874045
F-TEST (value)32.5942160749894
F-TEST (DF numerator)14
F-TEST (DF denominator)45
p-value0
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation4.3678245805265
Sum Squared Residuals858.505120481318


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
1106.7104.1388942760992.56110572390075
2100.6103.349697122394-2.74969712239422
3101.296.46627542341164.7337245765884
493.189.59844090412213.50155909587789
584.288.5341086834592-4.33410868345921
685.889.5125835905136-3.7125835905136
791.888.8189398931742.98106010682603
892.483.59848526195488.80151473804521
980.378.83217709485281.46782290514721
1079.786.6599297552564-6.95992975525638
1162.564.1223200330927-1.62232003309268
1257.164.2332488158211-7.13324881582111
13100.895.94291375441474.85708624558527
14100.792.39577944300218.30422055699788
1586.285.8752442121390.324755787861091
1683.283.434624603906-0.234624603905994
1771.771.084523224730.615476775269983
1877.575.80072875341411.69927124658586
1989.888.071923192641.72807680735990
2080.380.09353140371350.206468596286468
2178.776.70619181546521.99380818453478
2293.888.81600479967764.98399520032236
2357.661.488293698338-3.88829369833796
2460.663.050768353544-2.45076835354396
259193.9983717090869-2.99837170908686
2685.387.4392797122833-2.1392797122833
2777.484.7653410434857-7.36534104348565
2877.382.3247214352527-5.02472143525272
2968.370.446372464632-2.14637246463196
3069.972.6586613632923-2.75866136329226
3181.784.2766601599033-2.57666015990331
3275.177.894968830702-2.79496883070208
3369.975.9228864681194-6.02288646811939
348483.24259807315580.757401926844173
3554.354.28189786527890.0181021347211149
366059.07406208674750.925937913252518
3789.990.0216654422904-0.121665442290369
387782.4464913347525-5.44649133475252
3985.381.29667583205634.00332416794368
4077.674.21110943189523.38889056810483
4169.267.70348018944141.49651981055859
4275.571.5850468414513.91495315854907
4385.784.61830286372761.08169713627240
4472.273.5190874489743-1.31908744897426
4579.975.32102435483334.57897564516673
4685.381.04403550014444.25596449985562
4752.252.19220123270320.00779876729676343
4861.257.34725192229123.85274807770877
4982.486.6981548181088-4.2981548181088
5085.483.36875238756782.03124761243216
5178.279.8964634889075-1.69646348890752
5270.271.831103624824-1.63110362482401
5370.265.83151543773744.36848456226259
5469.368.4429794513290.85702054867094
5577.580.714173890555-3.21417389055501
5666.170.9939270546553-4.89392705465535
576971.0177202667293-2.01772026672934
5875.378.3374318717658-3.03743187176577
5958.252.71528717058725.48471282941276
6059.754.89466882159624.80533117840379
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/1xtb31195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/1xtb31195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/2ahw21195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/2ahw21195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/3b7mq1195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/3b7mq1195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/45yg21195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/45yg21195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/5m6mg1195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/5m6mg1195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/6rq6c1195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/6rq6c1195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/7mu3v1195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/7mu3v1195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/82q2o1195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/82q2o1195141260.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/98e1t1195141260.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195141099w8q13uwafpv7oro/98e1t1195141260.ps (open in new window)


 
Parameters:
par1 = 2 ; par2 = Include Monthly Dummies ; par3 = Linear Trend ;
 
R code (references can be found in the software module):
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
k <- length(x[1,])
df <- as.data.frame(x)
(mylm <- lm(df))
(mysum <- summary(mylm))
bitmap(file='test0.png')
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()
bitmap(file='test1.png')
plot(mysum$resid, type='b', pch=19, main='Residuals', ylab='value of Residuals', xlab='time or index')
grid()
dev.off()
bitmap(file='test2.png')
hist(mysum$resid, main='Residual Histogram', xlab='values of Residuals')
grid()
dev.off()
bitmap(file='test3.png')
densityplot(~mysum$resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
dev.off()
bitmap(file='test4.png')
qqnorm(mysum$resid, main='Residual Normal Q-Q Plot')
grid()
dev.off()
(myerror <- as.ts(mysum$resid))
bitmap(file='test5.png')
dum <- cbind(lag(myerror,k=1),myerror)
dum
dum1 <- dum[2:length(myerror),]
dum1
z <- as.data.frame(dum1)
z
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()
bitmap(file='test6.png')
acf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Autocorrelation Function')
grid()
dev.off()
bitmap(file='test7.png')
pacf(mysum$resid, lag.max=length(mysum$resid)/2, main='Residual Partial Autocorrelation Function')
grid()
dev.off()
bitmap(file='test8.png')
opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
plot(mylm, las = 1, sub='Residual Diagnostics')
par(opar)
dev.off()
load(file='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='mytable1.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<br />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='mytable2.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='mytable3.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<br />Forecast', 1, TRUE)
a<-table.element(a, 'Residuals<br />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='mytable4.tab')
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by