Hi Murray,
Thanks for your last email.
I have a new question about plotting confidence intervals (shaded area) around the regression spline (relationship between density and spatial covariate).
Is there any easy way to do so in secr?
This is the code I use to produce the regression spline from my model m35:
rdh.m35 <- predict(m35, newdata = data.frame(ruggedness = seq(0,200, length = 300), session =c("A","B", "C", "D", "E", "F"), h2 = 2) )
plot(seq(0,200, length = 300), bty="n", pch = 19, cex = 2, sapply(rdh.m35, "[", "D", "estimate"), xlab = "", ylab = "", yaxt = "n", xaxt = "n")
Please note (in relation to my previous question), that in the
newdata dataframe of the
predict() function, it was important to:
1) specify ALL covariates that are defined in the model
Otherwise R returns error messages such as:
2) mention ALL factor levels for these covariates (eg session = "A" was incorrect)
Otherwise R returns error messages such as:
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels