added.plot | R Documentation |
Create an added variable plot
added.plot(formula, data, lm_formula = NULL, method = "loess", x = NULL, ...)
formula |
A flexplot formula, specifying how the avp will visualize the variables. |
data |
The dataset used |
lm_formula |
Optional. A formula specifying how to condition variables. |
method |
The smoothing method. Defaults to "loess" |
x |
The variable you wish to place on the x axis. Defaults to NULL. |
... |
Other parameters passed to flexplot |
This function first residualizes the outcome variable based whatever variables the user decides to condition on. The mean of the outcome variable is then added to the residuals (to maintain the interpretation of the variable), then the function plots the residuals against the other variables the user specifies.
More specifically, if the user specifies 'formula' but leaves the options 'x' and 'lm_formula' as NULL, it will default to residualizing the first variable(s) in the formula and plot the last variable entered against those residuals. For example, if the user specifies y~x + z, this function will residualize y~x, then plot z against those residuals.
If the user specifies a value of 'x', that tells the function which variable to residualize. So, again, if the user specifies 'y~x + z' then sets 'x' to 2, the function will instead residualize based on z instead of x.
For multivariate AVPs, the user can specify a value for 'lm_formula'. The value of 'lm_formula' specifies the fitted model that is then residualized, while the value of 'formula' specifies how the remaining variables are displayed, using 'flexplot' formula conventions.
An added variable plot
Dustin Fife
flexplot
data(exercise_data)
added.plot(weight.loss~motivation + therapy.type, data=exercise_data)
added.plot(weight.loss~motivation + therapy.type, data=exercise_data, x=2)
added.plot(weight.loss~motivation + therapy.type,
lm_formula = weight.loss~health*muscle.gain, data=exercise_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.