<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 10/18/2011 01:10 PM, Ernesto Jardim wrote:
    <blockquote
cite="mid:CAC03QWCxARV-RbXfZJNwS8gMLVsgYkRPDrH86LDUkPuyhCmRzg@mail.gmail.com"
      type="cite"><br>
      <br>
      <div class="gmail_quote">On Tue, Oct 18, 2011 at 1:03 PM, Laurie <span
          dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:lauriekell@googlemail.com">lauriekell@googlemail.com</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div text="#000000" bgcolor="#ffffff">
            <div>
              <div class="h5"> On 10/18/2011 12:50 PM, <a
                  moz-do-not-send="true"
                  href="mailto:ernesto.jardim@jrc.ec.europa.eu"
                  target="_blank">ernesto.jardim@jrc.ec.europa.eu</a>
                wrote:
                <blockquote type="cite"> On 10/18/2011 12:02 PM, Laurie
                  wrote:
                  <blockquote type="cite"> On 10/18/2011 11:41 AM, <a
                      moz-do-not-send="true"
                      href="mailto:ernesto.jardim@jrc.ec.europa.eu"
                      target="_blank">ernesto.jardim@jrc.ec.europa.eu</a>
                    wrote:
                    <blockquote type="cite">On 10/18/2011 11:26 AM,
                      Laurie wrote: <br>
                      <blockquote type="cite">I am working on tagging
                        models, where tags are released for a number of&nbsp;
                        years and then recaptured in subsequent years.
                        This allows M &amp; Z to be estimated along a
                        cohort. <br>
                        <br>
                        The data are in the form of number of fish
                        tagged and recovered each year of a cohort. This
                        means that you can&acute;t use FLCohort which has age
                        &amp; cohort as dims 1&amp;2. <br>
                        <br>
                        However, if you use the 1st dim for cohort then
                        you can model this with an FLQuant, i.e. <br>
                        <br>
                        library(plyr) <br>
                        <br>
                        setGeneric("I",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        function(object,...) <br>
                        &nbsp;&nbsp;&nbsp; standardGeneric("I")) <br>
                        setGeneric('O',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function(object,
                        ...) <br>
                        &nbsp;&nbsp;&nbsp; standardGeneric("O")) <br>
                        <br>
                        setMethod('I', signature(object='FLQuant'), <br>
                        &nbsp; function(object,...){ <br>
                        &nbsp;&nbsp;&nbsp; dmns &lt;-dimnames(object) <br>
                        &nbsp;&nbsp;&nbsp; dmns[[1]]
                        &lt;-ac((dims(object)$minyear-dims(object)$max):(dims(object)$maxyear-
                        dims(object)$min)) <br>
                        &nbsp;&nbsp;&nbsp; names(dmns)[1]&lt;-"quant" <br>
                        &nbsp;&nbsp;&nbsp; flc &lt;-FLQuant(NA,dimnames=dmns) <br>
                        <br>
                        &nbsp;&nbsp;&nbsp; t. &lt;-as.data.frame(object) <br>
                        &nbsp;&nbsp;&nbsp; t.$cohort &lt;-t.$year-t.$age <br>
                        &nbsp;&nbsp;&nbsp; flc[]
                        &lt;-daply(t.,c("cohort","year","unit","season","area","iter"),function(x)



                        sum(x$data)) <br>
                        <br>
                        &nbsp;&nbsp;&nbsp; return(flc)}) <br>
                        <br>
                        setMethod('O', signature(object='FLQuant'), <br>
                        &nbsp; function(object,...){ <br>
                        &nbsp;&nbsp;&nbsp; dmns &lt;-dimnames(object) <br>
                        &nbsp;&nbsp;&nbsp; dmns[[1]]
&lt;-ac((dims(object)$maxyear-dims(object)$max):(dims(object)$minyear-dims(object)$min))<br>
                        &nbsp;&nbsp;&nbsp; names(dmns)[1]&lt;-"age" <br>
                        &nbsp;&nbsp;&nbsp; flc &lt;-FLQuant(NA,dimnames=dmns) <br>
                        <br>
                        &nbsp;&nbsp;&nbsp; t. &lt;-as.data.frame(object) <br>
                        &nbsp;&nbsp;&nbsp; t.$age &lt;-t.$year-t.$quant <br>
                        &nbsp;&nbsp;&nbsp; t. &lt;-t.[!<a moz-do-not-send="true"
                          href="http://is.na" target="_blank">is.na</a>(t.$data),]
                        <br>
                        &nbsp;&nbsp;&nbsp; flc[]
                        &lt;-daply(t.,c("age","year","unit","season","area","iter"),function(x)
                        sum(x$data)) <br>
                        <br>
                        &nbsp;&nbsp;&nbsp; return(flc)}) <br>
                        <br>
                        data(ple4) <br>
                        <br>
                        m1=I(m(ple4)) <br>
                        m2=O(m1) <br>
                        <br>
                        It is probably best to derive a new class for
                        this object just to break VPAs etc. But what to
                        call it? Also how does it relate to FLCohort. <br>
                        Laurie <br>
                      </blockquote>
                      <br>
                      You may change the age in FLCohort <br>
                      <br>
                      library(FLCore) <br>
                      data(ple4) <br>
                      flc &lt;- FLCohort(catch.n(ple4)) <br>
                      quant(flc) &lt;- "year" <br>
                      <br>
                      why not using year in the first dimension ? it
                      should work out of the box. <br>
                      <br>
                      EJ <br>
                      <br>
                      <br>
                    </blockquote>
                    But you don&acute;t get what you want.<br>
                    <br>
                    <span style="border-collapse: separate; color:
                      rgb(0, 0, 0); font-family: Arial; font-style:
                      normal; font-variant: normal; font-weight: normal;
                      letter-spacing: normal; line-height: normal;
                      text-indent: 0px; text-transform: none;
                      white-space: normal; word-spacing: 0px; font-size:
                      medium;"><span style="font-family: Monospace;
                        font-size: 13px; line-height: 17px; white-space:
                        pre-wrap;"><br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <pre style="font-family: Monospace; font-size: 10pt ! important; outline-style: none; border-style: none; white-space: pre-wrap ! important; margin: 0px; line-height: 1.3;"><span style="color: blue;">I(m(ple4))[1:10,1:10]
</span>An object of class "FLQuant"
, , unit = unique, season = all, area = unique

      year
quant  1957 1958 1959 1960 1961 1962 1963 1964 1965 1966
  1947 0.1   NA   NA   NA   NA   NA   NA   NA   NA   NA 
  <a moz-do-not-send="true" href="tel:1948%200.1%20%200.1" value="+35319480101" target="_blank">1948 0.1  0.1</a>   NA   NA   NA   NA   NA   NA   NA   NA 
  <a moz-do-not-send="true" href="tel:1949%200.1%20%200.1" value="+35319490101" target="_blank">1949 0.1  0.1</a>  0.1   NA   NA   NA   NA   NA   NA   NA 
  1950 0.1  0.1  0.1  0.1   NA   NA   NA   NA   NA   NA 
  1951 <a moz-do-not-send="true" href="tel:0.1%20%200.1%20%200.1%20%200.1%20%200.1" value="+353101010101" target="_blank">0.1  0.1  0.1  0.1  0.1</a>   NA   NA   NA   NA   NA 
  1952 0.1  0.1  0.1  0.1  0.1  0.1   NA   NA   NA   NA 
  1953 0.1  0.1  0.1  0.1  0.1  0.1  0.1   NA   NA   NA 
  1954 0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   NA   NA 
  1955 0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1   NA 
  1956 0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1 

units:  NA 
<span style="white-space: pre-wrap; color: blue;">&gt; </span><span style="color: blue;">FLCohort(m(ple4))[1:10,1:10]
</span>An object of class "FLCohort"
, , unit = unique, season = all, area = unique

    cohort
age  1947 1948 1949 1950 1951 1952 1953 1954 1955 1956
  1   NA   NA   NA   NA   NA   NA   NA   NA   NA  0.1 
  2   NA   NA   NA   NA   NA   NA   NA   NA  0.1  0.1 
  3   NA   NA   NA   NA   NA   NA   NA  0.1  0.1  0.1 
  4   NA   NA   NA   NA   NA   NA  0.1  0.1  0.1  0.1 
  5   NA   NA   NA   NA   NA  <a moz-do-not-send="true" href="tel:0.1%20%200.1%20%200.1%20%200.1%20%200.1" value="+353101010101" target="_blank">0.1  0.1  0.1  0.1  0.1</a> 
  6   NA   NA   NA   NA  0.1  <a moz-do-not-send="true" href="tel:0.1%20%200.1%20%200.1%20%200.1%20%200.1" value="+353101010101" target="_blank">0.1  0.1  0.1  0.1  0.1</a> 
  7   NA   NA   NA  0.1  0.1  0.1  0.1  0.1  0.1  0.1 
  8   NA   NA  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1 
  9   NA  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1  0.1 

laurie</pre>
                        <br>
                        <br>
                        <br>
                      </span></span></blockquote>
                  <br>
                  Lost me. What do you want ?<br>
                  <br>
                  EJ<br>
                  <br>
                  <br>
                  <br>
                </blockquote>
              </div>
            </div>
            There are three ways to represent the 1st two dims in an
            FLQuant.<br>
            <br>
            i) age &amp; year<br>
            ii) age &amp; cohort<br>
            iii) cohort &amp; year<br>
            <br>
            (i) is FLQuant and (ii) is FLCohort; However we do not have
            (iii) which is what I need for my tagging model.<br>
            <br>
            I have created an "FLCohortYear" from an FLQuant by adding
            I() &amp; O() as coercion methods and validity that only
            allows 1st dim to be called cohort.<br>
            But then we have two FLCohort objects which might conflict.
            <br>
            <font color="#888888"> <br>
              Laurie <br>
              <br>
              <br>
            </font></div>
        </blockquote>
        <div><br>
          But you can use FLQuant and change the first dimension. You
          may need a method to convert i) or ii) into it but shouldn't
          create any conflicts. If you really need a new data structure
          and the problem only affects tag data, call it FLTag and
          extend FLQuant.<br>
          <br>
          Best<br>
          <br>
          EJ<br>
          &nbsp;<br>
        </div>
      </div>
    </blockquote>
    I would have called in FLCohort but some body got there 1st!<br>
    <br>
    Having 2 versions of FLCohorts with different properties does raise
    an issue though.<br>
    <br>
    Laurie <br>
    <br>
    &nbsp;<br>
  </body>
</html>