Learn R Programming

ExpBites (version 0.1.3)

gen_df_human: Generate a Simulated Dataset of Human Behavioral States Over 24 Hours

Description

Simulates the hourly state of a set of individuals (either bednet users or non-users) over a 24-hour period. Each individual's state is assigned probabilistically based on the hour of the day and whether they use a bednet.

Usage

gen_df_human(n_individuals = 100, hours = c(0:23), prob_use = 0.5)

Value

A data.frame with the following columns:

individual

Individual ID.

hour

Hour of the day (0–23).

bednet_user

Logical, indicating whether the individual is a bednet user.

state

Integer representing the individual’s state at that hour: 1 = outdoors, 2 = indoors and awake, 3 = indoors asleep (non-user), 4 = indoors asleep under bednet (user).

state_label

Factor version of state with descriptive labels.

Arguments

n_individuals

Integer. Number of individuals to simulate. Default is 100.

hours

Integer vector. The hours of the day to simulate, typically 0:23. Default is 0:23.

prob_use

Numeric. Probability of being a bednet user vs non-user. Default is 0.5.

Examples

Run this code
df <- gen_df_human(n_individuals = 50)
df <- gen_df_human(n_individuals = 100, hours = c(0:9,17:23))
head(df)

Run the code above in your browser using DataLab