Description Usage Arguments Value Author(s) See Also Examples

This function simulates different aspects of the daily life of a human called Bob. Bob sleeps, eats, works, has an appetite, can be fatigue, has a mood and can have the feeling of loss of interest. All these different aspects are simulated separately, but do influence each other according to a network model. The network model can be obtained by the network_figures input. The network of Bob receives input from an external misery node that projects onto the mood and from social eating that projects on the appetite. Bob is also monitored for 6 different symptoms of depression. The different parameters that influence the processes and connections can be modified, the parameter values vary interpersonal. The default values result in a stable average system that correspond to Bob his life. The only input required is t_days, the number of days that should be simulated.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
simBob(t_days, t_step = 1/60, work = TRUE, body_weight = 70, c_BW = 0.3,
c_ee_work = 1/205.5, c_ee_nowork = 1/163, c_ei_work = 1/85.75,
c_ei_nowork = 1/75, tau_d = 4.2, tau_r = 18.2, tau_dh = 0.25,
tau_rh = 3.7, tau_rhs = 8, tau_c = 24, A_s = 0.12, A_h = 0.14,
t_0s = 9.8, t_0h = 7.5, H_s = 0.67, L_s = 0.17, H_h = 0.65,
L_h = 0.17, mu_a = 0, sigma_a = 0.3, a_thres = 0.1, A_rest = 0.1,
mu_a_night = 0, sigma_a_night = 0, a_thres_night = 0.1, A_night = 0.1,
mu_a_work = -0.3, sigma_a_work = 0.4, A_work = 0.35,
standard_sleep = 7.88, c_F = 0.9, c_FS = 1, c_taudF = 4.5,
c_taurF = 0.25, c_muF = 1/60, c_app = 0.99, c_appH = 1/60,
c_apploi = 1/60, c_appse = 1, c_taurapp_neg = -1.73,
c_taurapp_pos = 0.72, social_eating = 0, loss_int = 0,
home_base = 0.1, attrac_strength = 0.35, c_M = 0.99, a1 = 2,
a2 = 0.5, a3 = 0.01, a4 = 0.01, a5 = 0.1, a6 = 1, c_muM = 0.06,
c_muloi = 0.06, c_loiM = 2.5, c_taurM = 1, external_misery = 0,
social_eat_work = TRUE, extended_output = FALSE, minimal_output = FALSE,
plot_week = FALSE, plot_months = FALSE, network_figures = FALSE)
``` |

`t_days` |
The number of days that will be simulated. A scalar is required as input. |

`t_step` |
The iteration time step in hours of the simulation. A scalar is required as input. The default value is 1/60, which corresponds to 1 minute. |

`work` |
The boolean that determines if Bob will have a job or not. The job is 5 days a week from 9.00 to 17.00 hours with lunch from 12.30 to 13.00 hours. A boolean or scalar is required as input. The default value is TRUE. |

`body_weight` |
The body weight in kg of Bob at the onset of the simulation. A scalar is required as input. The default value is 70 kg. |

`c_BW` |
The constant that determines the influence of the energy difference on the body weight. The energy difference is defined as the difference between food intake times a constant and the activity times a constant. The constant is comparable to the inverse energy density. The energy density depends among others on fat percentage and the type of tissues in the body. A scalar is required as input. The default value is 0.3. |

`c_ee_work` |
The constant that scales the energy expenditure (activity) before the body weight can be calculated when Bob has a job. This constant is the inverse average activity of a day, such that a change in activity is calculated as a relative change in the body weight. A scalar is required as input. The default value is 1/205.5. |

`c_ee_nowork` |
The constant that scales the energy expenditure (activity) before the body weight can be calculated when Bob is unemployed. This constant is the inverse average activity of a day, such that a change in activity is calculated as a relative change in the body weight. A scalar is required as input. The default value is 1/163. |

`c_ei_work` |
The constant that scales the energy intake (food intake) before the body weight can be calculated when Bob has a job. This constant is the inverse average food intake of a day, such that a change in food intake is calculated as a relative change in the body weight. A scalar is required as input. The default value is 1/80.3. |

`c_ei_nowork` |
The constant that scales the energy intake (food intake) before the body weight can be calculated when Bob is unemployed. This constant is the inverse average food intake of a day, such that a change in food intake is calculated as a relative change in the body weight. A scalar is required as input. The default value is 1/75. |

`tau_d` |
The time constant for the decaying part of the homeostatic sleep process. The homeostatic curve decays during sleep. This parameter determines how steep the decay is. When the parameter is higher the decay will be less steep, such that the sleep duration will be higher. When the parameter is lower the curve will decay more steep, the sleep duration will be shorter. A scalar or vector of length N (24*t_step*t_days) is required as input. The value of the time constant can be modified during the simulation.The default value is 4.2. |

`tau_r` |
The time constant of the rising part of the homeostatic sleep process. The rising time constant determines the steepness of the rising curve and thus the timing of sleep onset. Higher values of the rising time constant will approximately cause a later sleep onset, even so lower values of this time constant will result approximately in an earlier sleep onset. A scalar or vector of length N (24*t_step*t_days) is required as input. The value of the time constant can be modified during the simulation. The default value is 18.2. |

`tau_dh` |
The decaying time constant of the homeostatic hunger process. The decaying curve represents eating and the value of the time constant determines the steepness of the decaying curve. When the time constant is increased, the curve will be less steep and more time will be spend on eating, even so when the time constant decreases, the curve will be more steep and less time will be spend on eating. A scalar or vector of length N (24*t_step*t_days) is required as input. The value of the time constant can be modified during the simulation. The default value is 0.25. |

`tau_rh` |
The rising time constant of the homeostatic hunger process while awake. The rising curve represents the build up of a hunger feeling. The rising time constant determines the steepness of the curve. Therefore, the time between meals, thus also how many meals a day are consumed. A higher value of the time constant results in less meals consumed per day, because there is more time between the meals. A lower value of the time constant results in a faster rise of the homeostatic curve. Thus, the time between meals is less and therefore more meals per day will be consumed. A scalar or vector of length N (24*t_step*t_days) is required as input. The value of the time constant can be modified during the simulation. The default value is 3.7. |

`tau_rhs` |
The rising time constant of the homeostatic hunger process during sleep. This parameter has the same properties as tau_rh. During sleep the build up of the hunger feeling is slower, therefore the default value is higher for this parameter in contrast to tau_rh. A scalar or vector of length N (24*t_step*t_days) is required as input. The value of the time constant can be modified during the simulation. The default value is 8. |

`tau_c` |
The period of the circadian rhythm in hours. One oscillation of the circadian process represents one day. A scalar is required as input. The default value is 24. |

`A_s` |
The amplitude of the circadian process of sleep that scales how much influence the circadian rhythm has on sleep. When the amplitude is small the circadian rhythm is almost flat. Therefore, the rhythmic influence will be small. In contrast to a large amplitude that causes the rhythmic process to be influential on the sleep process. A scalar or vector of length N (24*t_step*t_days) is required as input. The default value is 0.12. |

`A_h` |
The amplitude of the circadian process of the food intake process that scales how much influence the circadian oscillation has. A low amplitude results in a more flat circadian rhythm. Thus, the rhythmic influence of the circadian process will be small. A high amplitude results in more influence of the circadian rhythm on the food intake process. A scalar or vector of length N (24*t_step*t_days) is required as input.The default value is 0.14. |

`t_0s` |
The starting point of the circadian rhythm for the sleep process. This parameter executes a horizontal translation of the oscillations. This translation determines the phase of the circadian rhythm. A scalar is required as input.The default value is 9.8. |

`t_0h` |
The starting point of the circadian rhythm for the food intake process. This parameter executes a horizontal translation of the oscillations. This translation determines the phase of the circadian rhythm. A scalar is required as input. The default value is |

`H_s` |
The upper boundary of the sleep process. The upper limit is added to the circadian rhythm resulting in the upper threshold. The threshold influences the sleep onset. A higher boudary will approximately cause a later sleep onset. Lowering the boundary will cause an earlier sleep onset. The effect of a lower boundary can be compared with a person who is bored. A scalar or vector of length N (24*t_step*t_days) is required as input. The default value is 0.67. |

`L_s` |
The lower boundary of the sleep process. The lower limit is added to the circadian rhythm resulting in the lower threshold. The threshold influences the wake onset. An increased lower boundary results in an earlier wake onset. In contrast to a decrease of the lower boundary that results in a later wake onset. A sudden increase of this boundary is compared with an alarm going off. A scalar or vector of length N (24*t_step*t_days) is required as input. The default value is 0.17. |

`H_h` |
The upper boundary of the food intake process. The upper limit is added to the circadian rhythm resulting in the upper threshold. The threshold influences the moment of food intake. A higher boudary will approximately cause food intake at a later moment. Lowering the boundary will cause food intake to be earlier. A scalar or vector of length N (24*t_step*t_days) is required as input. The default value is 0.65. |

`L_h` |
The lower boundary of the food intake process. The lower limit is added to the circadian rhythm resulting in the lower threshold. The threshold influences the moment of satisfaction that results in stopping with eating. An increased lower boundary results quicker in a satisfaction. In contrast to a decrease of the lower boundary that results in a longer period of food intake because of a later moment of satisfaction. A scalar or vector of length N (24*t_step*t_days) is required as input. The default value is 0.17. |

`mu_a` |
The mean of the distribution where from the activity intensity is drawn. The default value is |

`sigma_a` |
The standard deviation of the distribution where from the activity intensity is drawn. The default value is |

`a_thres` |
The threshold that the activity intensity has to reach to be executed. The default value is |

`A_rest` |
The activity intensity in rest. The default value is |

`mu_a_night` |
The mean of the distribution where from the activity intensity is drawn at night. The default value is so it might could be that at night you try to sleep, but cannot sleep and then you are less active than during the day. The default value is |

`sigma_a_night` |
The standard deviation of the distribution where from the activity intensity is drawn at night. The default value is |

`a_thres_night` |
The activity threshold at night. The default value is |

`A_night` |
The activity intensity at night. The default value is |

`mu_a_work` |
The mean of the distribution where from the activity intensity is drawn on a working day. Assuming that after a day of work the activity could be different than the activity when Bob has a day off. The default value is |

`sigma_a_work` |
The standard deviation of the distribution where from the activity intensity is drawn on a work day. The default value is |

`A_work` |
The activity intensity during working hours. The default value is |

`standard_sleep` |
The amount of sleep in hours that is standard or necessary. The default value is 7.88 hours. |

`c_F` |
The autoregressive constant of fatigue. The default value is |

`c_FS` |
The constant that determines the influence of sleep on fatigue. The default value is |

`c_taudF` |
the constant that determines the influence of fatigue on tau_d. The default value is |

`c_taurF` |
The constant that determines the influence of fatigue on tau_r. The default value is |

`c_muF` |
The constant that determines the influence of fatigue on mu_a. When fatigue is above higher than 5 then mu_a is lowered by fatigue times this constant. The default value of this constant is 1/60. The default value is |

`c_app` |
The autoregressive coefficient of appetite. The default value is 0.99. The default value is |

`c_appH` |
The constant that determines the influence of the homeostatic hunger feeling on the appetite. The default value is |

`c_apploi` |
The constant that determines the influence of the loss of interest on the appetite. The default value is |

`c_appse` |
The constant that determines the influence of the social eating on the appetite. The default value is |

`c_taurapp_neg` |
The constant that determines the influence of a negative appetite on the tau_rh (how fast a hunger feeling grows). The default value is |

`c_taurapp_pos` |
The constant that determines the influence of a positive appetite on the tau_rh (how fast a hunger feeling grows). The default value is |

`social_eating` |
Increases the appetite because of an external/social reason. For example, breakfast and lunch are regulated by social eating if work and social_eat_work are both true. The default value is |

`loss_int` |
Loss of interest determines if you feel like eating and activity. The default value is Loss of interest can only be positive and is also influenced by the mood. A scalar as basic value can be given or vector of the length of the time series (t_step*24*t_days). The default value is |

`home_base` |
The constant that determines the default mood value. The home base determines where the attractor point of the mood is. The default value is |

`attrac_strength` |
The strength of the attractor pulling on the mood. The default value is |

`c_M` |
The autoregressive coefficient of the mood. The default value is |

`a1` |
The constant that determines the influence of activity on the mood. The default value is |

`a2` |
The constant that determines the influence of fatigue on the mood. The default value is |

`a3` |
The constant that determines the influence of appetite on the mood. The default value is |

`a4` |
The constant that determines the influence of weight difference between body_weight and current weight on the mood. The default value is |

`a5` |
The constant that determines the influence of sleep on the mood.The default value is |

`a6` |
The constant that determines the influence of the external misery on the mood. The default value is |

`c_muM` |
The constant that determines the influence of the mood on mu_a, the mean of the distribution where from the activity intensity is drawn. The default value is |

`c_muloi` |
The constant that determines the influence of the loss of interest on mu_a. The mean of the distribution where from the activity intensity is drawn. The default value is |

`c_loiM` |
The constant that determines the influence of the mood on the loss of interest. The default value is |

`c_taurM` |
The constant that determines the influence of the mood on tau_r, thus how the mood determines the sleeping pattern. The default value is |

`external_misery` |
External misery is input from the external world and can represent positive and negative events. A scalar as default value can be given or a vector of the same length as the time axis (length(t)->t_step*24*t_days). The default value is |

`social_eat_work` |
If breakfast and lunch are stimulated by social eating or not when Bob has work. The default value is |

`extended_output` |
The output consists all the default values of all the different parameters. The default value is |

`minimal_output` |
The minimal output only returns the time series of the variables, but no parameter values. The default value is |

`plot_week` |
Plots will be made that are insightful for time series around one week (7 days). The default value is |

`plot_months` |
Plots of time series longer than weeks. The plots are made of mean or total daily value of the different variables. The default value is |

`network_figures` |
If TRUE this will return to pictures of the network. The first figure shows the simulated network with all the edges and nodes. The second figure shows the network with all the parameters that are used plotted in or on the node or connection. The default value is |

The output is divided in different lists, the content of the list depends on the chosen output.

`sleep`

Included in the minimal output

`sleep` |
The homeostatic sleep curve with length N. The curve is measured at every time step. |

`sleep_day` |
The hours of sleep per day. This is measured from 12.00 to 12.00. |

`C` |
The circadian rhythm of sleep. |

`H` |
The upper boundary of sleep. |

`L` |
The lower boundary of sleep. |

Included in the default output

`A` |
Amplitude of the circadian rhythm of sleep. |

`t_0` |
The time shift of the circadian rhythm of sleep. |

`tau_d` |
The time constant of the decaying homeostatic curve. |

`tau_r` |
The time constant of the rising homeostatic curve. |

Included in the extended output

`c_taudF` |
The constant that determines how fatigue is changing the tau_r of the sleep process. |

`c_taurF` |
The constant that determines how fatigue is changing the tau_d of the sleep process. |

`c_taurM` |
The constant that determines how the mood is changing the tau_r of the sleep process. |

`eat`

Included in the minimal output

`hunger` |
The homeostatic hunger curve with length N. The curve is measured at every time step. |

`eating_day` |
The minutes per day spend on eating. This is measured from 12.00 to 12.00. |

`C` |
The circadian rhythm of eating. |

`H` |
The upper boundary of eating. |

`L` |
The lower boundary of eating. |

Included in the default output

`A` |
Amplitude of the circadian rhythm of eating. |

`t_0` |
The time shift of the circadian rhythm of eating. |

`tau_d` |
The time constant of the decaying homeostatic curve. |

`tau_r` |
The time constant of the rising homeostatic curve. |

`tau_rs` |
The time constant of the rising homeostatic curve while Bob is sleeping. |

Included in the extended output

`c_taurapp_pos` |
The constant that determines how positive appetite influences tau_r, such that the eating pattern will be changed. |

`c_taurapp_neg` |
The constant that determines how negative appetite influences tau_r, such that the eating pattern will be changed. |

`activity`

Included in the minimal output

`activity` |
The time series of the activity of length N. The values are the intensity of the activity at the particular time point. |

`activity_day` |
The intensity*minutes active. This is measured from 12.00 to 12.00. |

Included in the default output

`mu_a` |
The mean of the distribution where from the activity intensity is drawn. This is vector of length N. |

`sigma_a` |
The mean of the distribution where from the activity intensity is drawn. This is vector of length N. |

Included in the extended output

`c_muF` |
The constant that determines how fatigue is changing mu_a. |

`c_muM` |
The constant that determines how mood is changing mu_a. |

`c_muloi` |
The constant that determines how the loss of interest is changing mu_a. |

`body_weight`

Included in the minimal output

`weight` |
The body weight measured per day. The measured time of the day is 12.00. |

Included in the default output

`c_ee_work` |
The constant that determines the contribution of activity to body weight when Bob has work. This constant should be the inverse of the mean of activity_day for a stable body weight. |

`c_ee_nowork` |
The constant that determines the contribution of activity to body weight when Bob is unemployed. This constant should be the inverse of the mean of activity_day for a stable body weight. |

`c_ei_work` |
The constant that determines the contribution of food intake to body weight when Bob has work. This constant should be the inverse of the mean of eating_day for a stable body weight. |

`c_ei_nowork` |
The constant that determines the contribution of food intake to body weight when Bob is unemployed. This constant should be the inverse of the mean of eating_day for a stable body weight. |

Included in the extended output

`c_BW` |
The constant that determines the influence of the difference between energy intake and expenditure. This constant is the inverse of the energy densit.y |

`appetite`

Included in the minimal output

`appetite` |
The appetite time series of length N. The curve is measured at every time step. |

Included in the extended output

`c_app` |
The autoregressive coefficient of appetite. |

`c_appH` |
The constant that determines the influence of the homeostatic hunger feeling on appetite. |

`c_apploi` |
The constant that determines the influence of loss of interest on appetite. |

`c_appse` |
The constant that determines the influence of social eating on appetite. |

`fatigue`

Included in the minimal output

`fatigue` |
The fatigue time series of length N. |

Included in the extended output

`c_F` |
The autoregressive coefficient of fatigue. |

`c_FS` |
The influence of missing sleep on fatigue. |

`standard_sleep` |
The standard amount of sleep necessary. |

`loss_of_interest`

Included in the minimal output

`loss_int` |
The time series of the loss of interest of length N. |

Included in the extended output

`c_loiM` |
The constant that determines the influence of mood on the loss of interest. |

`mood`

Included in the minimal output

`mood` |
The time series of the mood of length N. |

`mood_day` |
The daily mean of the mood. This is vector of length t_days. |

Included in the default output

`home_base` |
The home base of the mood is where the location of the attractor point. |

`attrac_strength` |
The strength that the mood is pulled to the attractor point. |

Included in the extended output

`a1` |
The constant that determines the influence of activity on the mood. |

`a2` |
The constant that determines the influence of fatigue on the mood. |

`a3` |
The constant that determines the influence of appetite on the mood. |

`a4` |
The constant that determines the influence of weight change on the mood. |

`a5` |
The constant that determines the influence of sleep on the mood. |

`a6` |
The constant that determines the influence of external misery on the mood. |

`c_M` |
The autoregressive coefficient of the mood. |

`external_misery`

Included in the default output

`external` |
The external misery time series of length N. |

`depression`

Included in the minimal output

`depression` |
A time series that represents the number of symptoms of depression per day. |

Included in the default output

`symptoms_day` |
Matrix of the measured symptoms by the number of simulated days. A 1 means that the symptom is present and a 0 means that the symptom is absent that day. |

`symptoms_14days` |
Matrix of the measured symptoms by the number of simulated days. This matrix returns a 1 when the symptom is present for 14 days or more. |

`other`

Included in the minimal output

`t` |
The time series of the simulation. This is the time per t_step. |

`t_days` |
Number of simulated days. |

`N` |
Number of time points of the time series t. This is the length of the time series. |

Included in the default output

`t_step` |
The time step that is used to simulate. |

`tau_c` |
The time constant of the circadian rhythm. This is by default 24, because there are 24 hours in one day. |

Lisanne Huurdeman

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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | ```
## Not run:
##Show the network
bob<-simBob(1,network_figures = TRUE)
#Simulate one week of Bob his life and return the plots appropiate for
#one simulation week and extended output.
bob<-simBob(7,plot_week=TRUE,extended_output=TRUE)
#Simulate again one week but now Bob is unemployed.
bob<-simBob(7,work=FALSE,plot_week=TRUE,extended_output=TRUE)
#Simulate a whole year of Bob his life and return the appropriate plots.
#To save memory only the minimal output will be returned with these options.
bob<-simBob(365,plot_months=TRUE,minimal_output=TRUE)
#The mean mood over the whole simulation is:
mean_mood<-mean(bob$mood$mood)
#An example with external misery as input
t_days<-100
t_step<-1/60; #hours, so time steps of a minute
t_end<-24*t_days; #convert end time in hours
t<-seq(from=0,to=(t_end-t_step),by=t_step); #make time vector
#Create a Gaussian for the external input
mean_mis=24*30; sigma_mis=24*10; #The mean and standard deviation times 24 so it is in days
external_misery<- 2*(2*sqrt(2*pi)*sigma_mis*dnorm(t, mean=mean_mis,sd=sigma_mis))
#Run the simulation with the external misery input and
#return plots for simulations longer than a week
bob<-simBob(t_days=t_days,external_misery = external_misery,plot_months = TRUE)
# Rename the depression variables
depression<-bob$depression$depression
depressed<-bob$depression$symptoms_14days
depression_symp<-bob$depression$symptoms_day
day_vec<-bob$other$t_day
lwd<-2
plot(day_vec,colSums(depression_symp),bty='l',
col='black',
type='l',
lwd=lwd,
xlab='day',
ylab='number of symptoms' ,
las=1)
plot(day_vec,depression,bty='l',
col='black',
type='l',
lwd=lwd,
xlab='day',
ylab='Number of symptoms more than 2 weeks' ,
las=1)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.