6.2 Cyclical Temporal Effects
The squidR
function in the {squid} R package uses the sinusoidal equation to implement cyclical temporal effects:
\[ y = A sin(B(x - C)) + D \]
where A is the amplitude, \(B/2\pi\) is the period \(C/B\) is the horizontal shift and D is the vertical shift. We can visualise this
<- 1:20
time
<- 10 # |A| = the amplitude
amplitude <- 10
period <- 3
h_shift <- 5
v_shift
<- (2*pi) / abs(period) # 2pi/|B| = the period
B <- amplitude*sin(B*time - B^2*h_shift ) + v_shift
cyclic_effect
plot(cyclic_effect~time)
We can simulate this using the model part of the simulate_population()
, adding the extra parameters for the cyclical effects into the year_cont part of the list.
<- simulate_population(
squid_data data_structure= make_structure(structure = "year(20) + sex(2)/individual(50)",repeat_obs=1),
parameters=list(
year_cont = list(
group="year",
names= "linear_effect",
covariate=TRUE,
beta=0.3,
amplitude = 2, # |A| = the amplitude
period = 10,
h_shift = 3,
v_shift = 5
),year = list(
vcov = 1.2
),residual=list(
vcov = 1
)
),
model=" B =(2*pi) / abs(period);
cyclic_effect = amplitude*sin(B*I(linear_effect) - B^2*h_shift ) + v_shift;
y = linear_effect + cyclic_effect + year_effect + residual"
)
<- get_population_data(squid_data)
data
plot(y~year,data)