Page 1 of 1

Error "incorrect # of dimensions" with covariate.predictions

PostPosted: Mon Sep 12, 2022 9:36 am
by SamZenaida
I have a marklist named "CACG.results" with 8 models that incorporate 2 groups and 1 continuous covariate. I want to produce 4 estimates of survival for the 4 possible combinations of the 2 groups using the mean value for the continuous covariate based on the model average of the 8 models in the marklist. nocc=49
However, when I run this script:
Code: Select all
allModels85 <- covariate.predictions(CACG.results, data=data.frame(Relmed=mRelmed), indices=c(1,49,97,145), alpha = .075)

I get the error:
Error in model$results$beta.vcv[used.beta, used.beta] : incorrect number of dimensions
Interestingly, I believe this script ran fine before, and I do not get this error when estimating survival for only 1 model at a time as in the case below.
Code: Select all
MostComplex85 <- covariate.predictions(CACG.results$S.LayCamInit, data=data.frame(Relmed=mRelmed), indices=c(1,49,97,145), alpha = .075)
MostComplex85$estimates

Re: Error "incorrect # of dimensions" with covariate.predict

PostPosted: Mon Sep 12, 2022 10:44 am
by jlaake
Something must have changed if it used to work. Software? Have you tried individually with each model? It may be that one you haven't tried is causing error. Hard for me to tell with the information you provided. Also covariate.predictions and model.average.marklist use the average covariate values by default.

Jeff

Re: Error "incorrect # of dimensions" with covariate.predict

PostPosted: Mon Sep 12, 2022 7:17 pm
by SamZenaida
Individually running each model was a good idea. I found that every model except the null model listed last ran fine. I included more of my script for better context.
Code: Select all
Nest <- read_excel("C:/Users/SamZenaida/Nest.xlsx", sheet = "DataFromAccess")
mRelmed <- mean(Nest$Relmed)
Nest$lay=factor(Nest$lay)
Nest$camera=factor(Nest$camera)
nest.dp <- process.data(Nest, nocc=49, model="Nest", groups=c("lay","camera") )
nest.ddl <- make.design.data(nest.dp)
run.CACG=function()
{
  S.B0 <- list(formula=~1)
  S.lay <- list(formula=~lay)
  S.Cam <- list(formula=~camera)
  S.Init <- list(formula=~Relmed)
  S.LayCam <- list(formula=~lay+camera)
  S.LayInit <- list(formula=~lay+Relmed)
  S.CamInit <- list(formula=~camera+Relmed)
  S.LayCamInit <- list(formula=~lay+camera+Relmed)
  cml <- create.model.list("Nest")
  return(mark.wrapper(cml, data=nest.dp, ddl=nest.ddl))
}
CACG.results=run.CACG()
CACG.results
allModels85 <- covariate.predictions(CACG.results, data=data.frame(Relmed=mRelmed), indices=c(1,49,97,145), alpha = .075)
lay85 <- covariate.predictions(CACG.results$S.lay, data=data.frame(Relmed=mRelmed), indices=c(1,49), alpha = .075)
lay85$estimates
init85 <- covariate.predictions(CACG.results$S.Init, data=data.frame(Relmed=mRelmed), indices=c(1), alpha = .075)
init85$estimates
cam85 <- covariate.predictions(CACG.results$S.Cam, data=data.frame(Relmed=mRelmed), indices=c(1,97), alpha = .075)
cam85$estimates
B085 <- covariate.predictions(CACG.results$S.B0, data=data.frame(Relmed=mRelmed), indices=c(1), alpha = .075)
B085$estimates

Re: Error "incorrect # of dimensions" with covariate.predict

PostPosted: Mon Sep 12, 2022 8:36 pm
by jlaake
This is clearly a bug that I hadn't anticipated a model with a single parameter. Can only occur with something like nest survival that only has a single type of parameter. Most models have Code likely dropped to a vector instead a 1 by 1 matrix. Very likely just need to add a drop=FALSE somewhere so it maintains as a matrix. I doubt if this ever worked so you must have added the null model if it worked previously.



Jeff

Re: Error "incorrect # of dimensions" with covariate.predict

PostPosted: Tue Sep 13, 2022 9:39 am
by SamZenaida
Thanks, I added drop=FALSE and it works fine now.

Re: Error "incorrect # of dimensions" with covariate.predict

PostPosted: Tue Sep 13, 2022 11:03 am
by jlaake
You misunderstood my message. Adding drop=FALSE in the function will drop that model from the model average. I need to add drop=FALSE to some code so it doesn't drop the second dimension converting a 1 by 1 matrix to a vector. I'll patch the code and get back to you.

Re: Error "incorrect # of dimensions" with covariate.predict

PostPosted: Wed May 03, 2023 5:02 pm
by SamZenaida
Hi Jeff,
Thanks for the clarification. I see that you patched this issue, and I am trying to download the Windows package binary from GitHub to run the patched version of RMark, but I do not have access permission. How can I get a version of RMark where this bug has been resolved?

Thanks, Sam