extra individual covariate values

questions concerning analysis/theory using program MARK

extra individual covariate values

Postby markmiller » Tue Apr 25, 2023 9:40 pm

I have been creating dynamic occupancy models in RMark with 126 seasons, 252 occasions (two per season) and two groups. I also have been using 630 individual covariates in the input *.inp data file. Today I tried recreating the best model directly in MARK because I understand the design matrix in MARK better and just wanted to ensure I got the same estimates both ways. However, MARK keeps returning the following warning which I do not recall seeing in RMark:

* * WARNING * * Number of encounter history records found with extra individual covariate values was [all of them].


I think the problem is that MARK has trouble reading extremely long lines of input data. I use the following R code to create meaningless stochastic data and individual covariate values. If the total number of visits (n.visits) is 20, 40 or 100 I do not get the warning. If I use 200 or 252 total visits (n.visits) I get the warning in MARK.

Code: Select all
set.seed(1234)

n.histories <- 40
n.visits    <- 200   # 252 visits returns a warning but 20 visits does not and 100 visits does not
n.seasons   <- n.visits / 2
histories   <- rep(0, n.histories)

for(i in 1:n.histories) {
     detections   <- sample(c(0,1), n.visits, replace = TRUE)
     histories[i] <- paste0(detections, collapse = '')
}

histories <- data.frame(ch = histories)

varA <- matrix(runif(n.seasons,-1,1), nrow=n.histories, ncol=n.seasons, byrow=TRUE)
varB <- matrix(runif(n.seasons,-1,1), nrow=n.histories, ncol=n.seasons, byrow=TRUE)
varC <- matrix(runif(n.seasons,-1,1), nrow=n.histories, ncol=n.seasons, byrow=TRUE)
varD <- matrix(runif(n.seasons,-1,1), nrow=n.histories, ncol=n.seasons, byrow=TRUE)
varE <- matrix(runif(n.seasons,-1,1), nrow=n.histories, ncol=n.seasons, byrow=TRUE)

varA <- round(varA,2)
varB <- round(varB,2)
varC <- round(varC,2)
varD <- round(varD,2)
varE <- round(varE,2)

varA <- as.data.frame(varA)
varB <- as.data.frame(varB)
varC <- as.data.frame(varC)
varD <- as.data.frame(varD)
varE <- as.data.frame(varE)
colnames(varA) <- paste0('varA', 1:n.seasons)
colnames(varB) <- paste0('varB', 1:n.seasons)
colnames(varC) <- paste0('varC', 1:n.seasons)
colnames(varD) <- paste0('varD', 1:n.seasons)
colnames(varE) <- paste0('varE', 1:n.seasons)

group1  <- c(rep(1, round(n.histories/2)), rep(0, (n.histories - round(n.histories/2))))
group2  <- c(rep(0, (n.histories - round(n.histories/2))), rep(1, round(n.histories/2)))

the_end <- rep(' ; ', n.histories)

mydata <- data.frame(histories, group1, group2, varA, varB, varC, varD, varE, the_end)
dim(mydata)
mydata

write.table(mydata, 'myfakedata200Apr252023.inp', col.names = FALSE, row.names = FALSE, quote = FALSE)

write.table(names(mydata), 'names_myfakedata200Apr252023.txt', col.names = FALSE, row.names = FALSE, quote = FALSE)


I can check my RMark code by reducing the number of total visits to maybe 100 and creating the same model with MARK and RMark. I just wanted to post this here because I do not recall seeing this warning before and no results are found when I search the internet for this warning.
markmiller
 
Posts: 49
Joined: Fri Nov 08, 2013 6:23 pm

Re: extra individual covariate values

Postby jhines » Wed Apr 26, 2023 8:21 am

It appears you've exceeded the max input line length in Mark. If you check the option to list the input data, then examine the output, you'll see that a space was inserted in one of the covariate values (-0.84). This caused Mark to think there are 501 covariates instead of 500.

INPUT --- 0.8 -0.91 -0 .84 0.5 0.74

This corresponds to position, 2050 in each input line.

To fix, I suggest writing the input text file using the R functions "sink" and "cat" so that you can break the input lines into shorter strings. For example,

sink('myfakedata200Apr262023.inp')
for (i in 1:nrow(mydata)) {
cat(unlist(histories)[i], group1[i], group2[i], unlist(varA[i,]), unlist(varB[i,]),
'\n',unlist(varC[i,]), unlist(varD[i,]), unlist(varE[i,]),';\n')
}
sink()
jhines
 
Posts: 599
Joined: Fri May 16, 2003 9:24 am
Location: Laurel, MD, USA

Re: extra individual covariate values

Postby jhines » Wed Apr 26, 2023 8:26 am

By the way, I assume your real data will have different covariate values for each site (row). If your real data has the same covariate values for each row (like the fake data), then you don't need individual covariates. You can input those numbers into the design matrix directly.
jhines
 
Posts: 599
Joined: Fri May 16, 2003 9:24 am
Location: Laurel, MD, USA


Return to analysis help

Who is online

Users browsing this forum: Google [Bot] and 11 guests