modelsPredictionAndPlot

This report just show the plotting of prediction and real datavalues

library(RSNNS)
library(lattice)
# make a function to plot the real and predict values based on different
# models and different matrix
predictAndPlot <- function(x) {
    predAndReal <- timeDifTestData[, c("realO3", "lmFit", "svmFit", "rfFit", 
        "nnetFit", "greedyFit", "linearFit")]
    predAndReal <- cbind(time = rep(x, nrow(predAndReal)), predAndReal)
    predAndRealReshape <- reshape(predAndReal, times = names(predAndReal[, c(3:8)]), 
        timevar = "model", varying = list(names(predAndReal[, 3:8])), v.names = "pred", 
        direction = "long")
    xyplot(realO3 ~ pred | model, data = predAndRealReshape, xlim = c(0, 0.7), 
        ylim = c(0, 0.7), main = paste("Matrix", x, "Testing"))
}
# make a function to plot prediction and real ozone values against index
library(lattice)
plotFun <- function(model, matrix) {
    database <- timeDifTestData[, c("realO3", model)]
    d <- reshape(database, times = names(database[, c(1:2)]), timevar = "realOrPred", 
        varying = list(names(database[, 1:2])), v.names = "value", direction = "long")
    xyplot(value ~ id, group = realOrPred, data = d, type = "l", ylab = "Daily Maximum Ozone", 
        xlab = "", main = paste(matrix, "test data", model), auto.key = list(space = "right"))
}
# make a function to plot the histogram and Q-Q plot of residuals
# different models based on different matrixs
library(car)
histRes <- function(model, matrix) {
    residuals <- timeDifTestData[, c("realO3")] - timeDifTestData[, c(model)]
    stRes <- residuals/sd(residuals)
    hist(stRes, col = "blue", main = paste("Histogram of standardized residuals based on  model", 
        model, matrix), breaks = 15)
    lines(density(stRes))
    rug(jitter(stRes))
    qqPlot(stRes, main = paste("Normal QQ plot of standardized residuals", model, 
        matrix))
}
# make a function to plot the standardized residuals against index
plotStaRes <- function(model, matrix) {
    residuals <- timeDifTestData[, c("realO3")] - timeDifTestData[, c(model)]
    stRes <- residuals/sd(residuals)
    plot(stRes, col = "red", main = paste("residuals plot based on model", model, 
        matrix), ylab = "standardized residuals")
    abline(h = 0)
}

load("~/HORA12/timeDifTestData.RData")
predictAndPlot(12)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

plotFun("rfFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

plotFun("svmFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

plotFun("nnetFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

plotFun("linearFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

plotFun("greedyFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

histRes("lmFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot plot of chunk modelsPredictionAndPlot

plotStaRes("lmFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

histRes("svmFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot plot of chunk modelsPredictionAndPlot

plotStaRes("svmFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

histRes("rfFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot plot of chunk modelsPredictionAndPlot

plotStaRes("rfFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

histRes("nnetFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot plot of chunk modelsPredictionAndPlot

plotStaRes("nnetFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

histRes("linearFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot plot of chunk modelsPredictionAndPlot

plotStaRes("linearFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

histRes("greedyFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot plot of chunk modelsPredictionAndPlot

plotStaRes("greedyFit", "Matrix 12")

plot of chunk modelsPredictionAndPlot

load("~/HORA11/timeDifTestData.RData")
predictAndPlot(11)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 11")

plot of chunk modelsPredictionAndPlot

load("~/HORA10/timeDifTestData.RData")
predictAndPlot(10)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 10")

plot of chunk modelsPredictionAndPlot

load("~/HORA9/timeDifTestData.RData")
predictAndPlot(9)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 9")

plot of chunk modelsPredictionAndPlot

load("~/HORA8/timeDifTestData.RData")
predictAndPlot(8)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 8")

plot of chunk modelsPredictionAndPlot

load("~/HORA7/timeDifTestData.RData")
predictAndPlot(7)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 7")

plot of chunk modelsPredictionAndPlot

load("~/HORA6/timeDifTestData.RData")
predictAndPlot(6)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 6")

plot of chunk modelsPredictionAndPlot

load("~/HORA5/timeDifTestData.RData")
predictAndPlot(5)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 5")

plot of chunk modelsPredictionAndPlot

load("~/HORA4/timeDifTestData.RData")
predictAndPlot(4)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 4")

plot of chunk modelsPredictionAndPlot

load("~/HORA3/timeDifTestData.RData")
predictAndPlot(3)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 3")

plot of chunk modelsPredictionAndPlot

load("~/HORA2/timeDifTestData.RData")
predictAndPlot(2)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 2")

plot of chunk modelsPredictionAndPlot

load("~/HORA1/timeDifTestData.RData")
predictAndPlot(1)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix 1")

plot of chunk modelsPredictionAndPlot

load("~/extendDavg/timeDifTestData.RData")
a <- "davg"
predictAndPlot(a)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix davg")

plot of chunk modelsPredictionAndPlot

load("~/extendDmax/timeDifTestData.RData")
a <- "dmax"
predictAndPlot(a)

plot of chunk modelsPredictionAndPlot

plotFun("lmFit", "Matrix dmax")

plot of chunk modelsPredictionAndPlot