source('/home/pw/wessanet/cretab')
RC.capture <- function (expression, collapse = NULL) {
resultConn <- textConnection('RC.resultText', open = 'w', local=TRUE)
sink(resultConn)
on.exit(function() {
sink()
close(resultConn)
})
expression
on.exit(NULL)
sink()
close(resultConn)
return(paste(c(RC.resultText, ''), collapse = collapse, sep = ''))
}
RC.texteval <- function (sourceText, collapse = NULL, echo = TRUE) {
sourceConn <- textConnection(sourceText, open = 'r')
on.exit(close(sourceConn))
result <- RC.capture(source(file = sourceConn, local = FALSE, echo = echo, print.eval = TRUE), collapse = collapse)
on.exit(NULL)
close(sourceConn)
res <- ''
for(i in 1:length(result)) {
if (result[i]!='') res <- paste(res,result[i],'
',sep='')
}
return(res)
}
myrfcuid = ''
x <- array(list(6.0,-.10,0.57,1.01,1.68,1.1,0.0,-.5,0.5,7.5,-.99,-.10,0.57,1.01,2.2,1.1,0.0,-.5,7.0,.11,-.99,-.10,0.57,1.7,2.2,1.1,0.0,1.4,-.26,.11,-.99,-.10,2.1,1.7,2.2,1.1,-5.4,-.66,-.26,.11,-.99,0.1,2.1,1.7,2.2,-3.5,.05,-.66,-.26,.11,0.9,0.1,2.1,1.7,1.9,-.27,.05,-.66,-.26,0.0,0.9,0.1,2.1,4.4,.00,-.27,.05,-.66,-.2,0.0,0.9,0.1,4.4,.99,.00,-.27,.05,-1.9,-.2,0.0,0.9,9.5,1.61,.99,.00,-.27,-1.2,-1.9,-.2,0.0,17.7,1.26,1.61,.99,.00,0.6,-1.2,-1.9,-.2,11.5,1.04,1.26,1.61,.99,2.9,0.6,-1.2,-1.9,14.1,1.23,1.04,1.26,1.61,7.8,2.9,0.6,-1.2,7.9,0.94,1.23,1.04,1.26,6.4,7.8,2.9,0.6,6.7,1.45,0.94,1.23,1.04,4.2,6.4,7.8,2.9,4.2,2.39,1.45,0.94,1.23,4.9,4.2,6.4,7.8,2.7,1.63,2.39,1.45,0.94,1.1,4.9,4.2,6.4,7.2,0.91,1.63,2.39,1.45,3.9,1.1,4.9,4.2,9.7,1.24,0.91,1.63,2.39,2.1,3.9,1.1,4.9,9.2,1.39,1.24,0.91,1.63,0.3,2.1,3.9,1.1,6.1,0.50,1.39,1.24,0.91,2.6,0.3,2.1,3.9,3.3,0.75,0.50,1.39,1.24,0.9,2.6,0.3,2.1,-1.0,0.23,0.75,0.50,1.39,-.9,0.9,2.6,0.3,-5.3,0.19,0.23,0.75,0.50,0.4,-.9,0.9,2.6,-.6,0.40,0.19,0.23,0.75,-4.8,0.4,-.9,0.9,-.2,0.15,0.40,0.19,0.23,-4.8,-4.8,0.4,-.9,4.4,1.25,0.15,0.40,0.19,-1.8,-4.8,-4.8,0.4,8.9,1.42,1.25,0.15,0.40,-1.4,-1.8,-4.8,-4.8,12.6,1.51,1.42,1.25,0.15,-.3,-1.4,-1.8,-4.8,8.00,0.72,1.51,1.42,1.25,-.8,-.3,-1.4,-1.8,8.6,0.59,0.72,1.51,1.42,1.0,-.8,-.3,-1.4,6.2,0.32,0.59,0.72,1.51,0.2,1.0,-.8,-.3,1.8,0.54,0.32,0.59,0.72,0.0,0.2,1.0,-.8,5.6,0.22,0.54,0.32,0.59,1.3,0.0,0.2,1.0,5.1,0.06,0.22,0.54,0.32,-.4,1.3,0.0,0.2,8.6,0.61,0.06,0.22,0.54,0.9,-.4,1.3,0.0,8.1,0.31,0.61,0.06,0.22,3.6,0.9,-.4,1.3,2.1,0.03,0.31,0.61,0.06,-.4,3.6,0.9,-.4,7.1,-.01,0.03,0.31,0.61,0.2,-.4,3.6,0.9,-5.4,-.63,-.01,0.03,0.31,-.5,0.2,-.4,3.6,-7.2,-.20,-.63,-.01,0.03,2.0,-.5,0.2,-.4,3.9,1.47,-.20,-.63,-.01,2.0,2.0,-.5,0.2,13.2,1.46,1.47,-.20,-.63,0.8,2.0,2.0,-.5,13.1,1.78,1.46,1.47,-.20,1.5,0.8,2.0,2.0,10.0,1.86,1.78,1.46,1.47,-1.6,1.5,0.8,2.0,10.0,1.20,1.86,1.78,1.46,0.0,-1.6,1.5,0.8,5.0,1.00,1.20,1.86,1.78,-.6,0.0,-1.6,1.5,5.0,-1.26,1.00,1.20,1.86,-.4,-.6,0.0,-1.6,5.0,-.37,-1.26,1.00,1.20,-1.0,-.4,-.6,0.0,4.3,-.30,-.37,-1.26,1.00,0.8,-1.0,-.4,-.6,1.7,1.33,-.30,-.37,-1.26,1.5,0.8,-1.0,-.4,-3.2,-0.10,1.33,-.30,-.37,0.2,1.5,0.8,-1.0,3.4,0.70,-.10,1.33,-.30,0.5,0.2,1.5,0.8,11.0,1.03,0.70,-.10,1.33,1.6,0.5,0.2,1.5,9.0,0.84,1.03,0.70,-.10,0.8,1.6,0.5,0.2,14.4,1.30,0.84,1.03,0.70,1.9,0.8,1.6,0.5,11.6,0.93,1.30,0.84,1.03,3.4,1.9,0.8,1.6,8.5,0.97,0.93,1.30,0.84,0.0,3.4,1.9,0.8,6.2,-.13,0.97,0.93,1.30,1.1,0.0,3.4,1.9,5.4,0.80,-.13,0.97,0.93,0.7,1.1,0.0,3.4,7.7,1.53,0.80,-.13,0.97,0.1,0.7,1.1,0.0,8.7,1.37,1.53,0.80,-.13,-1.6,0.1,0.7,1.1,11.1,1.53,1.37,1.53,0.80,1.2,-1.6,0.1,0.7,10.6,1.47,1.53,1.37,1.53,1.4,1.2,-1.6,0.1,12.9,1.00,1.47,1.53,1.37,0.0,1.4,1.2,-1.6,8.7,1.06,1.00,1.47,1.53,-.1,0.0,1.4,1.2,8.8,2.54,1.06,1.00,1.47,-1.1,-.1,0.0,1.4,6.0,2.66,2.54,1.06,1.00,-.2,-1.1,-.1,0.0,20.0,1.20,2.66,2.54,1.06,-.6,-.2,-1.1,-.1,12.9,0.94,1.20,2.66,2.54,1.9,-.6,-.2,-1.1,14.7,1.86,0.94,1.20,2.66,1.8,1.9,-.6,-.2,20.8,3.00,1.86,0.94,1.20,4.2,1.8,1.9,-.6,21.3,2.90,3.00,1.86,0.94,1.8,4.2,1.8,1.9,11.5,1.84,2.90,3.00,1.86,3.2,1.8,4.2,1.8,10.6,-.54,1.84,2.90,3.00,4.7,3.2,1.8,4.2,14.3,0.50,-.54,1.84,2.90,2.0,4.7,3.2,1.8,5.8,1.70,0.50,-.54,1.84,5.1,2.0,4.7,3.2,7.9,2.40,1.70,0.50,-.54,0.8,5.1,2.0,4.7,17.1,3.87,2.40,1.70,.50,2.7,0.8,5.1,2.0,17.6,2.93,3.87,2.40,1.70,1.6,2.7,0.8,5.1,17.9,2.40,2.93,3.87,2.40,2.3,1.6,2.7,0.8,26.0,3.17,2.40,2.93,3.87,2.8,2.3,1.6,2.7,17.7,3.67,3.17,2.40,2.93,-.2,2.8,2.3,1.6,15.4,4.13,3.67,3.17,2.40,0.0,-.2,2.8,2.3,20.9,3.53,4.13,3.67,3.17,-1.6,0.0,-.2,2.8,16.2,1.60,3.53,4.13,3.67,0.2,-1.6,0.0,-.2,17.9,0.90,1.60,3.53,4.13,1.1,0.2,-1.6,0.0,6.7,1.64,0.90,1.60,3.53,-.5,1.1,0.2,-1.6,10.0,2.16,1.64,0.90,1.60,0.2,-.5,1.1,0.2,14.3,1.54,2.16,1.64,0.90,-2.2,0.2,-.5,1.1,17.3,2.73,1.54,2.16,1.64,-1.6,-2.2,0.2,-.5,22.9,3.77,2.73,1.54,2.16,0.8,-1.6,-2.2,0.2,22.8,3.56,3.77,2.73,1.54,0.8,0.8,-1.6,-2.2,19.6,4.60,3.56,3.77,2.73,-.8,0.8,0.8,-1.6,17.7,3.84,4.60,3.56,3.77,1.6,-.8,0.8,0.8,19.2,2.10,3.84,4.60,3.56,0.8,1.6,-.8,0.8),dim=c(9,96),dimnames=list(c('^QP','^M','^M-1','^M-2','^M-3','^Gf','^Gf-1','^Gf-2','^Gf-3'),1:96))
y <- array(NA,dim=c(9,96),dimnames=list(c('^QP','^M','^M-1','^M-2','^M-3','^Gf','^Gf-1','^Gf-2','^Gf-3'),1:96))
for (i in 1:dim(x)[1])
{
for (j in 1:dim(x)[2])
{
y[i,j] <- as.numeric(x[i,j])
}
}
par6 = '12'
par5 = ''
par4 = ''
par3 = 'No Linear Trend'
par2 = 'Do not include Seasonal Dummies'
par1 = '1'
par6 <- '12'
par5 <- ''
par4 <- ''
par3 <- 'No Linear Trend'
par2 <- 'Do not include Seasonal Dummies'
par1 <- '1'
#'GNU S' R Code compiled by R2WASP v. 1.2.327 (Fri, 21 Jul 2017 20:18:06 +0200)
#Author: root
#To cite this work: Wessa P., (2017), Multiple Regression (v1.0.48) in Free Statistics Software (v$_version), Office for Research Development and Education, URL https://www.wessa.net/rwasp_multipleregression.wasp/
#Source of accompanying publication: Office for Research, Development, and Education
#
library(lattice)
library(lmtest)
library(car)
library(MASS)
n25 <- 25 #minimum number of obs. for Goldfeld-Quandt test
mywarning <- ''
par6 <- as.numeric(par6)
if(is.na(par6)) {
par6 <- 12
mywarning = 'Warning: you did not specify the seasonality. The seasonal period was set to s = 12.'
}
par1 <- as.numeric(par1)
if(is.na(par1)) {
par1 <- 1
mywarning = 'Warning: you did not specify the column number of the endogenous series! The first column was selected by default.'
}
if (par4=='') par4 <- 0
par4 <- as.numeric(par4)
if (!is.numeric(par4)) par4 <- 0
if (par5=='') par5 <- 0
par5 <- as.numeric(par5)
if (!is.numeric(par5)) par5 <- 0
x <- na.omit(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'){
(n <- n -1)
x2 <- array(0, dim=c(n,k), dimnames=list(1:n, paste('(1-B)',colnames(x),sep='')))
for (i in 1:n) {
for (j in 1:k) {
x2[i,j] <- x[i+1,j] - x[i,j]
}
}
x <- x2
}
if (par3 == 'Seasonal Differences (s)'){
(n <- n - par6)
x2 <- array(0, dim=c(n,k), dimnames=list(1:n, paste('(1-Bs)',colnames(x),sep='')))
for (i in 1:n) {
for (j in 1:k) {
x2[i,j] <- x[i+par6,j] - x[i,j]
}
}
x <- x2
}
if (par3 == 'First and Seasonal Differences (s)'){
(n <- n -1)
x2 <- array(0, dim=c(n,k), dimnames=list(1:n, paste('(1-B)',colnames(x),sep='')))
for (i in 1:n) {
for (j in 1:k) {
x2[i,j] <- x[i+1,j] - x[i,j]
}
}
x <- x2
(n <- n - par6)
x2 <- array(0, dim=c(n,k), dimnames=list(1:n, paste('(1-Bs)',colnames(x),sep='')))
for (i in 1:n) {
for (j in 1:k) {
x2[i,j] <- x[i+par6,j] - x[i,j]
}
}
x <- x2
}
if(par4 > 0) {
x2 <- array(0, dim=c(n-par4,par4), dimnames=list(1:(n-par4), paste(colnames(x)[par1],'(t-',1:par4,')',sep='')))
for (i in 1:(n-par4)) {
for (j in 1:par4) {
x2[i,j] <- x[i+par4-j,par1]
}
}
x <- cbind(x[(par4+1):n,], x2)
n <- n - par4
}
if(par5 > 0) {
x2 <- array(0, dim=c(n-par5*par6,par5), dimnames=list(1:(n-par5*par6), paste(colnames(x)[par1],'(t-',1:par5,'s)',sep='')))
for (i in 1:(n-par5*par6)) {
for (j in 1:par5) {
x2[i,j] <- x[i+par5*par6-j*par6,par1]
}
}
x <- cbind(x[(par5*par6+1):n,], x2)
n <- n - par5*par6
}
if (par2 == 'Include Seasonal Dummies'){
x2 <- array(0, dim=c(n,par6-1), dimnames=list(1:n, paste('M', seq(1:(par6-1)), sep ='')))
for (i in 1:(par6-1)){
x2[seq(i,n,par6),i] <- 1
}
x <- cbind(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[n,]))
if (par3 == 'Linear Trend'){
x <- cbind(x, c(1:n))
colnames(x)[k+1] <- 't'
}
print(x)
(k <- length(x[n,]))
head(x)
df <- as.data.frame(x)
(mylm <- lm(df))
(mysum <- summary(mylm))
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
}
postscript(file="/home/pw/wessanet/rcomp/tmp/1fwco1586637023.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()
postscript(file="/home/pw/wessanet/rcomp/tmp/2ot9n1586637023.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()
postscript(file="/home/pw/wessanet/rcomp/tmp/353bm1586637023.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
sresid <- studres(mylm)
hist(sresid, freq=FALSE, main='Distribution of Studentized Residuals')
xfit<-seq(min(sresid),max(sresid),length=40)
yfit<-dnorm(xfit)
lines(xfit, yfit)
grid()
dev.off()
postscript(file="/home/pw/wessanet/rcomp/tmp/4wbtq1586637023.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()
postscript(file="/home/pw/wessanet/rcomp/tmp/5oj751586637023.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
qqPlot(mylm, main='QQ Plot')
grid()
dev.off()
(myerror <- as.ts(mysum$resid))
postscript(file="/home/pw/wessanet/rcomp/tmp/6pdgz1586637023.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556)
dum <- cbind(lag(myerror,k=1),myerror)
dum
dum1 <- dum[2:length(myerror),]
dum1
z <- as.data.frame(dum1)
print(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()
postscript(file="/home/pw/wessanet/rcomp/tmp/7ecqj1586637023.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()
postscript(file="/home/pw/wessanet/rcomp/tmp/84sql1586637023.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()
postscript(file="/home/pw/wessanet/rcomp/tmp/9or8w1586637023.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()
if (n > n25) {
postscript(file="/home/pw/wessanet/rcomp/tmp/10z29e1586637023.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()
}
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, signif(mysum$coefficients[i,1],6), 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.row.start(a)
a<-table.element(a, mywarning)
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/home/pw/wessanet/rcomp/tmp/11t6dw1586637023.tab")
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'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,formatC(signif(mysum$coefficients[i,1],5),format='g',flag='+'))
a<-table.element(a,formatC(signif(mysum$coefficients[i,2],5),format='g',flag=' '))
a<-table.element(a,formatC(signif(mysum$coefficients[i,3],4),format='e',flag='+'))
a<-table.element(a,formatC(signif(mysum$coefficients[i,4],4),format='g',flag=' '))
a<-table.element(a,formatC(signif(mysum$coefficients[i,4]/2,4),format='g',flag=' '))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/home/pw/wessanet/rcomp/tmp/12zo0q1586637023.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,formatC(signif(sqrt(mysum$r.squared),6),format='g',flag=' '))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'R-squared',1,TRUE)
a<-table.element(a,formatC(signif(mysum$r.squared,6),format='g',flag=' '))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'Adjusted R-squared',1,TRUE)
a<-table.element(a,formatC(signif(mysum$adj.r.squared,6),format='g',flag=' '))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'F-TEST (value)',1,TRUE)
a<-table.element(a,formatC(signif(mysum$fstatistic[1],6),format='g',flag=' '))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'F-TEST (DF numerator)',1,TRUE)
a<-table.element(a, signif(mysum$fstatistic[2],6))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'F-TEST (DF denominator)',1,TRUE)
a<-table.element(a, signif(mysum$fstatistic[3],6))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'p-value',1,TRUE)
a<-table.element(a,formatC(signif(1-pf(mysum$fstatistic[1],mysum$fstatistic[2],mysum$fstatistic[3]),6),format='g',flag=' '))
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,formatC(signif(mysum$sigma,6),format='g',flag=' '))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, 'Sum Squared Residuals',1,TRUE)
a<-table.element(a,formatC(signif(sum(myerror*myerror),6),format='g',flag=' '))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file="/home/pw/wessanet/rcomp/tmp/13zayg1586637023.tab")
myr <- as.numeric(mysum$resid)
myr
a <-table.start()
a <- table.row.start(a)
a <- table.element(a,'Menu of Residual Diagnostics',2,TRUE)
a <- table.row.end(a)
a <- table.row.start(a)
a <- table.element(a,'Description',1,TRUE)
a <- table.element(a,'Link',1,TRUE)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Histogram',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_histogram.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Central Tendency',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_centraltendency.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'QQ Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_fitdistrnorm.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Kernel Density Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_density.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Skewness/Kurtosis Test',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_skewness_kurtosis.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Skewness-Kurtosis Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_skewness_kurtosis_plot.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Harrell-Davis Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_harrell_davis.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Bootstrap Plot -- Central Tendency',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_bootstrapplot1.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Blocked Bootstrap Plot -- Central Tendency',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_bootstrapplot.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'(Partial) Autocorrelation Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_autocorrelation.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Spectral Analysis',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_spectrum.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Tukey lambda PPCC Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_tukeylambda.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <-table.element(a,'Box-Cox Normality Plot',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_boxcoxnorm.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a <- table.row.start(a)
a <- table.element(a,'Summary Statistics',1,header=TRUE)
a <- table.element(a,hyperlink( paste('https://supernova.wessa.net/rwasp_summary1.wasp?convertgetintopost=1&data=',paste(as.character(mysum$resid),sep='',collapse=' '),sep='') ,'Compute','Click here to examine the Residuals.'),1)
a <- table.row.end(a)
a<-table.end(a)
table.save(a,file="/home/pw/wessanet/rcomp/tmp/14ssdi1586637023.tab")
if(n < 200) {
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,formatC(signif(x[i],6),format='g',flag=' '))
a<-table.element(a,formatC(signif(x[i]-mysum$resid[i],6),format='g',flag=' '))
a<-table.element(a,formatC(signif(mysum$resid[i],6),format='g',flag=' '))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/home/pw/wessanet/rcomp/tmp/15nt0w1586637023.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,formatC(signif(gqarr[mypoint-kp3+1,1],6),format='g',flag=' '))
a<-table.element(a,formatC(signif(gqarr[mypoint-kp3+1,2],6),format='g',flag=' '))
a<-table.element(a,formatC(signif(gqarr[mypoint-kp3+1,3],6),format='g',flag=' '))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file="/home/pw/wessanet/rcomp/tmp/16ujk61586637023.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,signif(numsignificant1,6))
a<-table.element(a,formatC(signif(numsignificant1/numgqtests,6),format='g',flag=' '))
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,signif(numsignificant5,6))
a<-table.element(a,signif(numsignificant5/numgqtests,6))
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,signif(numsignificant10,6))
a<-table.element(a,signif(numsignificant10/numgqtests,6))
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="/home/pw/wessanet/rcomp/tmp/17696z1586637023.tab")
}
}
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Ramsey RESET F-Test for powers (2 and 3) of fitted values',1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
reset_test_fitted <- resettest(mylm,power=2:3,type='fitted')
a<-table.element(a,paste('
',RC.texteval('reset_test_fitted'),'',sep='')) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Ramsey RESET F-Test for powers (2 and 3) of regressors',1,TRUE) a<-table.row.end(a) a<-table.row.start(a) reset_test_regressors <- resettest(mylm,power=2:3,type='regressor') a<-table.element(a,paste('
',RC.texteval('reset_test_regressors'),'',sep='')) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Ramsey RESET F-Test for powers (2 and 3) of principal components',1,TRUE) a<-table.row.end(a) a<-table.row.start(a) reset_test_principal_components <- resettest(mylm,power=2:3,type='princomp') a<-table.element(a,paste('
',RC.texteval('reset_test_principal_components'),'',sep='')) a<-table.row.end(a) a<-table.end(a) table.save(a,file="/home/pw/wessanet/rcomp/tmp/18kf9v1586637023.tab") a<-table.start() a<-table.row.start(a) a<-table.element(a,'Variance Inflation Factors (Multicollinearity)',1,TRUE) a<-table.row.end(a) a<-table.row.start(a) vif <- vif(mylm) a<-table.element(a,paste('
',RC.texteval('vif'),'',sep='')) a<-table.row.end(a) a<-table.end(a) table.save(a,file="/home/pw/wessanet/rcomp/tmp/19717t1586637023.tab") try(system("convert /home/pw/wessanet/rcomp/tmp/1fwco1586637023.ps /home/pw/wessanet/rcomp/tmp/1fwco1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/2ot9n1586637023.ps /home/pw/wessanet/rcomp/tmp/2ot9n1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/353bm1586637023.ps /home/pw/wessanet/rcomp/tmp/353bm1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/4wbtq1586637023.ps /home/pw/wessanet/rcomp/tmp/4wbtq1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/5oj751586637023.ps /home/pw/wessanet/rcomp/tmp/5oj751586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/6pdgz1586637023.ps /home/pw/wessanet/rcomp/tmp/6pdgz1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/7ecqj1586637023.ps /home/pw/wessanet/rcomp/tmp/7ecqj1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/84sql1586637023.ps /home/pw/wessanet/rcomp/tmp/84sql1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/9or8w1586637023.ps /home/pw/wessanet/rcomp/tmp/9or8w1586637023.png",intern=TRUE)) try(system("convert /home/pw/wessanet/rcomp/tmp/10z29e1586637023.ps /home/pw/wessanet/rcomp/tmp/10z29e1586637023.png",intern=TRUE))