What do I do if I don't want to accept default parameters in wolfAlps module?

23 views
Skip to first unread message

claram...@googlemail.com

unread,
Sep 4, 2018, 11:30:02 AM9/4/18
to SpaDES Users
Hi,

I have another question concerning the wolfAlps module: I would like to change the input parameters, not just once to adjust for the different situation in Germany, but multiple times, in order to investigate the influence of the parameters on model output. So changing the values manually inside the first few lines of wolfAlps.R doesn't work for me anymore. I would like to do it in the starting script (or via loading an input file).


Inside the starting script there is this code block:

# These are the default parameters, none is being changed at the moment.
# parameters <- list(
# .plotInitialTime = NA, .plotInterval = 1,
# .saveInitialTime = 0, .saveInterval = 1,
# MeanNpups = 3.387, SdNpups = 1.210,
# AdultMortalityRate = 0.18, JuvMortalityRate = 0.449, DispMortRatePerMove = 0.0353,
# MeanPackSize = 4.405, SdPackSize = 1.251,
# EndDispersal = 0.98,
# CellWidth = 1.25, MoveStep = 10.929,
# sigma = 21.802,
# MeanPixelQuality = 0.84, MinPixelQuality = 0.376, MinPackQuality = 89.288,
# PackArea = 256, PhaseTransitionLower = 0.198,
# run.tests = TRUE
# )

but it is with comment sign '#' and if I uncomment the program still uses the default values from line 17 etc in wolfAlps.R. Setting the values there to NA doesn't work either.. Since the section above is included in the script I am thinking that it must have worked for someone at some time - but how?
Uncommenting the #params.. in the following section was another idea I had, but just results in errors:

# accept default parameters for now
wolfModuleStart <- simInit(times = times, #params = list(wolfAlps = parameters),
modules = modules, inputs = inputs, paths = paths)

In the advanced user section here https://github.com/PredictiveEcology/wolfAlps/blob/master/wolfAlps.Rmd#saving

params = list(wolfAlps = parameters) is used, but the necessary sections above aren't shown, unfortunately.

So I would really appreciate your help :)

Greetings,
Clara

Alex Chubaty

unread,
Sep 4, 2018, 12:03:26 PM9/4/18
to SpaDES Users
Uncommenting the parameters list assignment still leaves you with the defaults. If you want to use different parameters, change them in this block (uncommented) and be sure to also uncomment the piece in simInit so that it's using the new values. Note, you generally need to use non-NA values to not get the defaults.

# These are the default parameters; change them as needed
parameters
<- list(


   
.plotInitialTime = NA, .plotInterval = 1,


   
.saveInitialTime = 0, .saveInterval = 1,


   
MeanNpups = 3.387, SdNpups = 1.210,


   
AdultMortalityRate  = 0.18, JuvMortalityRate = 0.449, DispMortRatePerMove = 0.0353,


   
MeanPackSize = 4.405, SdPackSize = 1.251,


   
EndDispersal = 0.98,
   
CellWidth = 1.25,

   MoveStep = 10.929, sigma = 21.802,


   
MeanPixelQuality = 0.84, MinPixelQuality = 0.376, MinPackQuality = 89.288,


   
PackArea = 256, PhaseTransitionLower = 0.198,


   run
.tests = TRUE
 
)


# use the (modified) parameters defined above
wolfModuleStart <- simInit(times = times, params = list(wolfAlps = parameters),
                           modules = modules, inputs = inputs, paths = paths)

To facilitate the sort of sensitivity analysis you describe, you can make use of experiment() to pass a sequence of values to your parameters. See ?experiment for documentation and examples.

claram...@googlemail.com

unread,
Sep 6, 2018, 8:34:59 AM9/6/18
to SpaDES Users
Hm, doesn't quite work for me, I get the following errors:

Error in sim@params[[m]][names(pars[[m]])] <- pars[[m]] :
cannot coerce type 'closure' to vector of type 'list'

and

Error in spades(wolfModuleStart, progress = 4, debug = T) :
object 'wolfModuleStart' not found


Alex Chubaty

unread,
Sep 6, 2018, 12:03:12 PM9/6/18
to SpaDES Users
instead of using a list named "parameters", simply rename it (e.g., myParams) and pass that to the simInit call. `parameters` is a function, so you're getting a name collision.

Alex

claram...@googlemail.com

unread,
Sep 10, 2018, 9:17:08 AM9/10/18
to SpaDES Users
Thanks, I got it to work properly! Additionally, I had to uncomment the .plotInitialTime = start(sim) etc, because at that point sim wasn't yet defined.
Reply all
Reply to author
Forward
0 new messages