GithubHelp home page GithubHelp logo

nres803's People

Contributors

andrewroylaws avatar atyre2 avatar diatomdaniel avatar dnguyen2017 avatar sgabrielp avatar

Watchers

 avatar  avatar

nres803's Issues

broke check_nonlinear again

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

check_assumptions() should make sure there are sufficient unique values

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)

check_assumptions() acting strange

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...

fix whacky smooths problem in check assumptions

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)

check_assumptions for gams!

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.