#data (rows) at the site (n = 50) level
covs <- read.csv("file/path/habitat.csv")
#example of covariates (to be used as detection covariates)
jdate<-(dists$day.julian)
daytime<-(dists$time.hour.num)
#example of habitat variables (to be used as density/abundance predictors)
tcov<-(covs$tree.cover)
FHD<-(covs$foliage.heigh.diversity)
covspoint<-covs$point)
head(dists, 1108)
#'point' contains character+numerical site names (e.g., 'sweco03')
levels(dists$point) <- c(levels(dists$point), "sweco03")
levels(dists$point)
yDat <- formatDistData(dists, distCol = "distance.m", transectNameCol = "point", dist.breaks = c(0,10,20,30,40,50,60,70,80,90,100), occasionCol = "survey")
yDat
covs <- data.frame(tcov, sFHD, row.names = covspoint)
#individual observations were recorded at 10-m distance intervals to 100-m; numPrimary = 3 surveys over the season
umf <-unmarkedFrameGDS(y = as.matrix(yDat), siteCovs = covs, survey = "point", dist.breaks = c(0,10,20,30,40,50,60,70,80,90,100), unitsIn = "m", numPrimary = 3)
summary(umf)
#to determine the best detection function
hn_Null <- gdistsamp (~1, ~1, ~1, umf, keyfun = "halfnorm", output = "density", unitsOut = "ha")
haz_Null <-gdistsamp (~1, ~1, ~1, umf, keyfun = "hazard") #lowest AIC
uni_Null <- gdistsamp (~1, ~1, ~1, umf, keyfun = "uniform")
exp_Null <- gdistsamp (~1, ~1, ~1, umf, keyfun = "exp")
#to test the fit of detection covariates
m1 <- gdistsamp (~1, ~1, ~jdate, umf, keyfun = "hazard", output="density", mixture="P")
m2 <- gdistsamp (~1, ~1, ~daytime, umf, keyfun = "hazard", output="density", mixture="P")
#When I attempt to run these models, I get the "*In lambda * A : longer object length is not a multiple of shorter object length*" warning message.
*********END CODE*********
I think this may have something to do with the fact that the detection covariates have not been reformatted as a data.frame. If so, could someone please provide me some advice on how to product such a data frame so that the row names will be equivalent to those for both the individual observation-level data (row n=1108) and the site-level habitat data (row n = 50)?
Thank-you in advance,
Rachel