Re: [R] How to get the same result for GA optimization?

2025-05-07 Thread Daniel Lobo
u have re-generated the data before calling ga() > so the data is not just a permutation of the first set. > > Michael > > On 07/05/2025 15:36, Daniel Lobo wrote: > > I am using *Genetic Algorithm* to maximize some function which use data. > > > > I use GA

[R] How to get the same result for GA optimization?

2025-05-07 Thread Daniel Lobo
I am using *Genetic Algorithm* to maximize some function which use data. I use GA package in R for this ( https://cran.r-project.org/web/packages/GA/index.html) Below is my code library(GA) set.seed(1) Dat = data.frame(rnorm(1000), matrix(rnorm(1000 * 30), nc = 30)) Fitness_Fn = function(x) {

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Daniel Lobo
2.05/100 I can see that the constraint #2 is implemented in the function argument lower = rep(0.01, 21), How can I impose other 2 constraints? Many thanks, On Sat, 29 Mar 2025 at 01:49, Rui Barradas wrote: > Às 13:59 de 28/03/2025, Daniel Lobo escreveu: > > Hi Duncan, > > >

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Daniel Lobo
don't know if there is an R function that can do > constrained discrete maximization. > > Duncan Murdoch > > On 2025-03-27 2:35 p.m., Daniel Lobo wrote: > > Hi, > > > > I have below minimization problem > > > > > > MyDat = structure(list(c(50L, 0L,

Re: [R] Problem with minimization that I failed to understand

2025-03-27 Thread Daniel Lobo
, 28 Mar 2025 at 03:53, Rui Barradas wrote: > Às 19:36 de 27/03/2025, Daniel Lobo escreveu: > > My code is to minimize the objective function > > > > therefore, shouldnt I expect that > > > > StartingValue = c(0.12, 0.04, 0.07, 0.03, 0.06, 0.07, 0.07, 0.04, 0.09,

Re: [R] Problem with minimization that I failed to understand

2025-03-27 Thread Daniel Lobo
6, 0.02, 0, 0.07, 0.05, 0.02, 0.02, 0.02)) #FALSE On Fri, 28 Mar 2025 at 00:58, Rui Barradas wrote: > Às 18:35 de 27/03/2025, Daniel Lobo escreveu: > > Hi, > > > > I have below minimization problem > > > > > > MyDat = structure(list(c(50L, 0L, 0L, 50L, 7

[R] Problem with minimization that I failed to understand

2025-03-27 Thread Daniel Lobo
Hi, I have below minimization problem MyDat = structure(list(c(50L, 0L, 0L, 50L, 75L, 100L, 50L, 0L, 50L, 0L, 25L, 50L, 50L, 75L, 75L, 75L, 0L, 75L, 75L, 75L, 0L, 25L, 75L, 75L, 0L, 75L, 100L, 0L, 25L, 100L), c(75L, 0L, 0L, 50L, 100L, 50L, 75L, 75L, 100L, 25L, 0L, 25L, 100L, 0L, 50L, 0L, 25L, 25

[R] Details about the boxcox function

2025-01-23 Thread Daniel Lobo
Hi, I tried with library(MASS) methods('boxcox') # [1] boxcox.default* boxcox.formula* boxcox.lm* Then > boxcox.lm Error: object 'boxcox.lm' not found How to look into the codes of boxcox.lm? Thanks for your time [[alternative HTML version deleted]]

[R] Calculation of critical probability from lm()

2024-12-23 Thread Daniel Lobo
Hi, I tried to replicate the values of critical probabilities reported from lm() function in R as below ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2,10,20, labels=c("Ctl","Trt")) weight <- c(ctl, trt) model_c

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

2024-12-13 Thread Daniel Lobo
early 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: > > library(nloptr) > > > > set.seed(1) > > A <- 1.34 > > B <-

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

2024-12-13 Thread Daniel Lobo
da > web: https://www.john-fox.ca/ > -- > On 2024-12-13 1:45 p.m., Duncan Murdoch wrote: > > Caution: External email. > > > > > > You posted a version of this question on StackOverflow, and were given > > advice there that you ignored. > > > > nloptr

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

2024-12-13 Thread Daniel Lobo
ntraint are computed correctly? > > 50% of "your software doesn't work" in optimization are due to such errors. > > John Nash > > > On 2024-12-13 12:52, Daniel Lobo wrote: > > Hi, > > > > I have below non-linear constraint optimization problem >

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: >

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) > &g

[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,

[R] Calculation of VCV matrix of estimated coefficient

2024-09-04 Thread Daniel Lobo
Hi, I am trying to replicate the R's result for VCV matrix of estimated coefficients from linear model as below data(mtcars) model <- lm(mpg~disp+hp, data=mtcars) model_summ <-summary(model) MSE = mean(model_summ$residuals^2) vcov(model) Now I want to calculate the same thing manually, library(