.. _pop_pkpd_index:

Simulating A Population Of Individuals
##############################################

Because people vary in many, many ways, we should rarely draw conclusions
of any analysis based on a single individual. 

This part therefore introduces concepts related to variability within a 
*population* of individuals (and *Population PK/PD* from which |popy| gets its
name), using |popy| example scripts to generate data and figures for ease of
learning.

Variability between individuals comes in two flavours:

#. *Observable* variability that can be *measured* directly before a trial even 
   takes place, such as age, body weight and exposure to other drugs that
   may have an impact on an individual's |pkpd|. These variables are known as 
   *covariates* and are usually recorded in the data before analysis takes 
   place.
#. *Unobservable* Variability that must be *estimated* as part of 
   the data analysis.

Early attempts at estimating the unobservable variability
relied on the residual error model "taking up the slack" 
but it quickly became clear that the estimates of 
population parameters were biased; 
when dealing with a population of subjects, 
a single set of model parameters cannot capture the variation in 
concentration time courses in a sensible way.

A significant advance in the field came with the development of 
*mixed effect models* that model unobservable variability between individuals
as random deviations (known as *random effects*) from population averages
(known as *fixed effects*). 
Furthermore, the distributional assumptions we choose for the newly introduced
:term:`random effects` constrain the problem mathematically,
making it practical to find a "best" local fit even with sparse observations.

The population on average is therefore characterized by the fixed effects,
while each individual in the population has |pkpd| parameters that are also
dependent on both covariates and random effects.

.. toctree::
    :maxdepth: 1

    inter_subject_variation
    inter_occasional_variation
    re_correlation
    covariates

    .. super_subject_variation
    .. sparse_individual_data
