ambiguity in the documented return value of Null() from package MASS

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ambiguity in the documented return value of Null() from package MASS

Georgi Boshnakov
Hi,
 
Function Null from package MASS seems to return a matrix with zero columns and the expected number of rows when
the null space of the argument contains only the zero vector, e.g.

> library(MASS)
> diag(nrow=3)
     [,1] [,2] [,3]
[1,]    1    0    0
[2,]    0    1    0
[3,]    0    0    1

>  Null(diag(nrow=3))

[1,]
[2,]
[3,]

But the documentation of Null  seems to imply that the result is numeric(0):

-----------------------------------------------

Value:

The matrix 'N' with the basis for the null space, or an empty
     vector if the matrix 'M' is square and of maximal rank.

-----------------------------------------------

(R version 3.1.1 Patched (2014-09-21 r66653) -- "Sock it to Me")

Georgi

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: ambiguity in the documented return value of Null() from package MASS

Peter Dalgaard-2
There is a maintainer for this contributed package...

However, a zero column vector _is_ numeric(0) -- with dimension attributes c(3,0).

structure(numeric(0),dim=c(3,0))
c(Null(diag(3)))

I.e., the ambiguity is pretty slight.

Presumably, the help file wording goes back to S-PLUS which (to my recollection) didn't allow zero-extent matrices. The actual behaviour is a clear improvement.

- Peter D.



On 10 Nov 2014, at 13:49 , Georgi Boshnakov <[hidden email]> wrote:

> Hi,
>
> Function Null from package MASS seems to return a matrix with zero columns and the expected number of rows when
> the null space of the argument contains only the zero vector, e.g.
>
>> library(MASS)
>> diag(nrow=3)
>     [,1] [,2] [,3]
> [1,]    1    0    0
> [2,]    0    1    0
> [3,]    0    0    1
>
>> Null(diag(nrow=3))
>
> [1,]
> [2,]
> [3,]
>
> But the documentation of Null  seems to imply that the result is numeric(0):
>
> -----------------------------------------------
>
> Value:
>
> The matrix 'N' with the basis for the null space, or an empty
>     vector if the matrix 'M' is square and of maximal rank.
>
> -----------------------------------------------
>
> (R version 3.1.1 Patched (2014-09-21 r66653) -- "Sock it to Me")
>
> Georgi
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: ambiguity in the documented return value of Null() from package MASS

Martin Maechler
>>>>> peter dalgaard <[hidden email]>
>>>>>     on Mon, 10 Nov 2014 14:47:16 +0100 writes:

    > There is a maintainer for this contributed package...
    > However, a zero column vector _is_ numeric(0) -- with
    > dimension attributes c(3,0).

    > structure(numeric(0),dim=c(3,0))
    > c(Null(diag(3)))

    > I.e., the ambiguity is pretty slight.

    > Presumably, the help file wording goes back to S-PLUS
    > which (to my recollection) didn't allow zero-extent
    > matrices. The actual behaviour is a clear improvement.

    > - Peter D.

confirmed:

- S-PLUS aka S+ aka ...  did not have 0-extent matrices nor arrays
- R having them makes for much more consistent code in several places.
- one could argue that  matrix( , 3, 0) *is* a special case of
 an empty vector

Further confirmation [not for Peter, for other readers] :

> str(Null(diag(3)))
 num[1:3, 0 ]
> identical(Null(diag(3)), matrix(pi, 3,0))
[1] TRUE
>





    > On 10 Nov 2014, at 13:49 , Georgi Boshnakov <[hidden email]> wrote:

    >> Hi,
    >>
    >> Function Null from package MASS seems to return a matrix with zero columns and the expected number of rows when
    >> the null space of the argument contains only the zero vector, e.g.
    >>
    >>> library(MASS)
    >>> diag(nrow=3)
    >> [,1] [,2] [,3]
    >> [1,]    1    0    0
    >> [2,]    0    1    0
    >> [3,]    0    0    1
    >>
    >>> Null(diag(nrow=3))
    >>
    >> [1,]
    >> [2,]
    >> [3,]
    >>
    >> But the documentation of Null  seems to imply that the result is numeric(0):
    >>
    >> -----------------------------------------------
    >>
    >> Value:
    >>
    >> The matrix 'N' with the basis for the null space, or an empty
    >> vector if the matrix 'M' is square and of maximal rank.
    >>
    >> -----------------------------------------------
    >>
    >> (R version 3.1.1 Patched (2014-09-21 r66653) -- "Sock it to Me")
    >>
    >> Georgi
    >>
    >> ______________________________________________
    >> [hidden email] mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-devel

    > --
    > Peter Dalgaard, Professor,
    > Center for Statistics, Copenhagen Business School
    > Solbjerg Plads 3, 2000 Frederiksberg, Denmark
    > Phone: (+45)38153501
    > Email: [hidden email]  Priv: [hidden email]

    > ______________________________________________
    > [hidden email] mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: ambiguity in the documented return value of Null() from package MASS

William Dunlap
In reply to this post by Peter Dalgaard-2
> Presumably, the help file wording goes back to S-PLUS which
> (to my recollection) didn't allow zero-extent matrices.

Splus (and S) started having reasonable support for zero-extent
matrices in May 2001 (i.e., Splus 6.0, which I think corresponds
to S version 4-m of June 2, 1999),  Splus5.0 (Nov 20, 1998, corresponding
to S version 4-? of Oct 26, 1998) have very partial support for them.

  % Splus6.0
  S-PLUS : Copyright (c) 1988, 2001 Insightful Corp.
  S : Copyright Lucent Technologies, Inc.
  Version 6.0.1 Release 1 for Linux 2.2.12 : 2001
  Working data will be in .Data
  > library(MASS)
  > Null(diag(3))
  numeric matrix: 3 rows, 0 columns.
  > load.date()
  [1] "Fri May  4 01:09:06 PDT 2001"



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Nov 10, 2014 at 5:47 AM, peter dalgaard <[hidden email]> wrote:

> There is a maintainer for this contributed package...
>
> However, a zero column vector _is_ numeric(0) -- with dimension attributes
> c(3,0).
>
> structure(numeric(0),dim=c(3,0))
> c(Null(diag(3)))
>
> I.e., the ambiguity is pretty slight.
>
> Presumably, the help file wording goes back to S-PLUS which (to my
> recollection) didn't allow zero-extent matrices. The actual behaviour is a
> clear improvement.
>
> - Peter D.
>
>
>
> On 10 Nov 2014, at 13:49 , Georgi Boshnakov <
> [hidden email]> wrote:
>
> > Hi,
> >
> > Function Null from package MASS seems to return a matrix with zero
> columns and the expected number of rows when
> > the null space of the argument contains only the zero vector, e.g.
> >
> >> library(MASS)
> >> diag(nrow=3)
> >     [,1] [,2] [,3]
> > [1,]    1    0    0
> > [2,]    0    1    0
> > [3,]    0    0    1
> >
> >> Null(diag(nrow=3))
> >
> > [1,]
> > [2,]
> > [3,]
> >
> > But the documentation of Null  seems to imply that the result is
> numeric(0):
> >
> > -----------------------------------------------
> >
> > Value:
> >
> > The matrix 'N' with the basis for the null space, or an empty
> >     vector if the matrix 'M' is square and of maximal rank.
> >
> > -----------------------------------------------
> >
> > (R version 3.1.1 Patched (2014-09-21 r66653) -- "Sock it to Me")
> >
> > Georgi
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: [hidden email]  Priv: [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel