Re: [Rd] long-standing documentation bug in ?anova.lme

2019-01-20 Thread Ben Bolker


  Silence on this so far? Trying here one more time, otherwise I'll
submit it as a bug report ...

  cheers
   Ben Bolker

On 2019-01-17 12:32 p.m., Ben Bolker wrote:
> tl;dr anova.lme() claims to provide sums of squares, but it doesn't. And
> some names are misspelled in ?lme.  I can submit all this stuff as a bug
> report if that's preferred.
> 
> ?anova.lme says:
> 
> When only one fitted model object is present, a data frame with
>  the sums of squares, numerator degrees of freedom, denominator
>  degrees of freedom, F-values, and P-values
> 
> The output of
> 
> fm1 <- lme(distance ~ age, data = Orthodont) # random is ~ age
> anova(fm1)
> 
> gives columns
> 
> numDF denDF   F-value p-value
> 
> -- i.e. the sums of squares aren't there!  (For fairly good reasons; lme
> doesn't actually compute them internally, and it might not always be
> straightforward to compute them, for more complex models. They would
> mostly be useful for comparison with simpler, method-of-moments based
> approaches like aov()). Federico Calboli pointed this out on r-help in
> 2004: https://stat.ethz.ch/pipermail/r-help/2004-May/051444.html
> 
> 
> Two more points:
> 
>   * the last sentence of the Description might need one fewer comma
> [after "statistic"] or one more [after "p-value"].
>   * in ?lme, Littell's name is misspelled at least twice and Reinsel's
> at least once.
> 
>   Is there a publicly accessible SVN server for recommended packages (in
> general) and nlme (in particular) anywhere?
> 
>   cheers
>   Ben Bolker
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Request: make `var` a generic

2019-01-20 Thread Kenny Bell
Hi all,

I am running into problems using `summary.lm` as calling `var` on a `units`
object does not retain the `units` attribute.

The units package addresses this issue for `mean` by implementing
`mean.units`:

units:::mean.units
function (x, ...)
{
.as.units(NextMethod(), units(x))
}

This is, however, not possible for `var` (as it's not a generic), which
breaks `summary.lm`:

```
library(units)
#> udunits system database from C:/R/Library/3.5/units/share/udunits
iris$Sepal.Length <- set_units(iris$Sepal.Length, "cm")

summary(lm(Sepal.Length ~ Sepal.Width,
   data = iris))
#> Error in Ops.units(mean(f)^2, var(f)): both operands of the expression
should be "units" objects
```

Created on 2019-01-21 by the [reprex package](https://reprex.tidyverse.org)
(v0.2.1.9000)

Apologies if `stats` package emails shouldn't go here.

Cheers,
Kenny

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Request: make `var` a generic

2019-01-20 Thread Edzer Pebesma
Hi Kenny,

yes, there's only so much you can do with S3 methods penetrating other
packages' code; IƱaki discusses this in the blog about the r-quantities
project found at:

https://www.r-spatial.org/r/2018/08/31/quantities-final.html#fitting-linear-models-with-quantities

I'm not sure whether making "var" a generic would not shift the problem
to the next function not being generic, you could experiment with that.

On 1/20/19 6:39 PM, Kenny Bell wrote:
> Hi all,
> 
> I am running into problems using `summary.lm` as calling `var` on a `units`
> object does not retain the `units` attribute.
> 
> The units package addresses this issue for `mean` by implementing
> `mean.units`:
> 
> units:::mean.units
> function (x, ...)
> {
> .as.units(NextMethod(), units(x))
> }
> 
> This is, however, not possible for `var` (as it's not a generic), which
> breaks `summary.lm`:
> 
> ```
> library(units)
> #> udunits system database from C:/R/Library/3.5/units/share/udunits
> iris$Sepal.Length <- set_units(iris$Sepal.Length, "cm")
> 
> summary(lm(Sepal.Length ~ Sepal.Width,
>data = iris))
> #> Error in Ops.units(mean(f)^2, var(f)): both operands of the expression
> should be "units" objects
> ```
> 
> Created on 2019-01-21 by the [reprex package](https://reprex.tidyverse.org)
> (v0.2.1.9000)
> 
> Apologies if `stats` package emails shouldn't go here.
> 
> Cheers,
> Kenny
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel