<h2>File List</h2><blockquote>
<p><a href="Simulation code.r">Simulation code.r</a> β Source code to run simulation analysis</p>
</blockquote><h2>Description</h2><blockquote>
<p>This is the complete code for simulating usage under different environmental scenarios of food/cover availability and fitting GFR models to the synthetic data. The end of the listing contains the following three functions:</p>
<p>environ(d,x): Creates a square dxd arena containing a total of x units of resource. The function introduces spatial autocorrelation via kernel smoothing of the resource units. Kernel smoothed map is re-normalized to ensure that x is conserved.</p>
<p>movement(d, env1, env2) : This function contains the movement simulation. The parameters pertaining to animal behavior are locally defined, so the function operates as a wrapper. Its input is the dimensionality d of the square arena and the two environmental layers (env1 and env2). Its output is a map of usage.</p>
<p>predict.lmer(mod, newdat) : Generates predictions from the fixed effects of mixed model.</p>
<p>The main body of the code has the following parts:</p>
<p>1. Initialization</p>
<p> Parameters regulating the arena size, number of environmental scenarios and overall availabilities of each resource in the arena for each scenario.</p>
<p>2. Simulation</p>
<p>The functions environ() and movement() are used to generate resource distributions and resulting usage for each environmental scenario.</p>
<p>3. Model fitting</p>
<p>Here, the data frame is extended with columns for expectations of the two resources in each scenario and four GFR models are fit to the augmented data frame.</p>
<p>4. Model validation</p>
<p> This part first inspects the goodness-of-fit of the models. It then generates data for a new environmental scenario with unobserved availabilities. The model fitted in part 3 is then used to make predictions about the new scenario. Then follow several different outputs that aim to visualize and quantify the quality of the resulting predictions.</p>
</blockquote