[FLR-list] FLash: iter dimension in fwdControl()
Simon Fischer
simon_h_fischer at gmx.de
Mon Feb 2 11:43:43 CET 2015
Thanks for your help Iago,
works perfectly.
Regards,
Simon
Am 02.02.2015 um 09:29 schrieb Iago MOSQUEIRA (JRC):
>
> Hi,
>
> To specify iters in the target value you need to add them to the slot
> you mention, @tgrtArray. The process is a bit clumsy at the moment,
> but you can do
>
> # SET years
> years <- 1:2
>
> # SET No. of iters
> niter <- 100
>
> # MODIFY trgtArray with empty array
> ctrl at trgtArray <- array(NA, dim=c(length(years), 3, niter), dimnames =
> list(years, c("min","val","max"),iter=1:niter))
>
> and then modify the values by passing values to the 'val' column, or
> 'min' and 'max' if that is what you need
>
> ctrl at trgtArray[,'val',] <- rnorm(200)
>
> The key is creating an array that has the right structure
>
>
> > dimnames(ctrl at trgtArray)
> [[1]]
> [1] "1" "2"
>
> [[2]]
> [1] "min" "val" "max"
>
> $iter
> [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11"
> "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23"
> "24"
> [25] "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35"
> "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47"
> "48"
> [49] "49" "50" "51" "52" "53" "54" "55" "56" "57" "58" "59"
> "60" "61" "62" "63" "64" "65" "66" "67" "68" "69" "70" "71"
> "72"
> [73] "73" "74" "75" "76" "77" "78" "79" "80" "81" "82" "83"
> "84" "85" "86" "87" "88" "89" "90" "91" "92" "93" "94" "95"
> "96"
> [97] "97" "98" "99" "100"
>
> and adding the values in the right position, taking care of ther
> recycling rule.
>
> I am sorry this is really suboptimal right now. The new version of
> lash has a much improved version of the constructor that will make
> simpler creating control objects with iterations. The reason why
> target values are specified in these two objects (data.frame and
> array) is to be able to deal with them more easily in the Cpp code in
> FLash.
>
> This course session has a couple of examples
>
> https://github.com/iagomosqueira/FLRforQuantFishSci/blob/master/Sessions/06%20Forecasting/06.02%20MTF/MTF.R
>
>
> Best,
>
>
> Iago
>
> On 02/01/2015 05:13 PM, Simon Fischer wrote:
>> Dear all,
>>
>> I am working on an forecast for a FLStock object using the fwd() method.
>> I use the latest Versions of R (3.1.2), FLCore and FLash.
>>
>> My FLStock object contains several iterations and I want to use
>> individual targets (TACs) for each iteration.
>> The problem is, that I cannot figure out how to access the iter
>> dimension in the fwdControl object:
>>
>> When I just enter several values, only the last value is used for all
>> iterations:
>> >library(FLAsh)
>> >ctrl <- fwdControl(data.frame(year = 1, quantity = "catch", val =
>> c(*100,200*))
>> >ctrl
>> Target
>> year quantity min val max
>> 1 1 catch NA 100 NA
>> 2 1 catch NA 200 NA
>>
>> min val max
>> 1 NA 100 NA
>> 2 NA 200 NA
>>
>> also here only one iter is created:
>> >ctrl at trgtArray
>> , , *iter = 1*
>>
>> min val max
>> 1 NA 100 NA
>> 2 NA 200 NA
>>
>>
>> So my question is how I can access the iter dimension of fwdControl(),
>> if that is even possible.
>>
>>
>> Best regards
>> Simon
>>
>> ______________________________________
>> Simon Fischer
>> MSc. student
>> Institute for Hydrobiology and Fisheries Science,
>> University of Hamburg
>>
>>
>>
>> _______________________________________________
>> flr-list mailing list
>> flr-list at flr-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/flr-list
>>
>
> _______________________________________________
> flr-list mailing list
> flr-list at flr-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/flr-list
More information about the flr-list
mailing list