Skip to content

Instantly share code, notes, and snippets.

@aufrank
Created August 2, 2010 23:20
Show Gist options
  • Save aufrank/505500 to your computer and use it in GitHub Desktop.
Save aufrank/505500 to your computer and use it in GitHub Desktop.
library(rms)
library(ggplot2)
ddiamonds <- datadist(diamonds)
options(datadist = "ddiamonds")
fit.ols <- ols(price ~ carat * cut, diamonds)
## can specify a range on a continuous predictor
Predict(fit.ols, carat = seq(2,4,.25))
## can specify a single level for a categorical predictor
Predict(fit.ols, cut = "Good")
## can specify multiple levels for a categorical predictor
Predict(fit.ols, cut = c("Fair", "Good"))
## Is there a way to collapse across multiple levels of a categorical predictor?
## Would like to see the effect of carat, averaging over all cuts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment