0

Sorry for possible newbie question. I am using micEconCES package in R and keep getting the "Error in start[[i]] : subscript out of bounds" message. At first I thought it was the data - that one of my variables was needed to be transformed or something. It used to be log(raw_timeseries_data)*100, and I took away the *100 to fit my data more closely the data generated in an example.

I have tried using the methods in this post Subscript out of bounds - general definition and solution? But the problem is, when I try to look up the dimensions of the "start", it shows nothing. Here's a part of the code from the command line:


> options(error=recover)
   
> cesNlsLT <- nls( y2 ~ gamma * ( delta * x1^(-rho) + (1 - delta) * x2^(-rho) )^(-phi / rho),
data = LTTrialData, start = c(gamma = 0.5, delta = 0,5, rho = 0.25, phi = 1))

This gives:

Error in start[[i]] : subscript out of bounds


Enter a frame number, or 0 to exit   

1: nls(y2 ~ gamma * (delta * x1^(-rho) + (1 - delta) * x2^(-rho))^(-phi/rho), data = LTTrialData, start = c(gamma = 0.5,
2: nlsModel(formula, mf, start, wts)



Selection: 1
Called from: top level 
Browse[1]> ls()
[1] "algorithm"   "cl"          "control"     "data"        "env"         "form2"       "formula"     "lenVar"     
[9] "lower"       "mf"          "model"       "mWeights"    "n"           "na.action"   "not.there"   "pnames"     
[17] "respLength"  "start"       "subset"      "trace"       "upper"       "var"         "varIndex"    "varNames"   
[25] "varNamesRHS" "weights"     "wts"        

Part of my data:

Browse[1]> data
     x1       x2       y2
1  13.37293 6.310031 8.272156
2  13.39282 6.606810 8.296000
3  13.31085 6.386308 8.292540
4  13.33683 6.680705 8.275467
5  13.40671 6.347887 8.317865
6  13.40392 6.456606 8.314906

dimensions of my data:

Browse[1]> dim(data)
[1] 75  3

And when I try to browse the dimensions of "start" ir gives me

NULL

Browse[1]> dim(start)
NULL:

But the "start" itself is:

Browse[1]> start
gamma delta         rho   phi 
 0.50  0.00  5.00  0.25  1.00 

Could this be due to inappropriate parameter setting of gamma, delta, rho and phi? My problem is, I have no idea how to set them. I was kind'a hoping that this micEconCES package was for that - production function parameter estimation. But I'm just trying it out, and thought that I'd just wing it with the same parameters that were given in an example where randomly generated data is used.


Edit: user jav here pointed out that it was a typo in the values of my parameters. I had written a colon where a point should have been. I have corrected it, but now I'm getting a completely different error.

> cesNlsLT <- nls( y2 ~ gamma * ( delta * x1^(-rho) + (1 - delta) * x2^(-rho) )^(-phi / rho), +   data = LTTrialData, start = c(gamma = 0.5, delta = 0.5, rho = 0.25, phi = 1))
> Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model
Community
  • 1
  • 1
Rokis1990
  • 36
  • 6
  • Is it perhaps because your set of start values has a typo in it? You have `c(gamma = 0.5, delta = 0,5, rho = 0.25, phi = 1)`. Should it be `c(gamma = 0.5, delta = 0.5, rho = 0.25, phi = 1)` instead? (I set delta to 0.5 rather than 0,5) – jav Feb 09 '18 at 05:45
  • You are correct, My Friend! – Rokis1990 Feb 09 '18 at 05:48
  • Thank You! Anyway, now a different error appears. I'll have to look it up later, because it's almost 8 AM... > cesNlsLT <- nls( y2 ~ gamma * ( delta * x1^(-rho) + (1 - delta) * x2^(-rho) )^(-phi / rho), + data = LTTrialData, start = c(gamma = 0.5, delta = 0.5, rho = 0.25, phi = 1)) Error in numericDeriv(form[[3L]], names(ind), env) : Missing value or an infinity produced when evaluating the model – Rokis1990 Feb 09 '18 at 05:53
  • Not very familiar with this function, or the underlying `nls` function but this post discusses what you're seeing: https://stackoverflow.com/questions/33265467/nls-troubles-missing-value-or-an-infinity-produced-when-evaluating-the-model. Perhaps experiment with the 'method' parameter to change the estimation method (see the https://cran.r-project.org/web/packages/micEconCES/micEconCES.pdf for possible values). If this does not work, you could try including upper and lower bounds for your parameters. – jav Feb 09 '18 at 06:02

0 Answers0