library(Sleuth2)
mlr<-lm(ex1222$Buchanan2000~ex1222$Perot96*ex1222$Gore2000)
for (i in 0:3) {
assign(paste("betaHat", i, sep=""),
summary(mlr)$coeff[i+1,1])
}
x<-sort(ex1222$Perot96)
y<-sort(ex1222$Gore2000)
z1 <- outer(x, y, function(a,b) betaHat0+betaHat1*a+betaHat2*b+betaHat3*a*b)
nrz <- nrow(z)
ncz <- ncol(z)
# Create a function interpolating colors in the range of specified colors
jet.colors <- colorRampPalette( c("blue", "red") )
# Generate the desired number of colors from this palette
nbcol <- 100
color <- jet.colors(nbcol)
# Compute the z-value at the facet centres
zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, …
Run Code Online (Sandbox Code Playgroud)