FunResplot | R Documentation |
FunResplot
plots four model diagnostic residual plots to check model
assumptions.
FunResplot(
obj,
plots = 1:4,
method = c("rnorm", "resampling"),
num = 100,
set_seed = FALSE,
change_mfrow = TRUE,
plot_title = TRUE
)
obj |
model (e.g. object of type |
plots |
1=Tukey-Anscombe, 2=Normal, 3=Scale-Location, 4=Leverage.
Several can be plotted e.g. |
method |
how should resampling residuals be obtained for Tukey-Anscombe plots. rnorm: residuals are drawn from a normal distribution with variance equal the estimated variance of the observed residuals. resampling: residuals are drawn from observed residuals with replacment |
num |
number of resampling iterations (number of gray lines) |
set_seed |
boolean. Automatically set a constant seed in the function |
change_mfrow |
boolean. Automatically adjust |
plot_title |
boolean. Should there be a title above the figure. |
Nothing is returned. Plots are plotted
Marcel Dettling
## generate data
x <- 1:100
y <- rnorm(100, x + 10, 10)
## fit model
fit <- lm(y ~ x)
plot(y ~ x)
abline(fit)
## plot residual plots
FunResplot(fit)
FunResplot(fit, plots = 1:2, num = 20)
## another good method
## see anova r-script 05_nitrogen
nitro.sim <- nitro
set.seed(12)
opar <- par(mfrow = c(4, 5))
for(i in 1:20){
nitro.sim[, "y"] <- simulate(fit)
fit.sim <- update(fit, data = nitro.sim)
plot(fit.sim, which = 1)
}
par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.