atyre2 / nres803 Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Check non_linear does not work with transformed variables that are not specified as as columns in the data frame that was used to build the model. No idea why this is happening, anyone have any ideas?
E.g.
data("iris")
x <- lm(Sepal.Width ~ log(Sepal.Length), data = iris)
check_nonlinear(x)
Error in FUN(X[[i]], ...) : object 'Sepal.Length' not found
If there are few unique levels of .fitted, the scale-location and residual vs. fitted plots get whacky with lots of warnings.
library("tidyverse")
library("broom")
library("NRES803")
library("NRES803data")
data(RIKZ)
dim(RIKZ)
RIKZ$Richness <- rowSums(RIKZ[,2:76] > 0)
dim(RIKZ)
richness_week <- ggplot(RIKZ, aes(x = week, y = Richness)) +
geom_point() +
geom_smooth(method = "lm")
richness_week
RIKZ_model.2 = lm(Richness ~ week, data = RIKZ)
summary(RIKZ_model.2)
test_RIKZ2 <- augment(RIKZ_model.2, data=RIKZ)
ggplot(test_RIKZ2, aes(x = .fitted, y = .resid)) +
geom_point() +
geom_smooth()
# this is lifted out of base R qqline()
y <- quantile(test_RIKZ2$.resid, c(0.25, 0.75))
x <- qnorm(c(0.25, 0.75))
slope <- diff(y)/diff(x)
int <- y[1L] - slope * x[1L]
ggplot(test_RIKZ2, aes(sample = .resid)) +
stat_qq() +
geom_abline(slope = slope, intercept = int)
ggplot(test_RIKZ2, aes(x = .fitted, y = sqrt(abs(.std.resid)))) +
geom_point() +
geom_smooth() +
geom_hline(yintercept = 1)
ggplot(test_RIKZ2, aes(.hat, .std.resid)) +
geom_vline(size = 2, colour = "white", xintercept = 0) +
geom_hline(size = 2, colour = "white", yintercept = 0) +
geom_point(aes(size = .cooksd)) + geom_smooth(se = FALSE)
I've noticed a strange issue with the check_assumptions() function. Check_assumptions() should return one (!) ggplot-object with four panels. During recent use however two ggplot-objects are returned with two panels each. This happens for lms, gams, etc.
I'm not sure why this is happening as the code seems fine. I assume it is an issue with how we add the individual plot objects together. Both ggpubr::ggarrange(rr0, rr1, rr2, rr3, nrow=2) and ggpubr::ggarrange(plotlist = list(rr0, rr1, rr2, rr3), nrow=2) have the same issue.
I have also found a workaround: instead of ggpubr::ggarrange(rr0, rr1, rr2, rr3, nrow=2)
use ggpubr::ggarrange(rr0, rr1, rr2, rr3, nrow=2, ncol = 2)
.
I'll commit the changes to the code later but still this is strange behaviour as nrow = 2 should do the trick...
When there are few unique values on the x axis, the smooths in the standardized residuals and scale location plots get bizarre and unhelpful. Detect this condition and do something about it.
library(NRES803data)
RIKZ_model.2 = lm(Richness ~ week, data = RIKZ)
check_assumptions(RIKZ_model.2)
but doesn't happen all the time:
RIKZ$fweek <- factor(RIKZ$week)
RIKZ_model.3 <- lm(Richness ~ fweek, data = RIKZ)
check_assumptions(RIKZ_model.3)
I'd like to rewrite the check_assumptions function for gams using the evaluation plots in Zuur et al 2007 Analysing ecological data on p.118, chapter 7 Additive and generalised additive modelling.
Anyone interested in this/thinks its a good idea?
https://cran.r-project.org/package=gratia
but doesn't use the same sort of API as broom. Does some of the same things but in a different way.
fix with usethis::use_package()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.