Hi
Please help with below erratic error in Rmarkdown.
When I run the R & Rmarkdown below which is based on the example code from bbmle vignette p21, it works within the source editor and plots a Square Root of deviance chart similar to those from the example code.
However, when I knit to HTML this code fails with the message:
Line 186 Error inUseMethod(”profile”) :
no applicable method
for ‘profile' applied
to an object of class
“mle2” calls:
... handle
-> withcallingHandlers
-> withvisible -> eval
-> eval Execution
halted
However, profile is shown in the bbmle example and so I dont understand this error or why the same code works fine when testing in the source editor.
Package bbmle2
M12 dataframe:
"spd" | "test" |
---|---|
-0.192 | 244 |
-0.0920000000000001 | 850 |
-0.0559999999999998 | 2800 |
-0.40 | 95 |
-0.31 | 490 |
n.max <- max(M12$test)
n.min <- min(M12$test)
k=10
(fit<-mle2(test~dpois((n.max - n.min)/(1+exp(-(k*spd))) + n.min),data=M12,start=list(k=10)))
p1 <- suppressWarnings(profile(fit))
d1 <- as.data.frame(p1)
library(lattice)
xyplot(abs(z)~focal|param,data=d1,
subset=abs(z)<3,
type="b",
xlab="",
ylab=expression(paste(abs(z),
" (square root of ",Delta," deviance)")),
scale=list(x=list(relation="free")))