> str(umf) Formal class 'unmarkedMultFrame' [package "unmarked"] with 7 slots ..@ numPrimary : num 3 ..@ yearlySiteCovs:'data.frame': 567 obs. of 1 variable: .. ..$ season: Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 1 2 3 1 ... ..@ y : int [1:189, 1:9] 0 0 0 0 0 0 0 0 0 0 ... .. ..- attr(*, "dimnames")=List of 2 .. .. ..$ : NULL .. .. ..$ : chr [1:9] "det.sp1" "det.sp2" "det.sp3" "det.su1" ... ..@ obsCovs :'data.frame': 1701 obs. of 2 variables: .. ..$ wind: num [1:1701] 19.1 3 5.9 4.1 13.2 5.4 14.2 6.1 5.8 20.7 ... .. ..$ date: num [1:1701] 6 33 75 96 123 162 186 217 255 6 ... ..@ siteCovs :'data.frame': 189 obs. of 8 variables: .. ..$ ag : num [1:189] 0 0 0.053 0.565 0 ... .. ..$ btpd : num [1:189] 0 0 0 0 0.636 ... .. ..$ dev : num [1:189] 0 0.0086 0 0 0.00938 ... .. ..$ gr : num [1:189] 0.972 0.843 0.865 0.417 0.333 ... .. ..$ water: num [1:189] 0 0.1356 0.0723 0 0 ... .. ..$ road : num [1:189] 0.02803 0.01317 0.00927 0.01826 0.02219 ... .. ..$ sc : num [1:189] 0 0 0 0 0 0 0 0 0 0 ... .. ..$ well : num [1:189] 5.97 9.95 0 5.97 17.91 ... ..@ mapInfo : NULL ..@ obsToY : num [1:9, 1:9] 1 0 0 0 0 0 0 0 0 0 ...
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Error in factor(levels = c(unique(season)), date = seq(4, 282, length = 282)) : unused argument(s) (date = seq(4, 282, length = 282))
I tried other permutations of this variety and can't figure it out. My intent was to plot detection probability as a function of Julian date while holding all other factors in the model constant (zero). To move forward, I came up with this alternative solution that removed all the other covariates in the detection process, leaving "date" (data.frame of 9 columns) as the sole covariate that influenced detection.
detect <- colext(~1,~1,~1,~date,data=umf)
nd <- data.frame(date=seq(4,282,length=282))
E.p <- predict(detect, type="det", newdata=nd, appendData=TRUE)
##Plot it:
with(E.p,{
plot(date,Predicted,ylim=c(0,0.65),type="l",
xlab="Julian Date",
ylab=expression(italic(p)),cex.lab=0.8,cex.axis=0.8)
lines(date,Predicted+1.96*SE,col="black", lty=2,lwd=1)
lines(date,Predicted-1.96*SE,col="black", lty=2,lwd=1)
legend("topleft",c("Fitted Regression Line", "95% Confidence Interval"),
bty="n",lty=c(1,2),lwd=c(1,1),col=c("black","black"),cex=0.8)
})
The plot (attached) makes sense to me. Not the prettiest code or the most sophisticated solution but I believe it gets it done.
My question: by removing the other detection covariates in the best fit model (levels I intended to set to 0) and focusing solely on detection probability by date am I losing detection information that would be used with this abbreviated model and the possible solution you provided below?
I think the answer is "clunky but OK" but wanted to check back with you.
Thanks so much, Erik
Hi Erik,
I think there is a misplaced bracket in there:
nd <- data.frame(gr=0, wind=0, season=factor("sea.1",levels=c(unique(season)), date=seq(4,282,length=282)))
should read
nd <- data.frame(gr=0, wind=0, season=factor("sea.1",levels=c(unique(season))), date=seq(4,282,length=282))
which I think is the source of this particular error message.
Chris
Error in unique(season) : object 'season' not found
...which is odd because my model selection steps, Empirical Bayes estimates of occupancy by season and linear combinations by season all work OK. I checked the umf where I define season, I just don't get it. I think I found the workaround as I stated above and unless I hear that my the alternative approach is patently wrong I'm going for it!
Cheers, Erik
Error in unique(season) : object 'season' not found
> head(YRCOVS)
id sea.1 sea.2 sea.3
1 1 1 2 3
2 2 1 2 3
3 3 1 2 3
nd <- data.frame(gr=0, wind=0, season=factor(2,levels=c(1,2,3)), date=seq(93,184,length=282))
E.p <- predict(fms$fm1, type="det", newdata=nd, appendData=TRUE)
with(E.p,{
plot(date,Predicted,ylim=c(0,1.0),type="l",
xlab="Julian Date",
ylab=expression(italic(p)),cex.lab=0.8,cex.axis=0.8)
lines(date,Predicted+1.96*SE,col="black", lty=2,lwd=1)
lines(date,Predicted-1.96*SE,col="black", lty=2,lwd=1)
legend("topleft",c("Fitted Regression Line", "95% Confidence Interval"),
bty="n",lty=c(1,2),lwd=c(1,1),col=c("black","black"),cex=0.8)
})
...which plots the detection probability during the second "season". The different scale certainly changes the slope of the line, compared to the probability over the entire season. Thanks again for all the helpful suggestions. Erik
--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "unmarked" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/unmarked/5UnUR4Ui4wA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to unmarked+u...@googlegroups.com.