[Basta-users] help with error in FUN(newX[,i], ...)

caroline caroline.chong at anu.edu.au
Fri Nov 1 14:01:02 CET 2013


Dear All,

I am running a simple Gompertz model with one categorical covariate, species (coded as species SPEC =  a, b, c.... ah for simplicity).
After running DataCheck with autofix set to on, I encounter the following error "in FUN(newX[,i]...)" - would you have any experience with a similar situation, and could provide any help or suggestions on how to interpret and trouble-shoot the problem? I am unsure as to how to decipher where the error lies.
N.b. this data set seems to run ok when I do not include the covariate matrix.

Very grateful for your help,
best regards
Caroline.

Caroline Chong
Postdoctoral Fellow
Research School of Biology
Australian National University, Canberra ACT

speciesout <- basta(object = inputMat2$newData, studyStart = 1, studyEnd = 109, covarsStruct = "all.in.mort", nsim = 4, parallel = TRUE, ncpus = 4, updateJumps = TRUE, niter = 100000)
No problems were detected with the data.

Error in FUN(newX[, i], ...) : invalid 'type' (character) of argument

#all commands below
captHist <- read.csv("CaptHist.csv")
source("CensusToCaptHist.R")

captHist$Date <- as.Date(captHist$ROBSDATES)
captHist$julDay <- julian(captHist$Date)
captHist$DayOfStudy <- (captHist$julDay - min(captHist$julDay))+1
Y <- CensusToCaptHist(captHist$ID, captHist$DayOfStudy, timeInt="D")

#Y[,2:length(Y[1,])] <- sapply( Y[,2:length(Y[1,])], as.integer )
y <- Y

y[,2:110] <- sapply(y[,2:110], as.character)
y[,2:110] <- sapply(y[,2:110], as.numeric)
y[y[,1]==2,]

birthDeath <- read.csv("penults_birthdeath.csv")
birthDeath2 <- birthDeath

covarsRaw <- read.csv("specalphcode_covars.csv")
df1 = data.frame(SPEC = covarsRaw$SPEC)

install.packages("BaSTA", repos="http://R-Forge.R-project.org",type="source")
library("BaSTA")
covars <- MakeCovMat(x = "SPEC", data = df1)

inputMat <- merge(birthDeath2, y, by.x = "ID", by.y = "ID")
inputMat <- merge(inputMat, covars, by.x = "ID", by.y = "ID")
inputMat2 <- DataCheck(inputMat, studyStart = 1, studyEnd = 109, autofix = rep(1, 7), silent = FALSE)

speciesout <- basta(object = inputMat2$newData, studyStart = 1, studyEnd = 109, nsim = 4, parallel = TRUE, ncpus = 4, updateJumps = TRUE, niter = 100000)

$newData
     idnames birth death X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24 X25 X26 X27 X28 X29
1          1     0    68  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
2          2     0    68  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





More information about the Basta-users mailing list