<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div style="word-wrap:break-word">
<div>Dear BaSTA</div>
<div><br>
</div>
<div>Owen, and Fernando - thanks for your assistance with my previous birth-death coding issue (rowSums error)- happy to report that I was able to re-code this successfully and DataCheck now passes with no errors.</div>
<div><br>
</div>
<div>However I am running into the below two errors - would you be able to solve or decipher what the issue is? Firstly in the final compiled matrix (im2 = inputMat), every single observation now has a recorded Death observation whereas this is not the case
in my input birthDeath matrix. I tried editing this via bd.na (below code) but this didn't work. Is there some possible issue when reading 0s in the birth and death columns?</div>
<div><br>
</div>
<div>##e.g. original births and deaths observation matrix</div>
<div>
<div>> head(birthDeath)</div>
<div> ID birth death</div>
<div>1 1 0 68</div>
<div>2 2 0 68</div>
<div>3 3 0 0</div>
<div>4 4 1 0</div>
<div>5 5 1 0</div>
<div>6 6 1 0</div>
<div>## whereas final merged matrix below shows:</div>
</div>
<div>
<div>> head(im2)</div>
<div>ID birth death 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40</div>
<div>1 1 0 53 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0</div>
<div>10 2 0 99 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0</div>
<div>100 3 0 99 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0</div>
<div>1000 4 8 103 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0</div>
<div>1001 5 8 103 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0</div>
<div>1002 6 8 103 0 0 </div>
</div>
<div>
<div>> dc <- DataCheck(im2, studyStart = 1, studyEnd = 109, autofix = rep(1, 7), silent=FALSE)</div>
<div>No problems were detected with the data.</div>
<div><br>
</div>
<div>*DataSummary*</div>
<div>- Number of individuals = 1,720 </div>
<div>- Number with known birth year = 1,428 </div>
<div>- Number with known death year = 1,720 </div>
<div>- Number with known birth</div>
<div> AND death years = 1,428 </div>
<div><br>
</div>
<div>- Total number of detections</div>
<div> in recapture matrix = 10,339 </div>
<div><br>
</div>
<div>- Earliest detection time = 1 </div>
<div>- Latest detection time = 109 </div>
<div>- Earliest recorded birth year = 1 </div>
<div>- Latest recorded birth year = 107 </div>
<div>- Earliest recorded death year = 2 </div>
<div>- Latest recorded death year = 109 </div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Secondly on running basta (run time to error 20mins) I get returned e.g.</div>
<div><br>
</div>
<div>> out <- basta(object = im2, studyStart = 1, studyEnd = 109)</div>
<div>
<div>No problems were detected with the data.</div>
<div><br>
</div>
<div>Starting simulation to find jump sd's... done.</div>
<div><br>
</div>
<div>Simulation started...</div>
</div>
<div><br>
</div>
<div><b>Error in `colnames<-`(`*tmp*`, value = c("b0", "b1")) : </b></div>
<div><b> length of 'dimnames' [2] not equal to array extent</b></div>
<div><br>
</div>
<div> It appears that the dimensions of the matrix are not 2 - is this correct?, which I am unsure how to interpret or fix.</div>
<div><br>
</div>
<div>looking forward to hearing back,</div>
<div>many thanks for your help,</div>
<div>best regards</div>
<div>Caroline.</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div><br>
</div>
<div>cv <- read.csv("~/CaptHist.csv")</div>
<div>rd <- cv$ROBSDATES</div>
<div>class(rd)</div>
<div>sum(is.na(cv))</div>
<div>rd<-as.Date(rd)</div>
<div>Y <- CensusToCaptHist(ID = cv[,1], d=rd, timeInt="D")</div>
<div>head(Y)</div>
<div>sum(is.na(cv))</div>
<div><br>
</div>
<div>birthDeath <- read.delim("~/penults_birthdeath.csv", sep=",", header=T)</div>
<div><br>
</div>
<div>bd.na <- t( # the below returns a transposed matrix, so we have to re-transpose it back to normal</div>
<div> apply( # foreach row (hence 1) in the birth dates matrix</div>
<div> birthDeath, 1,</div>
<div> function(r) { # apply by row this function (hence r)</div>
<div> if(r[2] == 0) { # if birth [2] is 0</div>
<div> r[2] <- NA # replace birth value with NA (R's missing data value)</div>
<div> }</div>
<div> if (r[3] == 0) { # if death [3] is 0</div>
<div> r[3] <- NA # replace death value with NA (R's missing data value)</div>
<div> }</div>
<div> return(r) # return the whole row</div>
<div> }</div>
<div> ))</div>
<div><br>
</div>
<div>table(is.na(bd.na[,3]))</div>
<div>BD <- bd.na</div>
<div>head(BD)</div>
<div>covar <- read.delim("~/fixed_covars.csv", sep=",", header=T)</div>
<div>head(covar)</div>
<div>covMat <- MakeCovMat(x=c("CLADE"), data = covar)</div>
<div>days <- as.numeric(colnames(Y)[2:ncol(Y)])</div>
<div>y <- as.matrix(Y)</div>
<div>bd <- apply(y,1,function(r) min(as.numeric(days[as.logical(r[2:ncol(Y)])]))) -1</div>
<div>dd <- apply(y,1,function(r) max(as.numeric(days[as.logical(r[2:ncol(Y)])])))</div>
<div>inputMat <- as.data.frame(cbind(BD, Y[, -1], covMat[, -1]))</div>
<div>##inputMat <- merge(BD, Y, by.x = "ID", by.y = "ID")</div>
<div>##inputMat <- merge(inputMat, covMat, by.x = "ID", by.y = "ID")</div>
<div>dim(inputMat)</div>
<div>colnames(inputMat)</div>
<div>im2 <- inputMat</div>
<div>im2[,2] <- bd</div>
<div>im2[,3] <- dd</div>
<div>head(im2)</div>
<div>dc <- DataCheck(im2, studyStart = 1, studyEnd = 109, autofix = rep(1, 7), silent=FALSE)</div>
<div>names(dc)</div>
<div>head(inputMat)</div>
<div># outMat <- dc$newData</div>
<div>out <- basta(object = im2, studyStart = 1, studyEnd = 109)</div>
</div>
</div>
<div><br>
</div>
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
</div>
</body>
</html>