Page 1 of 1

Adding groups/covariates in RMark

PostPosted: Sun Jan 08, 2023 12:20 pm
by abdnas
Apologies for the basic question, but how do you add groups/covariates in RMark? Here's my code:

Code: Select all
surv_dat <- read.csv("CJStestBDA.csv")
                  header = T, na.strings = c("", "N/A", "NA")
str(surv_dat)

write.table(surv_dat,file="BvrEncHistFINAL_ForCJS_20230107.inp", sep=" ",
            quote=F, col.names=F, row.names=F)

surv_age <- convert.inp("BvrEncHistFINAL_ForCJS_20230107.inp",
                        group.df=data.frame(Age=c("0", "1")),
                        covariates=data.frame(BDA=c("0", "1")))


I want Age to be a group and BDA to be a covariate. When I try to use convert.inp I get the error:

Code: Select all
"Error in convert.inp("BvrEncHistFINAL_ForCJS_20230107.inp", group.df = data.frame(Age = c("0",  :
 
Number of columns in data file does not match group/covariate specification

Re: Adding groups/covariates in RMark

PostPosted: Sun Jan 08, 2023 12:29 pm
by cooch
abdnas wrote:Apologies for the basic question...


Which largely indicates you haven't read either Appendix C in the MARK book, or the workshop notes.

Re: Adding groups/covariates in RMark

PostPosted: Sun Jan 08, 2023 1:08 pm
by jlaake
Please read the documentation and help files. Have you read Appendix C in Cooch and White and/or the workshop
notes which are in the RMark documentation archive which is available via the link that is given when you type library*RMark) for the first time in a session.

The function convert.inp is for converting a file in MARK format to the RMark format. You can read the data in directly as you did with read.csv ( or other R functions)but you have to make sure that the capture history is a character variable. The function import.chdata was designed to read in a data file in RMark format and make sure character is a character variable but you do not need to use it.

Once you get the data file read in properly, you specify a group variable with the argument groups in process.data.
Any numeric variable in the data can be used as covariate. Group variable must be a factor variable. All of this is explained in the documentation.

Jeff

Re: Adding groups/covariates in RMark

PostPosted: Sun Jan 08, 2023 9:35 pm
by cooch
cooch wrote:
abdnas wrote:Apologies for the basic question...


Which largely indicates you haven't read either Appendix C in the MARK book, or the workshop notes.


Said workshop notes (and other very useful bits) are collated in a single .zip archive: http://www.phidot.org/software/mark/rma ... tation.zip

Said 'Appendix C' is found here: http://www.phidot.org/software/mark/doc ... /app_3.pdf

Re: Adding groups/covariates in RMark

PostPosted: Sun Jan 08, 2023 10:05 pm
by abdnas
Thank you both for the resources.