Re: [R-sig-eco] Using the mra package in R...

2013-08-26 Thread Adam Fawcett
Hi Sarah and all

Thanks for those couple of tips. They did help to show that the data
imported alright but that there was a distinct difference between my data
set and the example data set for used to demonstrate the mra package.

I have attached subset of my data as suggested. Its formatted as a
tab-delimited text file with row names included (bird band numbers). I have
tried importing with and without row names but this doesn't appear to make
any difference.

To import to R, I have been using the following process.

brtb - read.table (file=filepath\\brtb.txt, header = TRUE, row.names =
1, sep = , colClasses=numeric)

Inspecting the data using str(brtb) provides the following

'data.frame':   65 obs. of  19 variables:
 $ C1 : num  0 0 0 0 0 0 0 0 1 1 ...
 $ C2 : num  1 1 0 0 0 0 0 0 0 0 ...
 $ C3 : num  1 0 1 1 1 1 1 1 0 0 ...
 $ C4 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C5 : num  0 0 0 0 1 0 0 0 0 0 ...
 $ C6 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C7 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C8 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C9 : num  0 0 0 0 0 0 0 0 0 0 ...
 $ C10: num  0 0 0 0 0 0 0 0 1 0 ...
 $ C11: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C12: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C13: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C14: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C15: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C16: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C17: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C18: num  0 0 0 0 0 0 0 0 0 0 ...
 $ C19: num  0 0 0 0 0 0 0 0 0 0 ...

The comparative example I am looking at from the mra package is the
dipper.histories data. Inspecting this with str(dipper.histories) provides
the following

 num [1:294, 1:7] 1 1 1 1 1 1 1 1 1 1 ...
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:294] 1 2 3 4 ...
  ..$ : chr [1:7] h1 h2 h3 h4 ...

There is an obvious difference in the returned output from the str()
function. Inspection of both data frames shows they are formatted in a
similar way, or at least appear to be.

With respect to the function I am attempting to run in mra, I have run the
examples routines as described in the mra manual using the supplied data.
Results as described. In attempting this on any of my own data as attached
I get an error message. The function I am trying to run is as follows

brtb.cjs = F.cjs.estim(
~x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17+x18,
~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17, brtb)


Each time I get the following error

Error in F.cjs.estim(~x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 +  :
  Capture histories must consist of 0's, 1's, and 2's only.

I have checked thru the data-set to make sure the data matches these
requirements, that there are no additional characters in the data-set, etc.
and keep getting the same error. Have tried a different subsets of the
data, different import options, etc. but still no success.

Am assuming the error lies with the format of the data imported to R but
cannot work out where or how to adjust to match the example.

Any suggestions or advice on this one would be greatly appreciated.

Cheers

Adam...


On 25 August 2013 23:33, Sarah Goslee sarah.gos...@gmail.com wrote:

 Hi,

 The first thing to do is str(yourdata) to double-check that your data
 import worked as expected. Particularly check that your data column isn't
 actually of mode factor.

 If that doesn't give you a lead on solving the problem, posting a
 reproducible example here with a subset of your data provided using dput()
 and the actual code you used will get you concrete answers, rather than
 random guesses.

 Sarah


 On Sunday, August 25, 2013, Adam Fawcett wrote:

 Have been trying to analyse life history data collected from a long term
 mark-recapture study of birds using the package mra. While the analysis
 works fine on the supplied example dataset, I keep getting error messages
 when running my data thru the F.cjs.estim function. Error message states
 that the data for this analysis must be either 1, 2 or0's. Have triple
 checked my data and its all 1  0's as required.

 Problems is likely to be an issue with either the read.table function to
 import my data (all correctly formatted and transformed ready for the
 analysis, possibly adding a character I have been able to remove, or with
 the mra package itself.

 Does anyone have experience using mra that could lend some advice.
 Alternatively, has anyone struck this sort of problem before that could
 suggest how to correct the problem.

 -



 --
 Sarah Goslee
 http://www.stringpage.com
 http://www.sarahgoslee.com
 http://www.functionaldiversity.org




-- 

*Adam Fawcett
**Lecturer (GSE854 and GSE856)
*Department of Environment and Geography
Macquarie University
NSW 2109 Australia

M: + 61 427 929 554
 http://mq.edu.aumq.edu.au


CRICOS Provider Number 2J

Please consider the environment before printing this email.
 This email (including all attachments) is confidential. It may be subject
to legal professional privilege and/or protected by copyright. If you
receive it in error do not use it or 

Re: [R-sig-eco] Using the mra package in R...

2013-08-26 Thread Roman Luštrik
Try coercing your data to matrix. You currently have a data.frame, which
might matter to the package functions (I'm not familiar enough with the
functions to be able to tell from the top of my head).

as.matrix(my.data)

A side note, here's how you would write a model that includes all
(remaining) variables in your data:

F.cjs.estim(~ ., data = ...)

Notice the ., which means all available.

Cheers,
Roman



On Mon, Aug 26, 2013 at 8:01 AM, Adam Fawcett adam.fawc...@mq.edu.auwrote:

 Hi Sarah and all

 Thanks for those couple of tips. They did help to show that the data
 imported alright but that there was a distinct difference between my data
 set and the example data set for used to demonstrate the mra package.

 I have attached subset of my data as suggested. Its formatted as a
 tab-delimited text file with row names included (bird band numbers). I have
 tried importing with and without row names but this doesn't appear to make
 any difference.

 To import to R, I have been using the following process.

 brtb - read.table (file=filepath\\brtb.txt, header = TRUE, row.names =
 1, sep = , colClasses=numeric)

 Inspecting the data using str(brtb) provides the following

 'data.frame':   65 obs. of  19 variables:
  $ C1 : num  0 0 0 0 0 0 0 0 1 1 ...
  $ C2 : num  1 1 0 0 0 0 0 0 0 0 ...
  $ C3 : num  1 0 1 1 1 1 1 1 0 0 ...
  $ C4 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C5 : num  0 0 0 0 1 0 0 0 0 0 ...
  $ C6 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C7 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C8 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C9 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C10: num  0 0 0 0 0 0 0 0 1 0 ...
  $ C11: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C12: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C13: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C14: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C15: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C16: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C17: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C18: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C19: num  0 0 0 0 0 0 0 0 0 0 ...

 The comparative example I am looking at from the mra package is the
 dipper.histories data. Inspecting this with str(dipper.histories) provides
 the following

  num [1:294, 1:7] 1 1 1 1 1 1 1 1 1 1 ...
  - attr(*, dimnames)=List of 2
   ..$ : chr [1:294] 1 2 3 4 ...
   ..$ : chr [1:7] h1 h2 h3 h4 ...

 There is an obvious difference in the returned output from the str()
 function. Inspection of both data frames shows they are formatted in a
 similar way, or at least appear to be.

 With respect to the function I am attempting to run in mra, I have run the
 examples routines as described in the mra manual using the supplied data.
 Results as described. In attempting this on any of my own data as attached
 I get an error message. The function I am trying to run is as follows

 brtb.cjs = F.cjs.estim(
 ~x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17+x18,
 ~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17, brtb)


 Each time I get the following error

 Error in F.cjs.estim(~x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 +
  :
   Capture histories must consist of 0's, 1's, and 2's only.

 I have checked thru the data-set to make sure the data matches these
 requirements, that there are no additional characters in the data-set, etc.
 and keep getting the same error. Have tried a different subsets of the
 data, different import options, etc. but still no success.

 Am assuming the error lies with the format of the data imported to R but
 cannot work out where or how to adjust to match the example.

 Any suggestions or advice on this one would be greatly appreciated.

 Cheers

 Adam...


 On 25 August 2013 23:33, Sarah Goslee sarah.gos...@gmail.com wrote:

  Hi,
 
  The first thing to do is str(yourdata) to double-check that your data
  import worked as expected. Particularly check that your data column isn't
  actually of mode factor.
 
  If that doesn't give you a lead on solving the problem, posting a
  reproducible example here with a subset of your data provided using
 dput()
  and the actual code you used will get you concrete answers, rather than
  random guesses.
 
  Sarah
 
 
  On Sunday, August 25, 2013, Adam Fawcett wrote:
 
  Have been trying to analyse life history data collected from a long term
  mark-recapture study of birds using the package mra. While the analysis
  works fine on the supplied example dataset, I keep getting error
 messages
  when running my data thru the F.cjs.estim function. Error message states
  that the data for this analysis must be either 1, 2 or0's. Have triple
  checked my data and its all 1  0's as required.
 
  Problems is likely to be an issue with either the read.table function to
  import my data (all correctly formatted and transformed ready for the
  analysis, possibly adding a character I have been able to remove, or
 with
  the mra package itself.
 
  Does anyone have experience using mra that could lend some advice.
  Alternatively, has anyone struck this sort of problem before that could
  suggest how to correct the 

Re: [R-sig-eco] Using the mra package in R...

2013-08-26 Thread Adam Fawcett
Hi Roman and all

That certainly helped a lot thanks. Data is now in the correct format and
comparable to the example data set.

Next problem that cropped up - I ran the F.cjs.estim function and got the
following error

 brtb.cjs = F.cjs.estim( 
 capture=~x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17+x18, 
 survival=~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17, brtb.mx)
Error in model.frame.default(formula = ~x1 + x2 + x3 + x4 + x5 + x6 +  :
  variable lengths differ (found for 'x8')


This has certainly thrown me. Ran traceback() to try and determine the
problem which resulted with

 traceback()7: model.frame.default(formula = ~x1 + x2 + x3 + x4 + x5 + x6 +
   x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 +
   x17, drop.unused.levels = TRUE)
6: model.frame(formula = ~x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 +
   x9 + x10 + x11 + x12 + x13 + x14 + x15 + x16 + x17,
drop.unused.levels = TRUE)
5: eval(expr, envir, enclos)
4: eval(mf)
3: F.3d.model.matrix(as.formula(survival), nan, ns)
2: F.cr.model.matrix(capture, survival, nan, ns)
1: F.cjs.estim(~x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 +
   x12 + x13 + x14 + x15 + x16 + x17 + x18, ~x1 + x2 + x3 +
   x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + x13 + x14 +
   x15 + x16 + x17, brtb.mx)



Suggestions and comments appreciated.

Many thanks

Adam...


On 26 August 2013 16:10, Roman Luštrik roman.lust...@gmail.com wrote:

 Try coercing your data to matrix. You currently have a data.frame, which
 might matter to the package functions (I'm not familiar enough with the
 functions to be able to tell from the top of my head).

 as.matrix(my.data)

 A side note, here's how you would write a model that includes all
 (remaining) variables in your data:

 F.cjs.estim(~ ., data = ...)

 Notice the ., which means all available.

 Cheers,
 Roman



 On Mon, Aug 26, 2013 at 8:01 AM, Adam Fawcett adam.fawc...@mq.edu.auwrote:

 Hi Sarah and all

 Thanks for those couple of tips. They did help to show that the data
 imported alright but that there was a distinct difference between my data
 set and the example data set for used to demonstrate the mra package.

 I have attached subset of my data as suggested. Its formatted as a
 tab-delimited text file with row names included (bird band numbers). I
 have
 tried importing with and without row names but this doesn't appear to make
 any difference.

 To import to R, I have been using the following process.

 brtb - read.table (file=filepath\\brtb.txt, header = TRUE, row.names =
 1, sep = , colClasses=numeric)

 Inspecting the data using str(brtb) provides the following

 'data.frame':   65 obs. of  19 variables:
  $ C1 : num  0 0 0 0 0 0 0 0 1 1 ...
  $ C2 : num  1 1 0 0 0 0 0 0 0 0 ...
  $ C3 : num  1 0 1 1 1 1 1 1 0 0 ...
  $ C4 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C5 : num  0 0 0 0 1 0 0 0 0 0 ...
  $ C6 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C7 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C8 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C9 : num  0 0 0 0 0 0 0 0 0 0 ...
  $ C10: num  0 0 0 0 0 0 0 0 1 0 ...
  $ C11: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C12: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C13: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C14: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C15: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C16: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C17: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C18: num  0 0 0 0 0 0 0 0 0 0 ...
  $ C19: num  0 0 0 0 0 0 0 0 0 0 ...

 The comparative example I am looking at from the mra package is the
 dipper.histories data. Inspecting this with str(dipper.histories) provides
 the following

  num [1:294, 1:7] 1 1 1 1 1 1 1 1 1 1 ...
  - attr(*, dimnames)=List of 2
   ..$ : chr [1:294] 1 2 3 4 ...
   ..$ : chr [1:7] h1 h2 h3 h4 ...

 There is an obvious difference in the returned output from the str()
 function. Inspection of both data frames shows they are formatted in a
 similar way, or at least appear to be.

 With respect to the function I am attempting to run in mra, I have run the
 examples routines as described in the mra manual using the supplied data.
 Results as described. In attempting this on any of my own data as attached
 I get an error message. The function I am trying to run is as follows

 brtb.cjs = F.cjs.estim(
 ~x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17+x18,
 ~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12+x13+x14+x15+x16+x17, brtb)


 Each time I get the following error

 Error in F.cjs.estim(~x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 +
  :
   Capture histories must consist of 0's, 1's, and 2's only.

 I have checked thru the data-set to make sure the data matches these
 requirements, that there are no additional characters in the data-set,
 etc.
 and keep getting the same error. Have tried a different subsets of the
 data, different import options, etc. but still no success.

 Am assuming the error lies with the format of the data imported to R but
 cannot work out where or how to adjust to match the example.

 Any suggestions or advice on