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 05:19:38 -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/t1195128846fa3o30aiwajf4b2.htm/, Retrieved Thu, 15 Nov 2007 13:14:19 +0100
 
User-defined keywords:
Workshop 6, question 3, Workshop 6, question 3, multiple lineair regression, seasonality
 
Dataseries X:
» Textbox « » Textfile « » CSV «
108.4 106.7 117 100.6 103.8 101.2 100.8 93.1 110.6 84.2 104 85.8 112.6 91.8 107.3 92.4 98.9 80.3 109.8 79.7 104.9 62.5 102.2 57.1 123.9 100.8 124.9 100.7 112.7 86.2 121.9 83.2 100.6 71.7 104.3 77.5 120.4 89.8 107.5 80.3 102.9 78.7 125.6 93.8 107.5 57.6 108.8 60.6 128.4 91 121.1 85.3 119.5 77.4 128.7 77.3 108.7 68.3 105.5 69.9 119.8 81.7 111.3 75.1 110.6 69.9 120.1 84 97.5 54.3 107.7 60 127.3 89.9 117.2 77 119.8 85.3 116.2 77.6 111 69.2 112.4 75.5 130.6 85.7 109.1 72.2 118.8 79.9 123.9 85.3 101.6 52.2 112.8 61.2 128 82.4 129.6 85.4 125.8 78.2 119.5 70.2 115.7 70.2 113.6 69.3 129.7 77.5 112 66.1 116.8 69 126.3 75.3 112.9 58.2 115.9 59.7
 
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] = + 108.556757497134 -0.44607926102607X[t] + 40.5602074612777M1[t] + 35.6470691776054M2[t] + 28.9911821454183M3[t] + 24.101869332547M4[t] + 12.9286273182358M5[t] + 15.2019595232404M6[t] + 31.4414814898826M7[t] + 17.4821568295589M8[t] + 15.8935295113231M9[t] + 29.101284183564M10[t] -4.81196460071992M11[t] + e[t]


Multiple Linear Regression - Ordinary Least Squares
VariableParameterS.D.T-STAT
H0: parameter = 0
2-tail p-value1-tail p-value
(Intercept)108.55675749713416.2176216.693800
X-0.446079261026070.145379-3.06840.0035670.001783
M140.56020746127774.8331128.392200
M235.64706917760544.7615487.486400
M328.99118214541834.5132446.423600
M424.1018693325474.5511525.29583e-062e-06
M512.92862731823584.4023972.93670.0051230.002561
M615.20195952324044.4078783.44880.0011980.000599
M731.44148148988264.7989286.551800
M817.48215682955894.402343.97110.0002440.000122
M915.89352951132314.402373.61020.0007410.00037
M1029.1012841835644.7174126.168900
M11-4.811964600719924.452839-1.08070.2853660.142683


Multiple Linear Regression - Regression Statistics
Multiple R0.87286876382315
R-squared0.761899878858152
Adjusted R-squared0.701108358566617
F-TEST (value)12.532995970562
F-TEST (DF numerator)12
F-TEST (DF denominator)47
p-value6.69052591106833e-11
Multiple Linear Regression - Residual Statistics
Residual Standard Deviation6.96070391037835
Sum Squared Residuals2277.21574961396


Multiple Linear Regression - Actuals, Interpolation, and Residuals
Time or IndexActualsInterpolation
Forecast
Residuals
Prediction Error
1106.7100.7619730631865.93802693681423
2100.692.01255313468938.5874468653107
3101.291.24491234804649.9550876519536
493.187.69383731825335.4061626817467
584.272.149018545886612.0509814541133
685.877.36647387366328.43352612633676
791.889.76971419548122.03028580451877
892.478.174609618595814.2253903814042
980.380.3330480929789-0.0330480929789354
1079.788.6785388200356-8.9785388200356
1162.556.95107841477955.54892158522053
1257.162.9674570202698-5.8674570202698
13100.893.84774451728186.95225548271823
14100.788.488526972583412.2114730274167
1586.287.2748069249144-1.07480692491437
1683.278.28156491060324.91843508939681
1771.776.6098111561473-4.90981115614733
1877.577.23265009535540.267349904644579
1989.886.29029595947793.50970404052213
2080.378.08539376639062.21460623360942
2178.778.54873104887470.151268951125325
2293.881.630486495823712.1695135041763
2357.655.79127233611171.80872766388830
2460.660.02333389749770.576666102502276
259191.8403878426645-0.840387842664454
2685.390.1836281644824-4.88362816448243
2777.484.2414679499371-6.8414679499371
2877.375.24822593562592.05177406437407
2968.372.9965691418362-4.69656914183617
3069.976.6973549821241-6.79735498212413
3181.786.5579435160935-4.85794351609352
3275.176.3902925744915-1.29029257449151
3369.975.113920738974-5.21392073897393
348484.0839224314671-0.0839224314671194
3554.360.2520649463724-5.95206494637241
366060.5140210846264-0.5140210846264
3789.992.3310750297931-2.43107502979313
387791.9233372824841-14.9233372824841
3985.384.10764417162931.19235582837072
4077.680.8242166984518-3.2242166984518
4169.271.9705868414762-2.77058684147619
4275.573.61940808104421.88059191895575
4385.781.7402874970123.95971250298805
4472.277.3716669487489-5.17166694874886
4579.971.45607079856028.44392920143985
4685.382.3888212395682.91117876043194
4752.258.4231399761655-6.22313997616551
4861.258.23901685339342.96098314660656
4982.492.0188195470749-9.61881954707488
5085.486.3919544457608-0.991954445760813
5178.281.4311686054729-3.23116860547286
5270.279.3521551370658-9.15215513706576
5370.269.87401431465370.325985685346336
5469.373.084112967813-3.78411296781297
5577.582.1417588319354-4.64175883193543
5666.176.0780370917733-9.97803709177327
576972.3482293206123-3.3482293206123
5875.381.3182310131055-6.01823101310548
5958.253.38244432657094.81755567342909
6059.756.85617114421262.84382885578738
 
Charts produced by software:
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/1k1bl1195129173.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/1k1bl1195129173.ps (open in new window)


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


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/33a9j1195129173.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/33a9j1195129173.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/4v4z91195129173.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/4v4z91195129173.ps (open in new window)


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


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


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


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/84bhs1195129174.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/84bhs1195129174.ps (open in new window)


http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/9c6xr1195129174.png (open in new window)
http://127.0.0.1/wessadotnet/public_html/freestatisticsdotorg/blog/date/2007/Nov/15/t1195128846fa3o30aiwajf4b2/9c6xr1195129174.ps (open in new window)


 
Parameters:
par1 = 2 ; par2 = Do not include Seasonal Dummies ; par3 = No 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