Getting issues with Robust Design modelling

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

Getting issues with Robust Design modelling

Postby tbow1978 » Tue Oct 24, 2023 6:00 pm

hi everyone,

I am having issues to run some robust design models using my data..but I am a pretty newborn using R studio. I have dolphin photo-ID data that was collected during 6 primary occasions (3 winters and 3 summers) and each season we ran 3 secondary occasions. So 18 secondary occasions in total. I tried to slowly learn how RMark is working and managed to make it work and finally ran few CJS models to test the program and I was also able to get some results from a model that I found and adapted the script to my data (RANDOM EMIGRATION model with constant survival, constant capture prob), and it worked.

First, for some reasons, I had to install conflicted package, because it seems that I have conflicts with other packages and I had to run this script (not sure why actually?)

Code: Select all
# install.packages("devtools")
devtools::install_github("r-lib/conflicted")
library(conflicted)
library(dplyr)
filter(mtcars, cyl == 8)
dplyr::filter(mtcars, am & cyl == 8)
library(dplyr)
conflicts_prefer(dplyr::filter)


Then, I tried to import my .inp file with my capture histories without any covariates (such ages, sexe, etc..). So my .inp file with capture histories looks like 100010010011000110 1; for one of the 718 individuals I have in my dataset.

Code: Select all
CMR_MOB_RD=convert.inp("/Users/dolphin/Documents/DISL/Data/R_file/CMR Data/MOB_CMR_D2.inp",use.comments=T)


Once properly imported, I tried to adapt this script to run RD models following this code for random movements:

Code: Select all
#Create the design data
CMR_MOB_RD.ddl=make.design.data(CMR_MOB_RD.process)

#Create time bins for GammaPrime and GammaDoublePrime
CMR_MOB_RD.ddl=add.design.data(CMR_MOB_RD.process, CMR_MOB_RD.ddl,parameter="GammaPrime",type="time",bins=c(2,3,4,5,6), name="gammaconstrain",replace=TRUE)
CMR_MOB_RD.ddl=add.design.data(CMR_MOB_RD.process, CMR_MOB_RD.ddl,parameter="GammaDoublePrime",type="time",bins=c(1,2,3,4,5,6), name="gamma2constrain",replace=TRUE)

CMR_MOB_RD.random.models=function()
{
  S.dot=list(formula=~1)
  S.time=list(formula=~time)
  p.dot=list(formula=~1+c,share=T)
  p.time.session=list(formula=~-1+session:time+c,share=TRUE)
  p.session=list(formula=~session+c,share=T)
  GammaDoublePrime.GammaPrime.random=list(formula=~1,share=T)
  GammaDoublePrime.GammaPrime.session.random=list(formula=~time,share=T)
  N.session=list(formula=~session)
  cml=create.model.list("Robust")
  results=mark.wrapper(cml,data= CMR_MOB_RD.process,ddl= CMR_MOB_RD.ddl,adjust=FALSE)
  return(results)
}
CMR_MOB_RD.random.results= CMR_MOB_RD.random.models()


I guess this is a pretty basic problem, but as I said I am completely new in using R studio and RMark. So, I would need assistance to go through the code and errors I have !
Thanks a lot..really appreciate your help!
Best,
Thibaut
tbow1978
 
Posts: 2
Joined: Fri Oct 20, 2023 10:21 am

Re: Getting issues with Robust Design modelling

Postby jlaake » Tue Oct 24, 2023 6:35 pm

I don't think the conflicted issues are because of RMark, so can't help there. You didn't actually identify what problems you were having with RMark.
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Getting issues with Robust Design modelling

Postby cooch » Tue Oct 24, 2023 6:51 pm

jlaake wrote:I don't think the conflicted issues are because of RMark, so can't help there. You didn't actually identify what problems you were having with RMark.


Because it is likely not an RMark problem at all, but more likely a package conflict issue because the OP uses RStudio. I have run into problems like this before where the problem has nothing to do with R (or, in this case RMark), but with the framing R is being used under. I now tell students that I'm not going to look at a problem they have unless they can replicate it in base R -- no RStudio or (my personal pet peeve) tidyverse (and, since the latter was developed by one of the folks involved in the former, separating the two is getting increasingly difficult).

Perhaps its time for the equivalent for RMark. ;-)
cooch
 
Posts: 1652
Joined: Thu May 15, 2003 4:11 pm
Location: Cornell University

Re: Getting issues with Robust Design modelling

Postby tbow1978 » Wed Oct 25, 2023 4:03 pm

thank you very much Evan and Jeff for your reply.
So, my first question is (and my apologies if I was not clear) do I need to install and load tidyverse and/or devtools packages when trying to run some RD models under RMark?
My second (main issue) is to be able to run these robust design models and fit them to my data to get the results and when trying different R codes and attempting to adapt them to stick with my data, I got many error messages and I don't really understand where are the issues. Did I set up the time bins wrong or something else in this code or is it an issues with the Rstudio version I am using?

Code: Select all
#Create the design data
CMR_MOB_RD.ddl=make.design.data(CMR_MOB_RD.process)

#Create time bins for GammaPrime and GammaDoublePrime
CMR_MOB_RD.ddl=add.design.data(CMR_MOB_RD.process, CMR_MOB_RD.ddl,parameter="GammaPrime",type="time",bins=c(2,3,4,5,6), name="gammaconstrain",replace=TRUE)
CMR_MOB_RD.ddl=add.design.data(CMR_MOB_RD.process, CMR_MOB_RD.ddl,parameter="GammaDoublePrime",type="time",bins=c(1,2,3,4,5,6), name="gamma2constrain",replace=TRUE)

CMR_MOB_RD.random.models=function()
{
  S.dot=list(formula=~1)
  S.time=list(formula=~time)
  p.dot=list(formula=~1+c,share=T)
  p.time.session=list(formula=~-1+session:time+c,share=TRUE)
  p.session=list(formula=~session+c,share=T)
  GammaDoublePrime.GammaPrime.random=list(formula=~1,share=T)
  GammaDoublePrime.GammaPrime.session.random=list(formula=~time,share=T)
  N.session=list(formula=~session)
  cml=create.model.list("Robust")
  results=mark.wrapper(cml,data= CMR_MOB_RD.process,ddl= CMR_MOB_RD.ddl,adjust=FALSE)
  return(results)
}
CMR_MOB_RD.random.results= CMR_MOB_RD.random.models()



Thank you very much for your assistance...as you can see I am not familair at all with Rmark (and R in general).
Best,

Thibaut
tbow1978
 
Posts: 2
Joined: Fri Oct 20, 2023 10:21 am

Re: Getting issues with Robust Design modelling

Postby cooch » Wed Oct 25, 2023 4:26 pm

No, I think you missed the point of my post. What I (and I suspect Jeff) recommend is -- ditch RStudio entirely. Test things out using base R console, with no extra bits bolted on. No RStudio, No tidyverse. No....anything except base R, and whatever package dependencies RMark installs when you install RMark.
cooch
 
Posts: 1652
Joined: Thu May 15, 2003 4:11 pm
Location: Cornell University

Re: Getting issues with Robust Design modelling

Postby jlaake » Wed Oct 25, 2023 5:05 pm

Tidyverse and devtools are NOT required for RMark. Not sure where you got the impression they are needed.

I run RMark from within Rstudio and it works fine but if you are having problems with Rstudio you might want to try regular R console as Evan suggested.

With regard to errors, you didn't show what the errors are so I have no idea. If you want you can send me your data file and R code and I can see what the problem is. Send to jefflaake@gmail.com

Jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to RMark

Who is online

Users browsing this forum: No registered users and 2 guests