Rmark 'MSLiveDead' binary and continuous covariates

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

Rmark 'MSLiveDead' binary and continuous covariates

Postby nturner » Fri Jan 10, 2020 1:25 pm

Hi,

I've gotten stuck with Rmark and cannot seem to figure out what I have done incorrectly, I will try to explain as clearly as possible.

I am using Rmark to run a MSLiveDead analysis and have done so successfully with no covariates included... continuous or binary. However I now want to re-run the analysis with covariates including sex (M,F) and a continuous condition (K) covariate. Here is a sample of my encounter histories format

/*Wall001*/ A000A0A000000 1 M 1.031319061 ;
/*Wall002*/ A000A000A0A0B 1 F 1.128465629 ;
/*Wall003*/ A00000A0A0A0A 1 F 0.871836095 ;
/*Wall004*/ A0A000A000A0A 1 F 1.009652684 ;
/*Wall005*/ A0A00000A000A 1 F 1.073007164 ;


Here is a sample of the code I have been trying to use to bring in the encounter history .INP file to Rmark.

>setwd('C:/Users/etc..')

> wall = convert.inp(".2states_1week_sexMF_condition", group.df=data.frame(sex=c("M","F")),
covariates="condition", use.comments = TRUE)

And here is my R error output

Error in convert.inp("2states_1week_sexMF_condition", group.df = data.frame(sex = c("M", :
Row names not unique. Set use.comments to default value FALSE
In addition: Warning messages:
1: In readLines(inp.filename) :
incomplete final line found on '2states_1week_sexMF_condition.inp'
2: In data.frame(ch = ch, as.numeric(unlist(zz[, 2:(2 + number.of.groups - :
NAs introduced by coercion


If anyone could point me in the right direction I would very much appreciate it as i am not quite sure if my encounter histories file is not set up correctly or my code needs to be altered, or both...

Thanks in advance I do appreciate it.
nturner
 
Posts: 8
Joined: Mon Dec 09, 2019 3:30 pm

Re: Rmark 'MSLiveDead' binary and continuous covariates

Postby jlaake » Fri Jan 10, 2020 1:52 pm

The error message tells you what to do. Set use.comments=FALSE. The comments are used to label rows and must be unique. You also need a return on last line of file but this is not critical.
jlaake
 
Posts: 1179
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Rmark 'MSLiveDead' binary and continuous covariates

Postby nturner » Fri Jan 10, 2020 2:08 pm

Hi Jeff,

Sorry, I should have mentioned I have tried the set.comments=FALSE

This does work for getting the input file into R...

However it doubles the number of observations that I had in my original encounter history .INP file
(303 observations/individuals to 606 when importing the file into R/Rmark). Is there any way around this?
nturner
 
Posts: 8
Joined: Mon Dec 09, 2019 3:30 pm

Re: Rmark 'MSLiveDead' binary and continuous covariates

Postby jlaake » Fri Jan 10, 2020 2:31 pm

Can't tell from this. Send file and code to my email. jefflaake@gmail.com
jlaake
 
Posts: 1179
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: Rmark 'MSLiveDead' binary and continuous covariates

Postby nturner » Mon Jan 13, 2020 2:33 pm

So Jeff was able to take a look at this out off post. I've included the solution below...

Both the comment strings /* */ and the ; were removed from the encounter histories file as these are not a requirement for Rmark (necessary for MARK however). Once those were removed from the encounter histories file it was saved as a .txt file (not .inp).

New encounter history file:
A000A0A000000 1 M 1.031319061
A000A000A0A0B 1 F 1.128465629
A00000A0A0A0A 1 F 0.871836095
A0A000A000A0A 1 F 1.009652684
A0A00000A000A 1 F 1.073007164

And this code was used to load the encounter histories file into R / process data for models in Rmark

Rcode:
>wall=import.chdata("2states_1week_sexMF_condition.txt",header=FALSE,
field.names=c("ch","freq","sex","condition"),field.types=c("n","f","n"))

>wall17.processed=process.data(wall, model="MSLiveDead", groups = "sex")

>wall17.ddl=make.design.data(wall17.processed)
nturner
 
Posts: 8
Joined: Mon Dec 09, 2019 3:30 pm


Return to RMark

Who is online

Users browsing this forum: No registered users and 1 guest

cron