<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body ocsi="0" fpstyle="1" bgcolor="#FFFFFF">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Brilliant. Cheers. Here it is: does anyone want to add it to SRmodels.r?<br>
<br>
Mark<br>
<br>
#SegregAR1<br>
segregAR1 <- function(){<br>
    logl <- function(a, b, rho, rec, ssb){<br>
       loglAR1(log(rec), FLQuant(log(ifelse(c(ssb)<=b,a*c(ssb),a*b)),dimnames=dimnames(ssb)),rho=rho)}<br>
<br>
    model <- rec ~ FLQuant(ifelse(c(ssb)<=b,a*c(ssb),a*b),dimnames=dimnames(ssb))<br>
<br>
    initial <- structure(function(rec, ssb){<br>
      return(FLPar(a=median(c(rec/ssb),na.rm=TRUE), b=median(c(ssb),na.rm=TRUE),rho=0))},<br>
      lower=c( 0, 0,-1),<br>
      upper=c(Inf, Inf,1))<br>
<br>
return(list(logl=logl, model=model, initial=initial))<br>
} # }}}<br>
<br>
<br>
<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF677520"><font face="Tahoma" size="2" color="#000000"><b>Fra:</b> flr-list-bounces@r-forge.wu-wien.ac.at [flr-list-bounces@r-forge.wu-wien.ac.at] på vegne af Laurie [lauriekell@gmail.com]<br>
<b>Sendt:</b> 14. oktober 2013 13:44<br>
<b>Til:</b> flr-list@r-forge.wu-wien.ac.at<br>
<b>Emne:</b> Re: [FLR-list] Adding a segregAR1 in FLSR<br>
</font><br>
</div>
<div></div>
<div>
<div class="moz-cite-prefix">You need to add the initial params and bounds also.<br>
<br>
bevholtAR1 <- function()<br>
  {<br>
  ## log likelihood, assuming normal log.<br>
  logl <- function(a, b, rho, rec, ssb)<br>
      loglAR1(log(rec), log(a*ssb/(b+ssb)), rho=rho)<br>
<br>
  ## initial parameter values<br>
  initial <- structure(function(rec, ssb) {<br>
      a <- max(quantile(c(rec), 0.75, na.rm = TRUE))<br>
    b <- max(quantile(c(rec)/c(ssb), 0.9, na.rm = TRUE))<br>
    return(FLPar(a = a, b = a/b, rho=0))<br>
    },<br>
<br>
  ## bounds<br>
  lower=c(rep(10e-8, 2), -1),<br>
    upper=c(rep(Inf, 2), 1))<br>
<br>
  ## model to be fitted<br>
  model  <- rec~a*ssb/(b+ssb)<br>
  <br>
    return(list(logl=logl, model=model, initial=initial))<br>
} # }}}<br>
<br>
<br>
i.e.  <br>
     initial <- structure(function(rec, ssb){<br>
      return(FLPar(a=median(c(rec/ssb),na.rm=TRUE), b=median(c(ssb),na.rm=TRUE),rho=0.0))},<br>
      lower=c( 0, 0,-1),<br>
      upper=c(Inf,Inf,1))<br>
<br>
<br>
On 14/10/13 08:49, Mark Payne wrote:<br>
</div>
<blockquote type="cite"><style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
BODY {direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;}P {margin-top:0;margin-bottom:0;}</style>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi,<br>
<br>
I'm trying to define a segregAR1 FLSR model, as it seems to be missing from the SRmodels available in FLCore. I have modified the segreg model as follows, based on the bevholtAR1 and rickerAR1 models:<br>
<br>
#SegregAR1<br>
segregAR1 <- function(){<br>
    logl <- function(a, b, rho, rec, ssb){<br>
       loglAR1(log(rec), FLQuant(log(ifelse(c(ssb)<=b,a*c(ssb),a*b)),dimnames=dimnames(ssb)),rho=rho)}<br>
                   <br>
    model <- rec ~ FLQuant(ifelse(c(ssb)<=b,a*c(ssb),a*b),dimnames=dimnames(ssb))<br>
<br>
    initial <- structure(function(rec, ssb){<br>
      return(FLPar(a=median(c(rec/ssb),na.rm=TRUE), b=median(c(ssb),na.rm=TRUE)))},<br>
      lower=rep( 0, 0),<br>
      upper=rep(Inf, 2))<br>
<br>
return(list(logl=logl, model=model, initial=initial))<br>
} # }}}<br>
<br>
<br>
Basically, I've justed added a rho parameter to the likelihood which should, as I understand it, be sufficient to give me what I want. However, it doesn't seem to work when I go to fit it:<br>
> model(base.dat) <- "segregAR1"<br>
> res <- fmle(base.dat)<br>
  Nelder-Mead direct search function minimizer<br>
Error in .local(obs, hat, ...) : <br>
  argument "rho" is missing, with no default<br>
> <br>
<br>
Any ideas what I've done wrong?<br>
<br>
Mark<br>
<br>
<br>
<br>
<div class="line" id="LC76"><span class="c1"><br>
</span></div>
<br>
<br>
<br>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr tabindex="-1">
<div id="divRpF64123" style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>Fra:</b>
<a class="moz-txt-link-abbreviated" href="mailto:flr-list-bounces@r-forge.wu-wien.ac.at" target="_blank">
flr-list-bounces@r-forge.wu-wien.ac.at</a> [<a class="moz-txt-link-abbreviated" href="mailto:flr-list-bounces@r-forge.wu-wien.ac.at" target="_blank">flr-list-bounces@r-forge.wu-wien.ac.at</a>] på vegne af Luis Ridao [<a class="moz-txt-link-abbreviated" href="mailto:luridao@gmail.com" target="_blank">luridao@gmail.com</a>]<br>
<b>Sendt:</b> 4. oktober 2013 16:08<br>
<b>Til:</b> <a class="moz-txt-link-abbreviated" href="mailto:flr-list@flr-project.org" target="_blank">
flr-list@flr-project.org</a><br>
<b>Emne:</b> [FLR-list] FLBRP<2 sorce code<br>
</font><br>
</div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>FLR help,<br>
<br>
</div>
trying to get the source code for FLBRP version<2 (e.g. FLBRP_1.4-1)<br>
</div>
but can't find it anywhere.<br>
<br>
</div>
anyone with an older source code version of the package around?<br>
<br>
</div>
best,<br>
</div>
Luis<br clear="all">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div><br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader" target="_blank"></fieldset> <br>
<pre>_______________________________________________
flr-list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:flr-list@flr-project.org" target="_blank">flr-list@flr-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/flr-list" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/flr-list</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</body>
</html>