Description Usage Arguments Details See Also Examples
View source: R/plot_differences.R
This functions plots the conditional values of the model parameters as a function of the covariates.
1 2 3 4 5 6 7 | plot_differences(
x,
parameter = NULL,
covariate = NULL,
confidence_level = 0.95,
...
)
|
x |
an ipcr object. |
parameter |
a string. The name of a model parameter as in |
covariate |
a string. The name of a covariate. Per default, all the effects of all covariates are plotted. |
confidence_level |
a numeric. The confidence interval plotted. 0.95 (resulting) in 95% confidence interval is the default. |
... |
other arguments. |
Note that regression lines (for continuous covariates), means (for dummy variables), and confidence intervals are plotted, using the estimates of the model parameters and the corresponding variances and covariances of the parameter estimates. The plots show the estimated parameter value as a function of a covariate with all other covariates set equal to zero. (Mean) centering of the covariates may increase the interpretability of the plots.
This function is a wrapper for ggplot
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Generate data
## Covariates
z1 <- rep(0:1, each = 50)
z2 <- rnorm(n = 100)
covariates <- data.frame(z1 = z1, z2 = z2)
## Model data
x <- rnorm(n = 100)
y <- 0.5 + 0.75*z1 + rnorm(n = 100, sd = sqrt(0.75))
d <- data.frame(x = x, y = y)
# Fit a linear regression
m <- lm(y ~ x, data = d)
# Investigate model with IPC regression
ipc <- ipcr(m, covariates = covariates)
# Plotting parameter values as a function of the covariates
## All plots
plot_differences(ipc)
## Plot the values of the regression slope x as a function of the covariate z1
plot_differences(ipc, parameter = "x", covariate = "z1")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.