.. _plot_types:

Plot Types
###########################

|popy|'s grph and vpc are highly configurable, but for everyday use |popy| comes with a variety of preset plots that will be familiar to those working in |pkpd|.

These presets are added in the grph_list option (for single populations) and vpc_list option (for simulated datasets of many populations).

.. comment 

    "OBS_vs_TIME": self._create_indiv_obs_vs_time_grph_dict,
    "{OBS}_vs_TIME": self._create_pop_obs_vs_time_grph_dict,
    "{OBS}_vs_IPRED": self._create_dv_vs_ipred_grph_dict,
    "{OBS}_vs_PRED": self._create_dv_vs_ppred_grph_dict,
    "{IRES}_vs_IPRED": self._create_ires_vs_ipred_grph_dict,
    "{IWRES}_vs_IPRED": self._create_iwres_vs_ipred_grph_dict,

    "OBS_vs_TIME_VPC": self._create_pop_obs_vs_time_vpc_dict,



.. _indobs_vs_time_grph:
    
Individual Observations vs. Time
==================================

Adding "OBS_vs_TIME" to grph_list creates a plot of predictions (line on the y-axis) and observations (points on the y-axis) against Time (on the x-axis) for each individual in the population.

.. code-block:: pyml

    GRPH:
        grph_list: ["OBS_vs_TIME"]

.. list-table:: Individual Observations vs Time for three individuals from a population
    :class: image_table
    
    * - .. thumbnail:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/indOBS_vs_TIME/000001.*
      - .. thumbnail:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/indOBS_vs_TIME/000002.*
      - .. thumbnail:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/indOBS_vs_TIME/000003.*

      
.. _allOBS_vs_time_grph:
    
Population Observations vs. Time
==================================

Adding "{OBS}_vs_TIME" to grph_list creates a single plot of predictions (line on the y-axis) and observations (points on the y-axis) against Time (on the x-axis) for the whole population, overlaying individual data on the same graph.

.. code-block:: pyml

    GRPH:
        grph_list: ["{OBS}_vs_TIME"]

.. figure:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/allOBS_vs_TIME/comb_spag.*
    :scale: 50%
    
    Population Observations vs Time for a whole population
      
.. _allOBS_vs_ipred_grph:
    
Population Observations vs. Individual Predictions
===================================================

Adding "{OBS}_vs_IPRED" to grph_list creates a scatter plot for the whole population with Observations on the y-axis against Individualised (i.e. incorporating random effects) Predictions on the x-axis.
            
.. code-block:: pyml

    GRPH:
        grph_list: ["{OBS}_vs_IPRED"]

.. figure:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/allOBS(DV_CENTRAL)_vs_IPRED(CEN)/pop_scatter.*
    :scale: 50%

    Population Observations vs Individual Predictions for a whole population

            
.. _allOBS_vs_pred_grph:
    
Population Observations vs. Population Predictions
===================================================

Adding "{OBS}_vs_PRED" to grph_list creates a scatter plot for the whole population with Observations on the y-axis against Population (i.e. using only fixed effects) Predictions on the x-axis.
            
.. code-block:: pyml

    GRPH:
        grph_list: ["{OBS}_vs_PRED"]

.. figure:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/allOBS(DV_CENTRAL)_vs_PPRED(CEN)/pop_scatter.*
    :scale: 50%

    Population Observations vs Population Predictions for a whole population

        
.. _ires_vs_ipred_grph:
    
Individual Residuals vs. Individual Predictions
===================================================

Adding "{IRES}_vs_IPRED" to grph_list creates a scatter plot for the whole population with Individualised (i.e. incorporating random effects) Residuals on the y-axis against Individualised Predictions on the x-axis. 
            
.. code-block:: pyml

    GRPH:
        grph_list: ["{IRES}_vs_IPRED"]

.. figure:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/RES(DV_CENTRAL)_wrt_IPRED(CEN)/pop_scatter.*
    :scale: 50%

    Individual Residuals vs. Individual Predictions for a whole population
    

.. _iwres_vs_ipred_grph:
    
Individual Weighted Residuals vs. Individual Predictions
===========================================================

Adding "{IWRES}_vs_IPRED" to grph_list creates a scatter plot for the whole population with Individualised (i.e. incorporating random effects) Weighted (i.e. normalized with respect to the variance) Residuals on the y-axis against Individualised Predictions on the x-axis.
            
.. code-block:: pyml

    GRPH:
        grph_list: ["{IWRES}_vs_IPRED"]

..
    There appears to be something of a misnomer here when plotting IWRES vs "IPRED"
    In particular, we plot the weighted residual (on y) against the *input covariate* (on x)
    rather than the prediction (as suggested by "IPRED").
    (I suspect I kept the IPRED notation because that is what Nonmem users will be familiar with.)
    
.. figure:: /_autogen/quick_start/tut_example1/images/fit_sim_grph_outputs/WRES(DV_CENTRAL)_wrt_IPRED(CEN)/pop_scatter.*
    :scale: 50%

    Individual Weighted Residuals vs. Individual Predictions for a whole population

    
.. _obs_vs_time_vpc:
    
Individual Observations vs Time (VPC)
===========================================================

Adding "OBS_vs_TIME_VPC" to vpc_list creates a Visual Predictive Check plot that shows the percentiles of predictions and observations, and gives you some indication of whether the estimated model parameters represent a distribution that is close to the observed data.
            
.. code-block:: pyml

    VPC:
        vpc_list: ["OBS_vs_TIME_VPC"]

.. figure:: /_autogen/quick_start/fit_example1/images/fit_msim_vpc_outputs/allOBS_vs_TIME_VPC/vpc.*
    :scale: 50%

    Individual Observations vs Time VPC for 100 populations
