0

I have the following issue when trying to use the nlm() function in R to find optimal values for a_o & b_o.
I have X : a table with 10k + rows and with 6 columns
Some columns of X are variables in the function I want to minimize. It's an MSE function.

f <- function(X, a_o, b_o) 
  {
  ((X$Td) - (((b_o*((a_o*X$T)/(b_o+X$T)) + log(X$U/100))/(a_o-((a_o*X$T)/(b_o+X$T)) + log(X$U/100)))))^2

  }
nlm(f, input, a_o=c(-1000,1000), b_o=c(-1000,1000))

I have this error message when I try to run it :

Error in Ops.Date(left, right) : / not defined for "Date" objects`

Input sample : https://image.noelshack.com/fichiers/2019/47/7/1574604926-sample.png

  • Could you share a sample of `input`? The issue is as the error states to do with dividing dates. Omit them maybe? – NelsonGon Nov 24 '19 at 14:05
  • I added a picture of Input – shootermanPOOL Nov 24 '19 at 14:17
  • 1
    You can add data to your post using `dput`. Either remove date from the data or exclude it when adding `input` to `nlm`. Is it a need model parameter? – NelsonGon Nov 24 '19 at 14:35
  • I have deleted the columns with date values but the code remains incorrect. I try to optimize to value for a_o & b_o having a large sample of combinaisons for the other values : Td, T, & U. the function seems as it does not accept non-numeric input. – shootermanPOOL Nov 24 '19 at 15:10

0 Answers0