- Code: Select all
library(RMark)
library(splines)
library(ggplot2)
data(dipper)
dipper.proc=process.data(dipper[dipper$sex=="Female",],model="CJS")
dipper.ddl=make.design.data(dipper.proc)
mod.Phis.pt=mark(dipper.proc,dipper.ddl,model.parameters=list(Phi=list(formula=~bs(Time))))
predPhi <- summary(mod.Phis.pt, se=TRUE)$real$Phi[1:6,]
pred.sm <- data.frame(spline(predPhi$Time, predPhi$estimate, n=100))
pred.sm$lcl <- spline(predPhi$Time, predPhi$lcl, n=100)$y
pred.sm$ucl <- spline(predPhi$Time, predPhi$ucl, n=100)$y
p <- ggplot(aes(x=x, y=y), data=pred.sm)
p <- p + geom_line() + geom_ribbon(aes(ymin=lcl, ymax=ucl), alpha=0.25) +
ggtitle("Female dipper survival\n") + xlab("Time") + ylab("Phi(t)")
p
The default is 3 degrees of freedom and the above will work with the existing version of RMark. However, if you want to specify the degrees of freedom as in ~bs(Time,df=4) then you need version 2.1.5 of RMark at:
https://docs.google.com/folder/d/0B77g1ScdUwVeOVJNUVVGS0YtWE0/edit?usp=sharing
I had to make the output extraction code smarter so it didn't trip on the = sign. You need the splines package to use bs and for the above code you need ggplot2 to produce the plot.
I keep the newest version of RMark and other software at the above location. To use the new version, you need to download the appropriate zip file and then use in the R menu, Packages/Install package from local zip. Browse to the location of the downloaded file and select it to install.
regards --jeff