anspiess / propagate

Propagation of Uncertainty
6 stars 3 forks source link

nls call containing "pi" (3.14) is interpreted as a predVar #2

Open fkrauer opened 5 years ago

fkrauer commented 5 years ago

Hi

I have a nls call that contains sine, cosine and pi:

nls(temperature ~ a + b*sin(2*pi/365*day) + c*cos(2*pi/365*day) + d*sin(4*pi/365*day)+ e*cos(4*pi/365*day), data=climate, start=list(a=10, b=1, c=1, d=1, e=1))

I tried predictNLS(), but it threw me a cryptic error. When I went to each of the steps in the function, I realized that the error occurs where the names of the predictors are extracted from the expression:

VARS <- all.vars(EXPR)

which gives "pi" and "day", which is wrong (it should only be "day"). The problem is that all.vars interprets "pi" as a variable. Is there a clean solution to this or do I have to go with 3.14 in the call? Interestingly "sin" and "cos" are interpreted properly.

Best, Fabienne