<?xml version="1.0" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">FLR</title>
  <subtitle type="text">
    FLcore bugs
  </subtitle>
  <id>http://www.flr-project.org/bugs/</id>
    <updated>2012-04-24T04:31:58Z</updated>
  <link rel="self" type="text/xml" href="feed.php?feed_type=atom"/>
  <link rel="alternate" type="text/html" hreflang="en" href="/bugs/feed.php"/>
    <entry>
    <title>FS#45: FLPar &amp; pmin</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=45" />    
    <updated>2011-03-24T08:42:43Z</updated>    
    <published>2011-03-24T08:42:43Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        FLPar doesn´t work with all methods e.g.<br />
<br />
this works<br />
pmin(1:2/FLPar(1),0)<br />
[1] 0 0<br />
<br />
but this doesn´t<br />
<br />
pmin(1/FLPar(1:2),0)<br />
Error in checkSlotAssignment(object, name, value) :<br />
  assignment of an object of class &quot;logical&quot; is not valid for slot &quot;.Data&quot; in an object of class &quot;FLPar&quot;; is(value, &quot;array&quot;) is not TRUE<br />
Calls: pmin -&gt; &gt; -&gt; &gt; -&gt; @&lt;- -&gt; slot&lt;- -&gt; checkSlotAssignment<br />
 <br />
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:45</id>
  </entry>
    <entry>
    <title>FS#44: covar in FLSR</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=44" />    
    <updated>2011-01-25T10:50:20Z</updated>    
    <published>2011-01-25T10:50:20Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        rickerCovA &lt;- function(){<br />
  logl &lt;- function(a, b, c, rec, ssb, covar){<br />
              loglAR1(log(rec), log(a*(1+c*covar[[1]])*ssb*exp(-b*ssb)))}<br />
<br />
  initial &lt;- structure(function(rec, ssb, covar) {<br />
		# The function to provide initial values<br />
    res  &lt;-coefficients(lm(c(log(rec/ssb))~c(ssb)))<br />
    return(FLPar(a=max(exp(res[1])), b=-max(res[2]), c=0.0))},<br />
<br />
  # lower and upper limits for optim()<br />
	lower=rep(-Inf, 3),<br />
	upper=rep( Inf, 3))<br />
<br />
	model  &lt;- rec~a*(1+c*covar[[1]])*ssb*exp(-b*ssb)<br />
<br />
	return(list(logl=logl, model=model, initial=initial))}<br />
<br />
#### Modified so temperature affects larval K<br />
rickerCovB &lt;- function(){<br />
  logl &lt;- function(a, b, c, rec, ssb, covar){<br />
              loglAR1(log(rec), log(a*(1+c*covar[[1]])*ssb*exp(-b*ssb)))}<br />
<br />
  initial &lt;- structure(function(rec, ssb, covar) {<br />
		# The function to provide initial values<br />
    res  &lt;-coefficients(lm(c(log(rec/ssb))~c(ssb)))<br />
    return(FLPar(a=max(exp(res[1])), b=-max(res[2]), c=0.0))},<br />
<br />
  # lower and upper limits for optim()<br />
	lower=rep(-Inf, 3),<br />
	upper=rep( Inf, 3))<br />
<br />
	model  &lt;- rec~a*ssb*exp(-b*(1+c*covar[[1]])*ssb)<br />
<br />
	return(list(logl=logl, model=model, initial=initial))}<br />
<br />
nao     &lt;-read.table(&quot;http://www.cdc.noaa.gov/data/correlation/nao.data&quot;, skip=1, nrow=62, na.strings=&quot;-99.90&quot;)<br />
dnms    &lt;-list(quant=&quot;nao&quot;, year=1948:2009, unit=&quot;unique&quot;, season=1:12, area=&quot;unique&quot;)<br />
nao     &lt;-FLQuant(unlist(nao[,-1]), dimnames=dnms, units=&quot;nao&quot;)<br />
<br />
#### include NAO as covar (note that it must be a FLQuants with a single component<br />
#### called “covar” that matches the year span of the data) and adjust the model.<br />
<br />
herSR         &lt;-as.FLSR(her4)<br />
model(herSR)  &lt;-ricker()<br />
herSR         &lt;-fmle(herSR)<br />
<br />
herCovA       &lt;-as.FLSR(her4)<br />
herCovA       &lt;-transform(herCovA,ssb=ssb/1000,rec=rec/1000)<br />
model(herCovA)&lt;-rickerCovA()<br />
covar(herCovA)&lt;-FLQuants(covar=seasonMeans(trim(nao, year=dimnames(ssb(herCovA))$year)))<br />
herCovA       &lt;-fmle(herCovA,fixed=list(c=0))<br />
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:44</id>
  </entry>
    <entry>
    <title>FS#43: plot(FLStock)</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=43" />    
    <updated>2011-01-25T10:48:30Z</updated>    
    <published>2011-01-25T10:48:30Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        Issues a warning for a valid plot, i.e.<br />
data(ple4)<br />
plot(ple4)<br />
<br />
this is because coercion of data.frame for rec &amp; ssb does <br />
<br />
rbind(as.data.frame(ssb(ple4)),as.data.frame(rec(ple4)))<br />
<br />
although <br />
<br />
rbind(as.data.frame(rec(ple4)),as.data.frame(ssb(ple4)))<br />
<br />
doesn´t
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:43</id>
  </entry>
    <entry>
    <title>FS#42: Profile fails if parameter negative</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=42" />    
    <updated>2010-12-07T09:02:26Z</updated>    
    <published>2010-12-06T17:09:07Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        model(nsher)&lt;-bevholt()<br />
nsher       &lt;-fmle(nsher,fixed=list(b=-0.1))<br />
profile(nsher)<br />
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:42</id>
  </entry>
    <entry>
    <title>FS#41: plotting</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=41" />    
    <updated>2010-10-26T09:44:51Z</updated>    
    <published>2010-10-26T09:44:51Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        Often FLStock::plot or FLStocks::plot is used to summarise projections for different management measures and stock hypotheses. However, in most cases the y-axis ranges arn´t comparable  making it difficult to compare results. For example the y-axis don´t start at 0 and if a stock recovers to different levels in scenarios (the whole point of running them!) then the y-axes will differ across scenarios. Since you can´t specify the max y values.<br />
<br />
While if you have an FLstock object with iterations the range is not set by the interquartile range but the actual data e.g.<br />
<br />
plot(ple4)<br />
<br />
stock.n(ple4[[1]])&lt;-propagate(stock.n(ple4[[1]]),500)<br />
stock.n(ple4[[1]])[1,,,,,1]&lt;-stock.n(ple4[[1]])[1,,,,,1]*10<br />
plot(ple4[[1]])<br />
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:41</id>
  </entry>
    <entry>
    <title>FS#40: FLModel logliklihood and gradient functions are different</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=40" />    
    <updated>2010-10-26T09:38:47Z</updated>    
    <published>2010-10-26T09:38:47Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        In FLModel there is a slot for the gradient, which in FLSR is by default empty. However if you can provide this then you can both speed up fitting and make it more robust.<br />
<br />
However, the syntax for the logliklihood and gradient functions are different e.g.<br />
<br />
obj&lt;-as.FLSR(ple4,model=bevholt)<br />
<br />
bevholt()$logl<br />
<br />
<br />
gr(obj)&lt;-function(a,b,rec,ssb) {params(obj)[&quot;a&quot;]&lt;-a;params(obj)[&quot;b&quot;]&lt;-b;FLPar(computeD(obj)[,1:2])}<br />
obj&lt;-fmle(obj)<br />
<br />
gr(obj)&lt;-function(par,rec,ssb) {params(obj)[&quot;a&quot;]&lt;-par[1];params(obj)[&quot;b&quot;]&lt;-par[2];FLPar(computeD(obj)[,1:2])}<br />
obj&lt;-fmle(obj)<br />
<br />
The syntax for logl and gr should be the same since If there is a good reason for specifying the parameters separately for logl then the same logic must also apply to gr. However, I think specifying the parameters separately (as currently done in logl) implies that FLPar is redundant. Therefore can we change all functions/methods in FLModel/FLSR to use FLPar rather than the parameters seperately.<br />
<br />
This is not a trivial point as if we don´t fix this now we will run into bigger problems in the future, I have already found this when working with ADMb &amp; ADol-C.<br />
<br />
Laurie
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:40</id>
  </entry>
    <entry>
    <title>FS#39: FLPar doesn´t print correctly </title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=39" />    
    <updated>2010-10-18T11:40:28Z</updated>    
    <published>2010-10-18T08:50:01Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        FLPar doesn´t print correctly e.g.<br />
<br />
<br />
&gt; FLPar(array(1:6,c(3,2,1)))<br />
An object of class &quot;FLPar&quot;<br />
      <br />
params 1 2<br />
     a 2 5<br />
     b 5 2<br />
     c 2 5<br />
units:  NA NA NA <br />
&gt; FLPar(array(1:6,c(3,2,1)))@.Data<br />
, , iter = 1<br />
<br />
      <br />
params 1 2<br />
     a 1 4<br />
     b 2 5<br />
     c 3 6<br />
<br />
<br />
<br />
Laurie
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:39</id>
  </entry>
    <entry>
    <title>FS#38: Broken FLxxx creators</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=38" />    
    <updated>2010-10-01T14:33:59Z</updated>    
    <published>2010-10-01T14:33:59Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        The FLXXX creators are broken<br />
<br />
&gt; data(ple4.indices)<br />
&gt; data(ple4)<br />
&gt; pleXSA&lt;-FLXSA(ple4,ple4.indices)<br />
[1] 0<br />
[1] 0<br />
Error in validityMethod(as(object, superClass)) : <br />
  Not all &#039;quant&#039; names are the same. Check using qapply(x, quant)<br />
&gt; qapply(FLAssess(), quant)<br />
$catch.n<br />
[1] &quot;quant&quot;<br />
<br />
$stock.n<br />
[1] &quot;quant&quot;<br />
<br />
$harvest<br />
[1] &quot;quant&quot;<br />
<br />
&gt; qapply(FLQuant(), quant)<br />
Error in function (classes, fdef, mtable)  : <br />
  unable to find an inherited method for function &quot;qapply&quot;, for signature &quot;FLQuant&quot;, &quot;standardGeneric&quot;<br />
&gt; FLQuant()<br />
An object of class &quot;FLQuant&quot;<br />
, , unit = unique, season = all, area = unique<br />
<br />
     year<br />
quant 1 <br />
  all NA<br />
<br />
units:  NA
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:38</id>
  </entry>
    <entry>
    <title>FS#37: rec method</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=37" />    
    <updated>2010-09-30T12:04:18Z</updated>    
    <published>2010-09-27T12:49:13Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        The rec method has a bug, since rec.age is numeric therefore if it is anything other than 1 then you will get the wrong recruitment.<br />
<br />
setMethod(&#039;rec&#039;, signature(object=&#039;FLStock&#039;),<br />
#  function(object, rec.age=ac(dims(object)$min))<br />
  function(object, rec.age=object@range[&quot;min&quot;])<br />
  {<br />
    if(dims(object)$quant != &#039;age&#039;)<br />
      stop(&quot;rec(FLStock) only defined for age-based objects&quot;)<br />
    res &lt;- quantSums(stock.n(object)[rec.age,])<br />
    dimnames(res) &lt;- list(age=rec.age)<br />
    return(res)<br />
  }<br />
) # }}}
      </div>
    </content>
    <author><name>Laurie Kell</name></author>
    <id>http://www.flr-project.org/bugs/:37</id>
  </entry>
    <entry>
    <title>FS#36: Update to wiki page and R documentation</title>
    <link href="http://www.flr-project.org/bugs/index.php?do=details&amp;task_id=36" />    
    <updated>2010-09-22T19:52:54Z</updated>    
    <published>2010-09-22T19:52:54Z</published>
    <content type="xhtml" xml:lang="en" xml:base="http://diveintomark.org/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        In the wiki tutorial Getting Data into FLR the bullet :&#039;ICCAT VPA2Box format&#039; could become a section heading with the following info:<br />
The readFLStock() function can be used to read in stock and CPUE data used to conduct stock assessment. The &#039;ICCAT Adapt file&#039; format is supported by specifying type=&#039;Adapt&#039;. The &#039;Adapt file format&#039; consists of a single file of  input data containing the biological parameters, catches and catch per unit effort data and it typically carries the *.d01 file extension.<br />
Sample Code:<br />
path2&lt;-&#039;C:\\Bluefin CPUE\\ICCAT\\Assessment\\Analyses\\West VPA\\Run3d\\bftw7009.d01&#039;<br />
BFTStock&lt;-readFLStock(file=path2,type=&#039;Adapt&#039;)<br />
<br />
In the R documentation for &#039;IOfunctions {FLCore} : Input/Output of FLR objects, it would help to see an example like the one above and perhaps use the same text in the details section. Finally, the comments for the &#039;type&#039; argument need to be corrected so that &#039;adapt&#039; is capitalized. I was stumped for a while trying to figure out why my code would not work and had to look at the source code for readFLStock before I guessed that my type argument should have been &quot;Adapt&quot; not &quot;adapt&quot;.<br />
<br />
Regards, -Alex-
      </div>
    </content>
    <author><name>Alex Hanke</name></author>
    <id>http://www.flr-project.org/bugs/:36</id>
  </entry>
  </feed>

