I am trying to use deltaMethod in the car library, but I am getting an odd error.
library(car) x=c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11) y=c(-0.78636545259908996, -0.48499513735893701, -0.61035206318152102, -0.60156864486986295, -0.61323703005521701, -0.33091952573467498, -0.269895273193686, -0.32222378534205598, -0.53183084634683997, -0.96631869084439304, -0.77105781684519603, -0.524039870915605, -0.41181303531095498, -0.27581842299642001, -0.72085673574325404, -0.35874718580022702, -0.30752543764527501, -0.090745334342823197, -0.465889655296298, -0.20115970219526799, -0.0511742487116199, 0.0100170907454752, -0.176138595601495, 0.042138062483845398, 0.00081247733328697303, -0.0045220167465173499, 0.57326735553016905, 0.116862163616526, 0.0072264835163109399, 0.48714531471859701, 0.83738659120408598, 0.83740077959237003, 0.48762419789728001, 0.20072016467283199, 0.56916547038663201, 0.14651949468445999, 0.575517323481333, 0.72715907067082697, 0.99958886855260898, 0.36070109242748599, 0.49335611371191601, 0.27098248212991599, 1.28001727666798, 0.36192955257384501) gdat=data.frame(x,y) fit=nls(y~a+b*(exp(-exp(s*(xm)))),data=gdat,start=list(a=-0.5,b=1,s=-0.6,m=5)) deltaMethod(fit,"ms*log((1/0.05)-1)")
The error I get is: Error in eval(expr, envir, enclos) : object 'ParaParam43' not found
When trying to solve this, I noticed a couple of things:
- the number after changing ParaParam depending on the specified parameters
- it works with
lm objects, although I have not tried other supported objects - in the above example,
deltaMethod(fit,"m") works, but none of the other parameters do. This can only be attributed to the fact that m is in the names(fit) . Apparently, the default method uses names(fit) instead of coef(fit) (as for other types of objects), can it be that the method does not recognize fit as an nls object? I need to tell deltaMethod what type of object to expect?
I used this some time ago with the now deprecated alr3 delta.method without any problems, but now it gives the same error.
Does anyone have any ideas?
I am using R version 2.13 and car version 2.0-10
thanks