Created
October 22, 2019 01:23
-
-
Save pgstevenson/8d5d3966fa53f1abb1689428e7709bfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Model Diagnostics | |
**Reference only, remove from report before sending to the sponsor** | |
### Influential Observations | |
```{r influence_plot, out.extra = "figure", echo = F, warning = F, message = F, comment = NA, eval = F} | |
influencePlot(mods$iris_data, id.method = "identify", main = "Influence Plot", sub = "Circle size is proportial to Cook's Distance" ) | |
``` | |
### Linearity of Relationships | |
```{r added_variable_plot, out.extra = "figure", echo = F, warning = F, message = F, eval = F} | |
avPlots(mods$iris_data) | |
``` | |
```{r nonlinearity_crPlots, out.extra = "figure", echo = F, warning = F, message = F, eval = F} | |
crPlots(mods$iris_data) # component + residual plot | |
``` | |
### Consitancy of Error Variance (homoscedasticity) | |
```{r homoscedasticity_test, echo = F, comment = NA, eval = F} | |
ncvTest(mods$iris_data) # non-constant error variance test | |
``` | |
```{r homoscedasticity_plot, out.extra = "figure", echo = F, warning = F, message = F, comment = NA, eval = F} | |
# plot studentized residuals vs. fitted values | |
spreadLevelPlot(mods$iris_data) | |
``` | |
### Normality of Errors | |
```{r qqplot, out.extra = "figure", echo = F, warning = F, message = F, comment = NA, eval = F} | |
qqPlot(mods$iris_data, main="QQ Plot") | |
``` | |
```{r residuals_distribution, out.extra = "figure", echo = F, warning = F, message = F, eval = F} | |
sresid <- MASS::studres(mods$iris_data) | |
hist(sresid, freq=FALSE, | |
main="Distribution of Studentized Residuals") | |
xfit<-seq(min(sresid),max(sresid),length=40) | |
yfit<-dnorm(xfit) | |
lines(xfit, yfit) | |
``` | |
### Collinearity | |
```{r Collinearity, table = T, results = "hide", eval = F} | |
vif(mods$iris_data) %>% as_tibble() # variance inflation factors | |
``` | |
$\sqrt(model) > 2$ | |
```{r Collinearity_sq, table = T, results = "hide", eval = F} | |
vif(mods$iris_data) %>% as_tibble() %>% mutate_all(list(~sqrt(.) > 2)) # problem? | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment