Select a data source:
dojo.dnd.dragManager.dropTargets = []; // This removes old dropTargets
" "
dum = capture.output({library(lattice)
library(Hmisc)
})
if (!exists("predict.plot"))
source(RpadBaseFile("predict.plot.R"))
data(list = c("hills","Cars93"),
package = c("MASS"))
if (!exists("DATA")) {
a = mtcars
} else {
a = get(DATA)
}
numericVariables = sapply(a, is.numeric)
HTMLon()
variableButtons =
H("span", class="variableButton", dojoType = "rpadchangeabledragvariable",
dragName = ifelse(numericVariables, "num", "other"),
dropsAllowed = "fun",
style = ifelse(numericVariables, "color:darkblue", "color:green"),
varValue = c(names(a), "0"),
collapseContents = FALSE)
H("table",
H("tr",
H("td", "Response: "),
H("td",
H("div", dojoType = "rpaddropzonesingle", class = "dropZone", baseZone = "baseDropZone",
listName = "dropY", dropsAllowed = "num", rpadRun = "all",
style = "min-width:6.2em; width:auto !important; width: 6.2em;",
H(NULL, variableButtons[numericVariables][1]))),
H("td", "Terms: "),
H("td",
H("div", dojoType = "rpaddropzone", class = "dropZone", id = "xDropZone",
listName = "dropX", dropsAllowed = "other,num", rpadRun = "all",
H(NULL, variableButtons[-c(which(numericVariables)[1], length(variableButtons))]))),
H("td",
H("input", type='button', value='New term',
onclick='javascript:insertNewTerm()'))))
BR
H("div", dojoType = "rpaddropzone", class = "dropZone", listName = "dropOther",
dropsAllowed = "num,other", rpadRun = "all", id = "baseDropZone",
style="width:800px; min-height:2em; height:auto !important; height: 2em;",
variableButtons[length(variableButtons)])
H("div", style="position:relative; z-index:1; left:100px; bottom:2.4em; width:800px; height:1px; font-style: italic; color: #D3D3D3;",
H("p", "Variable drop zone: drag and drop variables to redo the model."))
H("p", "Term modifiers (drop on terms):",
H("span", class="functionButton", dojoType="rpaddragvariable", dragName = "fun",
varValue = c("log", "sqrt", "I(#^2)", "poly(#,2)", "poly(#,3)", "factor", "cut2(#,g=4)")))
//dojo.event.connect(thisPage.d3, "onDrop", rpad, "calculatePage")
" "
Y = unlist(dropY)
X = paste(dropX, collapse = "+")
frm = as.formula(paste(Y, "~", X))
a.s = summary.formula(frm, data = a)
HTMLon()
Html(cbind(attr(a.s,"vname"), rownames(a.s),
as.matrix(format(as.data.frame(unclass(a.s), row.names = 1:NROW(a.s))))))
BR
BR
newgraph(width=5, height = 2*sqrt(NROW(a.s)))
plot(a.s, groupfont=2)
showgraph()
This uses summary.formula in Frank Harrell's Hmisc package.
newgraph(width=6,height=6)
predict.plot(as.formula(frm), data = a)
HTMLon()
showgraph()
This uses predict.plot by Tom Minka.
a.lm = lm(frm, data = a)
HTMLon()
HTML(summary(a.lm))
newgraph(width = 3)
plot(a.lm)
HTMLon()
showgraph()
HTMLon()
newgraph(width=3)
termplot(a.lm, partial=TRUE, se = TRUE, ask = FALSE)
showgraph()