Error "incorrect # of dimensions" with covariate.predictions

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

Error "incorrect # of dimensions" with covariate.predictions

Postby SamZenaida » Mon Sep 12, 2022 9:36 am

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
SamZenaida
 
Posts: 4
Joined: Sat Sep 10, 2022 7:03 pm

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

Postby jlaake » Mon Sep 12, 2022 10:44 am

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
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

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

Postby SamZenaida » Mon Sep 12, 2022 7:17 pm

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
SamZenaida
 
Posts: 4
Joined: Sat Sep 10, 2022 7:03 pm

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

Postby jlaake » Mon Sep 12, 2022 8:36 pm

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
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

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

Postby SamZenaida » Tue Sep 13, 2022 9:39 am

Thanks, I added drop=FALSE and it works fine now.
SamZenaida
 
Posts: 4
Joined: Sat Sep 10, 2022 7:03 pm

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

Postby jlaake » Tue Sep 13, 2022 11:03 am

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.
jlaake
 
Posts: 1417
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

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

Postby SamZenaida » Wed May 03, 2023 5:02 pm

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
SamZenaida
 
Posts: 4
Joined: Sat Sep 10, 2022 7:03 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 13 guests