0

I'm trying to calculate several BoxCox lambda parameters, for a list of several time-series using the line of code below. I'm getting the error below. I've tried googling the error with no luck, if someone could please point out the issue I'd be grateful.

Code:
testRun<-do.call(BoxCox.lambda, args=ListData)

Error in (function (x, method = c("guerrero", "loglik"), lower = -1, upper = 2)  : 
  unused arguments (c(310, 221.5, 215, 158, NA, NA, 255, 150.5, 126, 211, 164.5, NA, NA, 310, 216, NA, NA, 184, 149, NA, 308, NA, 221, NA, NA, 258, 310, 310, 119, 123, 101.5, NA, 81, NA, 182.5, 70.5, 138.5, 310, 188, 26, 185, 310, 310, 275, 250, 240, 186, 212, 304, 212), c(38, 3, 11, 9, NA, NA, 33, 64, 1, 28, 10.5, NA, NA, 2, NA, NA, 8, 4, 10, NA, 2, NA, NA, NA, NA, 10, 24, NA, 1, NA, NA, NA, NA, NA, 1, 1, 1, 1, 1.5, NA, 2, 4, 2, 86, 86, 2, 86, 86, 1, 86), c(0, 10.5, 22, 11, NA, NA, 19, 21, 20, 15, 15.5, NA, 
NA, 35, 29.5, NA, NA, 35, 11, NA, 35, NA, 11, NA, NA, 0, 12, 35, 26.5, 15, 22.5, NA, 6.5, NA, 10, 9.5, 22.5, 13, 23, 4, 14, 13, 12.5, 24, 0, 35, 10, 30, 17, 21), c(NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, 36.5, NA, NA, NA, NA, 99, NA, NA, NA, 92, NA, 99, 98, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, NA, 99, NA, 0, NA, NA, NA, 46, NA, NA, NA, 76, NA, NA, 78))

Data:
dput(ListData)
list(c(6, 15.5, 22, 16, NA, NA, 13, 13.5, 10, 6, 14.5, 16, NA, 
8, 11, NA, 2, 2, 10, NA, 9, NA, 11, 16, NA, 4, 17, 7, 11.5, 22, 
20.5, 10, 22, NA, 13, 17, 22, 9, 13, 19, 8, 16, 18, 22, 21, 14, 
7, 20, 21.5, 17), c(11, 4, 8, 11, 11, NA, 3, 2.5, 6, 11, 7, 1, 
NA, 6, 6, NA, 6, 11, 3, NA, 11, NA, 10, 10, NA, NA, 9, 3, 3, 
11, 8, 10, NA, NA, 11, 10, 9, 3, 7, NA, 2, 4, 11, 2.5, 3, NA, 
4, 7, 1, 5), c(33, 11, 33, 3, 12, NA, 8, 20.5, 17, 33, 22.5, 
2, NA, 16, 11, NA, 16, 28, 23, NA, 25, NA, 10, 11, NA, 12, 12, 
5, 12.5, 33, 17.5, 13, 9, NA, 22, 29, 21, 3, 7, 6, 2, 17.5, 33, 
33, 5.5, 5, 33, 8, 21.5, 5), c(337, 211, 194, 90, 337, NA, 236, 
129.5, 106, 196, 149, 225.5, NA, 302, 186.5, NA, 273, 147, 138, 
NA, 216, NA, 233.5, 123, NA, 259, 188, 323, 91, 108, 63.5, 337, 
88.5, NA, 38, 61, 148, 328, 219.5, 22, 176, 296.5, 280, 282, 
337, 170, 337, 302, 246, 289), c(310, 221.5, 215, 158, NA, NA, 
255, 150.5, 126, 211, 164.5, NA, NA, 310, 216, NA, NA, 184, 149, 
NA, 308, NA, 221, NA, NA, 258, 310, 310, 119, 123, 101.5, NA, 
81, NA, 182.5, 70.5, 138.5, 310, 188, 26, 185, 310, 310, 275, 
250, 240, 186, 212, 304, 212), c(38, 3, 11, 9, NA, NA, 33, 64, 
1, 28, 10.5, NA, NA, 2, NA, NA, 8, 4, 10, NA, 2, NA, NA, NA, 
NA, 10, 24, NA, 1, NA, NA, NA, NA, NA, 1, 1, 1, 1, 1.5, NA, 2, 
4, 2, 86, 86, 2, 86, 86, 1, 86), c(0, 10.5, 22, 11, NA, NA, 19, 
21, 20, 15, 15.5, NA, NA, 35, 29.5, NA, NA, 35, 11, NA, 35, NA, 
11, NA, NA, 0, 12, 35, 26.5, 15, 22.5, NA, 6.5, NA, 10, 9.5, 
22.5, 13, 23, 4, 14, 13, 12.5, 24, 0, 35, 10, 30, 17, 21), c(NA, 
NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, 36.5, NA, NA, NA, NA, 
99, NA, NA, NA, 92, NA, 99, 98, NA, NA, NA, NA, NA, NA, NA, 0, 
NA, NA, NA, NA, 99, NA, 0, NA, NA, NA, 46, NA, NA, NA, 76, NA, 
NA, 78))
Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55
ndderwerdo
  • 85
  • 8

1 Answers1

0

do.call treats the args argument as the arguments to a single call to the first argument.

Presumably, you want something like this instead:

testRun <- lapply(ListData, BoxCox.lambda)

However, the missing values will give you problems. You probably want to estimate them before calling BoxCox.lambda.

testRun <- lapply(ListData, function(x){BoxCox.lambda(na.interp(x))})
Rob Hyndman
  • 30,301
  • 7
  • 73
  • 85
  • Thank you for getting back to me about this. I noticed that the values returned by lapply are rounded to 3 decimal places. Do you know what would cause that, is there a setting with lapply that I can change to include more decimal places? – ndderwerdo Nov 15 '16 at 04:42
  • Why would you want more then three decimal places? – Rob Hyndman Nov 15 '16 at 04:44
  • In any case, the results are not rounded. They are computed using the `optimize` function, and the tolerance is set to `.Machine$double.eps^0.25`. – Rob Hyndman Nov 15 '16 at 04:52
  • Thank you again, I just checked some earlier code I was looking at sometimes I'm getting 4 decimal places with BoxCox.lambda and sometimes 2. So I think 3 is probably fine. My end goal is to parallelize calculating the BoxCox.lambda values. When I try parLapply(cl, ListData, function(x){lapply(ListData, BoxCox.lambda)}) it seems to calculate the lambda value for every value in each time-series, instead of for each time series. Do you know what I'm missing, or can you suggest a better way? – ndderwerdo Nov 15 '16 at 05:26