Re: [R] Weird Behavior of mean

2024-12-13 Thread avi.e.gross
It is probably a bit late in most existing languages to change behaviors all over the code. Languages like C often allowed many kinds of shortcuts that happened to work because 0 was false and 1 and most other things were true. Similarly, pointers were used in a Boolean way as in the way they co

[R] Fortune Nomination

2024-12-13 Thread Sorkin, John
As Dante wrote, Abandon all hope ye who enter R. Written by ivo welch 12/13 2:43 PM John David Sorkin M.D., Ph.D. Professor of Medicine, University of Maryland School of Medicine; Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, an

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread John Fox
Hello Duncan, On 2024-12-13 5:30 p.m., Duncan Murdoch wrote: Caution: External email. On 2024-12-13 5:11 p.m., John Fox wrote: Dear Daniel, On 2024-12-13 2:51 p.m., Daniel Lobo wrote: Caution: External email. Looks like the solution 1.576708   6.456606   6.195305 -19.007996 is the best so

Re: [R] Weird Behavior of mean

2024-12-13 Thread Bert Gunter
Sounds reasonable, but I leave it to wiser heads than me to decide. My only point is that whatever is done be accurately documented. At present, that does not appear to be the case. ... and yes, "accurate" documentation is not easy either. -- Bert On Fri, Dec 13, 2024 at 3:20 PM Ben Bolker wrote

Re: [R] Weird Behavior of mean

2024-12-13 Thread Richard O'Keefe
My preference would be for anything that is defined as taking a "logical" parameter to report an error if given anything else. On Sat, 14 Dec 2024 at 12:21, Ben Bolker wrote: > >Thanks, I had missed/forgotten the fact that there is also an > inconsistency between mean.default() and sd(). > >

Re: [R] Weird Behavior of mean

2024-12-13 Thread Ben Bolker
Thanks, I had missed/forgotten the fact that there is also an inconsistency between mean.default() and sd(). sd() calls var(), which evaluates if(na.rm) [i.e., it will try to coerce `na.rm` to logical rather than testing isTRUE] IM(H?)O, it would be best for both mean.default() and sd()

Re: [R] Weird Behavior of mean

2024-12-13 Thread Bert Gunter
Ivo, et al.: --IMHO only ... and with apologies for verbosity Defining, let alone enforcing, "consistent behavior" can be a philosophical conundrum: what one person deems "consistent" behavior for a function across different data structures and circumstances may not be the same as another's. While

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Duncan Murdoch
On 2024-12-13 5:11 p.m., John Fox wrote: Dear Daniel, On 2024-12-13 2:51 p.m., Daniel Lobo wrote: Caution: External email. Looks like the solution 1.576708 6.456606 6.195305 -19.007996 is the best solution that nloptr can produce by increasing the iteration numbers. The better set of sol

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread John Fox
Dear Daniel, On 2024-12-13 2:51 p.m., Daniel Lobo wrote: Caution: External email. Looks like the solution 1.576708 6.456606 6.195305 -19.007996 is the best solution that nloptr can produce by increasing the iteration numbers. The better set of solution is obtained using pracma package.

Re: [R] Weird Behavior of mean

2024-12-13 Thread avi.e.gross
Ivo, To be a bit clearer, your problem was not with mean(0 but with any function which is expecting a Boolean setting of TRUE/FALSE and instead got a nonsense value of 20. This gets even weirder in languages which automagcally transform many other values to be considered true. Languages like C co

Re: [R] [off-topic] crossword

2024-12-13 Thread avi.e.gross
Not to beat a dead horse, but if they wanted an answer of CODES, then why not use S instead of R in the … From: Bill Dunlap Sent: Friday, December 13, 2024 3:47 PM To: avi.e.gr...@gmail.com Cc: Olivier Crouzet ; r-help@r-project.org Subject: Re: [R] [off-topic] crossword Crossword answer

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
On 2024-12-13 13:55, Daniel Lobo wrote: 1. Why nloptr() is failing where other programs can continue with the same set of data, numbers, and constraints? 2. Is this enough ground to say that nloptr is inferior and user should not use this in complex problems? As I indicated in a recent respo

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Ben Bolker
It's a long way from "X works better than Y on this particular problem" to "X is superior to Y". It's a somewhat loose analogy, but the 'no free lunch theorem' asserts that if we consider a broad enough class of optimization problems, *no* op

Re: [R] Weird Behavior of mean

2024-12-13 Thread Jeff Newmiller via R-help
This was documented in [1] forever ago. I would not miss it if a future version of R chose to remove those variables. [1] The R Inferno, 8.1.32 On December 13, 2024 11:21:13 AM PST, ivo welch wrote: >isn't this still a little R buglet? I have overwritten T (even if my >schuld [franconian], it

Re: [R] Weird Behavior of mean

2024-12-13 Thread Ben Bolker
This example is a little more subtle than that; the OP knows about name masking, but was expecting T to be coerced to logical, which would ordinarily be a reasonable expectation (IMO) ... On Fri, Dec 13, 2024 at 3:40 PM Jeff Newmiller via R-help wrote: > > This was documented in [1] forever ago

Re: [R] [off-topic] crossword

2024-12-13 Thread Bill Dunlap
Crossword answers have to be drop-in replacements for the clue in a sentence. Hence replacing "She writes in C and R, say." with "She codes" would work, but "She coder" would not. (If one interpreted C and R as the names of third party candidates for office, then "She votes" would work, but

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Hi Duncan, I take your advice. I posted here in search for a better answer to my problem as I could not get that there. My question is: 1. Why nloptr() is failing where other programs can continue with the same set of data, numbers, and constraints? 2. Is this enough ground to say that nloptr is

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
Interesting that alabama and nloptr both use auglag but alabama gets a lower objective fn. I think there could be lots of exploration of controls and settings to play with to find out what is going on. alabama::auglag f, ci, ce,ob,val: 0 -4.71486e-08 1029.77 1029.77 at [1] -0.610594

Re: [R] [off-topic] crossword

2024-12-13 Thread avi.e.gross
I hesitate to say this and stray back on topic. R is basically an extension of C as it was written in C and many added functions end up being rewritten in a variant of C, albeit other languages may at times intrude. Something similar could be said of C-Python. But I truly doubt the ones making

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Looks like the solution 1.576708 6.456606 6.195305 -19.007996 is the best solution that nloptr can produce by increasing the iteration numbers. The better set of solution is obtained using pracma package. On Sat, 14 Dec 2024 at 01:14, John Fox wrote: > > Dear Daniel et al., > > Following on

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread John Fox
Dear Daniel et al., Following on Duncan's remark and examining the message produced by nloptr(), I simply tried increasing the maximum number of function evaluations: -- snip --- > nloptr(rep(0, 4), f, eval_g_ineq = hin, eval_g_eq = Hx, opts = + list("algorithm" = "NLOPT_LN_C

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Steven Ellis
Hi Edward, R can indeed initiate electronic communication, e.g. by downloading new libraries (`install.packages()`). You may be best off using a container. Steven On Fri, Dec 13, 2024, 10:25 AM Edward Woo via R-help wrote: > Hi, > > I am trying to download R version 3.6.1 onto my company compu

Re: [R] Weird Behavior of mean

2024-12-13 Thread ivo welch
isn't this still a little R buglet? I have overwritten T (even if my schuld [franconian], it is not that uncommon an error, because T is also a common abbreviation for the end of a time series; namespace pollution in R can be quite annoying, even though I understand that it is convenient in intera

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
Dec 2024 14:30:03 -0500 From: J C Nash To: r-help@r-project.org The following may or may not be relevant, but definitely getting somewhat different results. As this was a quick and dirty try while having a snack, it may have bugs. # Lobo2412.R -- from R Help 20241213 #Original artificial data

Re: [R] [off-topic] crossword

2024-12-13 Thread avi.e.gross
Since this is a discussion about a specific crossword puzzle the right answer has to fit with any words coming in from the other direction or it gets cross. I thought the clue hinted it started with C and ended with R and that the languages were chosen for no reason other than that they helped m

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
The following may or may not be relevant, but definitely getting somewhat different results. As this was a quick and dirty try while having a snack, it may have bugs. # Lobo2412.R -- from R Help 20241213 #Original artificial data library(optimx) library(nloptr) library(alabama) set.seed(1

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Duncan Murdoch
You posted a version of this question on StackOverflow, and were given advice there that you ignored. nloptr() clearly indicates that it is quitting without reaching an optimum, but you are hiding that message. Don't do that. Duncan Murdoch On 2024-12-13 12:52 p.m., Daniel Lobo wrote: libr

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Thanks for your reply. I have checked the optimized value and applicable constraints. Both set of the values of parameters satisfy the constraints. What other solver would you suggest for this problem? On Fri, 13 Dec 2024 at 23:33, J C Nash wrote: > > COBYLA stands for Contrained Optimization b

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Adding R help On Fri, 13 Dec 2024 at 23:39, Daniel Lobo wrote: > > If I use "algorithm" = "BOBYQA", the nloptr() fails with below message > > Error in is.nloptr(ret) : > > Incorrect algorithm supplied. Use one of the following: > > NLOPT_GN_DIRECT > > NLOPT_GN_DIRECT_L > > NLOPT_GN_DIRECT_L_RAN

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Ben Bolker
Fortune candidate? (Prof Zeileis, are you still collecting these?) Optimizers are like other tools. Some are chainsaws, others are scalpels. Don't do neurosurgery with a chainsaw unless you want a mess. __ R-help@r-project.org mailing list -- To

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
A small correction, the below combination 2.02, 6.764, 6.186, -20.095 Gives better result. On Fri, 13 Dec 2024 at 23:22, Daniel Lobo wrote: > > Hi, > > I have below non-linear constraint optimization problem > > #Original artificial data > > library(nloptr) > > set.seed(1) > A <- 1.34 > B <- 0.

Re: [R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread J C Nash
COBYLA stands for Contrained Optimization by Linear Approximation. You seem to have some squares in your functions. Maybe BOBYQA would be a better choice, though it only does bounds, so you'd have to introduce a penalty, but then more of the optimx solvers would be available. With only 4 paramete

[R] Non linear optimization with nloptr package fail to produce true optimal result

2024-12-13 Thread Daniel Lobo
Hi, I have below non-linear constraint optimization problem #Original artificial data library(nloptr) set.seed(1) A <- 1.34 B <- 0.5673 C <- 6.356 D <- -1.234 x <- seq(0.5, 20, length.out = 500) y <- A + B * x + C * x^2 + D * log(x) + runif(500, 0, 3) #Objective function X <- cbind(1, x, x^2,

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Ben Bolker
This reminds me a little bit of working in a secure data center (no external network connections from any of the workstations) where the security policy did not allow shell access, but did allow R (disallowing it would have crippled half of the projects using the data center). I didn't go ou

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Sergei Ko
I suspect it might be relevant for RStudio, but definitely not for pure R. On top of that you can just copy R to a flash drive or any accessible folder. It will work. Regards, Sergiy On Fri, 13 Dec 2024, 15:56 Bert Gunter, wrote: > Thanks, Ivan. Exactly my reaction. > > And as a Turing complete

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Marc Schwartz via R-help
Hi, In addition to the replies that you have already received, it is reasonable to question why you wish to download a version of R that is over 5 years old. Version 3.6.1 was released in July of 2019. If you are concerned about security, which is going to be a scenario specific discussion, as

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Bert Gunter
Thanks, Ivan. Exactly my reaction. And as a Turing complete language, R allows one to do anything in R -- including writing an email package that does email directly from R: see package emayili . Indeed, I think one would find it difficult to find *any* software that does not interact with the in

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Jeff Newmiller via R-help
R is a programming language. If you program it to communicate, it will. Also, it is designed to work with user-contributed packages of code... the process of downloading the packages is communication, and the downloaded packages may communicate if you invoke them (that is often why they are crea

Re: [R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Ivan Krylov via R-help
Dear Edward Woo, Welcome to R-help! В Fri, 13 Dec 2024 14:24:18 + Edward Woo via R-help пишет: > need an email confirming that r does not include any electronic > communication functionality within the program Could you please provide a definition of electronic communication functionality?

[R] Confirmation of no Electronic Communication functionality

2024-12-13 Thread Edward Woo via R-help
Hi, I am trying to download R version 3.6.1 onto my company computer and need an email confirming that r does not include any electronic communication functionality within the program. Thank you very much! Best, Edward Woo Edward Woo Municipals Securities Group Jefferies LLC 520 Madison Aven

Re: [R] [off-topic] crossword

2024-12-13 Thread Erin Hodgess
RULES means that anyone who uses C or R RULES the Universe. They just do. Erin Hodgess, PhD mailto: erinm.hodg...@gmail.com On Fri, Dec 13, 2024 at 1:02 AM CALUM POLWART wrote: > Well to complicate things, I don't think RULES is the answer. > > This is a cryptic crossword clue. They usually c

Re: [R] [off-topic] crossword

2024-12-13 Thread Olivier Crouzet
Thank you all for the helpful and enlightening comments. One question though, isn't "say" a synonym in oral forms of american english for "for example"? Which would translate to: > Writes in C or R, [for example]. which would involve that C and R are possible examples of the usage contexts consi

Re: [R] [off-topic] crossword

2024-12-13 Thread Bill Dunlap
The answer for "Writes in C and R, say" was "codes". I was impressed that R has passed into popular culture. On Thu, Dec 12, 2024 at 8:25 PM Ebert,Timothy Aaron wrote: > I do not understand the question and I do not understand the answer. > Possibly one confounds the other. > > -Original Me

Re: [R] [off-topic] crossword

2024-12-13 Thread Ebert,Timothy Aaron
Ok, that answer I understand and see it fitting. In that context there are several other possibilities that could also work: Programmer, hacker, geek, cracker. There are other choices, but the other options like “skiddie” are ones that I do not recognize and have omitted. Tim From: CALUM POLWAR

Re: [R] Weird Behavior of mean

2024-12-13 Thread Martin Maechler
> CALUM POLWART > on Fri, 13 Dec 2024 08:56:15 + writes: > I've not checked the code, but I think that result would > happen if mean uses something like > if (na.rm == TRUE) { # do something to remove the NA's } > And as uses something like > If (na.rm != FA

Re: [R] Weird Behavior of mean

2024-12-13 Thread CALUM POLWART
I've not checked the code, but I think that result would happen if mean uses something like if (na.rm == TRUE) { # do something to remove the NA's } And as uses something like If (na.rm != FALSE) { # do something to remove the NA's } Or perhaps ever na.rm == T If you ever see posts from B

[R] Weird Behavior of mean

2024-12-13 Thread Ivo Welch
Is the following a strange behavior for `mean` vs. `sd` ? ``` $ R --vanilla. ## 4.4.2 > x=c(NA,1,2,3) > c( mean(x,na.rm=T), sd(x,na.rm=T) ) [1] 2 1 > T=20 ## bad idea for a parameter. T is also used for TRUE > c( mean(x,na.rm=T), sd(x,na.rm=T) ) [1] NA 1 > ``` This one was a baffler for me to

Re: [R] [off-topic] crossword

2024-12-13 Thread CALUM POLWART
Well to complicate things, I don't think RULES is the answer. This is a cryptic crossword clue. They usually contain the answer twice (well... Cryptically!!) Writes in C or R, say. I think the answer is CODER If you look up the definition of say in the dictionary one option is: 1. give in