Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Bert Gunter
"This works with any single-index value, and lets all the existing operations for such values continue to work." As Peter Dalgaard already pointed out, that is false. > x <- 1:4 > x[-1] [1] 2 3 4 > elt(x,-0) [1] 1 Cheers, Bert On Tue, Apr 23, 2024 at 4:55 PM Richard O'Keefe wrote: > > Does it

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Richard O'Keefe
" You could have a global setting for whether ALL operations are 0-based or 1-based" NO. You could, but you shouldn't. []IO (index origin) in APL has always let you do this and it has always been a good way to break lots of stuff. A much better approach is to think of "index-from-0" and

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Richard O'Keefe
Does it have to use square bracket syntax? elt <- function (x, i) x[i+1] "elt<-" <- function (x, i, value) { x[i+1] <- value; x } > u <- c("A","B","C") > elt(u,0) [1] "A" > elt(u,length(u)-1) [1] "C" > elt(u,0) <- "Z" > u [1] "Z" "B" "C" This works with any single-index value, and lets all the

Re: [R] System GMM yields identical results for any weighting matrix

2024-04-23 Thread Bert Gunter
Sorry, my advice is incorrect (and I should have known better!). Task views are to search for relevant packages, not for posting questions. R "special interest groups" (SIGs) are for the latter, which in your case might be this one: https://stat.ethz.ch/mailman/listinfo/r-sig-finance . Cheers,

Re: [R] System GMM yields identical results for any weighting matrix

2024-04-23 Thread Bert Gunter
Generally speaking, this sort of detailed statistical question about a speccial package in R does not get a reply on this general R programming help list. Instead, I suggest you either email the maintainer (found by ?maintainer) or ask a question on a relevant R task view, such as

[R] System GMM yields identical results for any weighting matrix

2024-04-23 Thread Richard Hardy
A copy of this question can be found on Cross Validated: https://stats.stackexchange.com/questions/645362 I am estimating a system of seemingly unrelated regressions (SUR) in R. Each of the equations has one unique regressor and one common regressor. I am using `gmm::sysGmm` and am experimenting

[R] System GMM fails due to computationally singular system. Why?

2024-04-23 Thread Richard Hardy
A copy of this question can be found on Cross Validated: https://stats.stackexchange.com/questions/645610 I am estimating a system of seemingly unrelated regressions (SUR) with `gmm::sysGmm` in R. Each of the equations has one unique regressor and one common regressor. The common regressor is a

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread avi.e.gross
I think it might be fair to say that the discussion is becoming a tad wider than whether you want your data structures indexed starting from 0 or 1. Programming languages have added functionality to do many things on top of the simple concept of accessing or changing the nth element one at a

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Jeff Newmiller via R-help
While I certainly think using negative indices to denote element exclusion is a cool feature, I think people wanting to use zero-based indexes probably are not planning to use that feature. Python uses negative numbers to index from the end, which is a completely different use of negative

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread John Fox
Hello Peter, Unless I too misunderstand your point, negative indices for removal do work with the Oarray package (though -0 doesn't work to remove the 0th element, since -0 == 0 -- perhaps what you meant): > library(Oarray) > v <- Oarray(1:10, offset=0) > v [0,] [1,] [2,] [3,] [4,] [5,]

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Peter Dalgaard via R-help
Doesn't sound like you got the point. x[-1] normally removes the first element. With 0-based indices, this cannot work. - pd > On 22 Apr 2024, at 17:31 , Ebert,Timothy Aaron wrote: > > You could have negative indices. There are two ways to do this. > 1) provide a large offset. > Offset <- 30

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-23 Thread Martin Maechler
> Ben Bolker > on Sun, 21 Apr 2024 10:23:50 -0400 writes: > Also https://cran.r-project.org/package=Oarray (which is older and > hence possibly more stable) also maintained and written by a careful and really good person. I do recommend Oarray as well. Martin BB> On