# NOT RUN {
data(Jevons)
# show as tables
xtabs(frequency ~ estimated+actual, data=Jevons)
xtabs(frequency ~ error+actual, data=Jevons)
# show as sunflowerplot with regression line
with(Jevons, sunflowerplot(actual, estimated, frequency,
main="Jevons data on numerical estimation"))
Jmod <-lm(estimated ~ actual, data=Jevons, weights=frequency)
abline(Jmod)
# show as balloonplots
if (require(gplots)) {
with(Jevons, balloonplot(actual, estimated, frequency, xlab="actual", ylab="estimated",
main="Jevons data on numerical estimation\nBubble area proportional to frequency",
text.size=0.8))
with(Jevons, balloonplot(actual, error, frequency, xlab="actual", ylab="error",
main="Jevons data on numerical estimation: Errors\nBubble area proportional to frequency",
text.size=0.8))
}
# plot average error
if(require(reshape)) {
unJevons <- untable(Jevons, Jevons$frequency)
str(unJevons)
require(plyr)
mean_error <- function(df) mean(df$error, na.rm=TRUE)
Jmean <- ddply(unJevons, .(actual), mean_error)
with(Jmean, plot(actual, V1, ylab='Mean error', xlab='Actual number', type='b', main='Jevons data'))
abline(h=0)
}
# }
Run the code above in your browser using DataLab