aphalo / ggpmisc

R package ggpmisc is an extension to ggplot2 and the Grammar of Graphics
https://docs.r4photobiology.info/ggpmisc
98 stars 6 forks source link

Add support for major axis regression #7

Closed aphalo closed 3 years ago

aphalo commented 3 years ago

Add stat_sma_eq() and update stat_fit_deviations() and stat_fit_residuals(). Either package 'smatr' or 'lmodel2' could be used. Catch is that these packages only support very simple formulas, i.e., y ~ x which could surprise users is implemented in the same functions as 'lm', etc.

I suspect that 'smatr' would be the best option, but this needs to be further explored.

Support for ma and sma in stat_fit_deviations() would be particularly useful in teaching.

aphalo commented 3 years ago

Implementing this is laborious because both 'lmodel2' and 'smatr' return fitted objects with idiosyncratic structure and are missing some of the expected extraction and summary functions. I will not work on this immediately.

aphalo commented 3 years ago

Started a new branch lmodel2 and implemented coef(), confint() and predict() for fitted model objects of class lmodel2. These methods should make it easier to implement support for 'lmodel2' in stat_poly_eq() and stat_poly_line() or defining new statistics.

aphalo commented 3 years ago

Now working in main branch. Test cases need to be added.