compare.fits | R Documentation |
This function takes two fitted models as input and plots them to visually compare how the two differ in terms of fit.
It can take a glm
, rlm
, lm
, and randomForest
model (and maybe others as well). The function takes
a flexplot
-like formula as input.
compare.fits(
formula,
data,
model1,
model2 = NULL,
return.preds = F,
report.se = F,
re = F,
pred.type = "response",
num_points = 50,
clusters = 3,
...
)
formula |
A formula that can be used in flexplot. The variables inside must not include variables outside the fitted models. |
data |
The dataset containing the variables in formula |
model1 |
The fitted model object (e.g., lm) containing the variables specified in the formula |
model2 |
The second fitted model object (e.g., lm) containing the variables specified in the formula |
return.preds |
Should the function return the predictions instead of a graphic? Defaults to F |
report.se |
Should standard errors be reported alongside the estimates? Defaults to F. |
re |
Should random effects be predicted? Only applies to mixed models. Defaults to F. |
pred.type |
What type of predictions should be outputted? This is mostly for |
num_points |
Number of points used for predictions. Larger numbers = slower algorithm, but smoother predictions. |
clusters |
For visualizing mixed models, this specifies the number of clusters to display |
... |
Other parameters passed to flexplot |
Either a graphic or the predictions for the specified model(s)
Dustin Fife
data(exercise_data)
mod1 = lm(weight.loss~therapy.type + motivation, data=exercise_data)
mod2 = lm(weight.loss~therapy.type * motivation, data=exercise_data)
compare.fits(weight.loss~therapy.type | motivation, data=exercise_data, mod1, mod2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.