MMPPsampler-plot: Plotting function to visualise the results of the implemented...

Description Usage Arguments Author(s) References See Also Examples

Description

This function provides visualisation of the results taken from either of the two implemented Gibbs samplers. The generated plot depicts the generated sample distribution of the latent Markov process X_t as well as the uncertainty of the results.

The blue line indicates the sample mode at each point in time while the thickness of the red lines indicates the amount of samples in each state. The uncertainty is calculated by 1-alpha_{t_i} where alpha_{t_i} is the fraction of the sample mode of all samples at time $t_i$.

The plotting function relies on the R-packages 'ggplot2' and 'cowplot'.

Usage

1
2
3
MMPPplot(Sampler_Output=NULL,
         title=" ",xaxis=" ",breaks=NULL,
         colour=NULL)       

Arguments

Sampler_Output

the output of one of the sampler functions "GibbsSampler" or "GibbsSampler_hierarchical"

title

an optional string stating the desired title of the plot

xaxis

an optional string stating the desired label for the x-axis

breaks

an optional dataframe with columns that replaces the x-axis ticks with customized tick labels. The first column indicates the position of the new ticks, while the second column contains strings with the new tick labels.

colour

an optional numeric vector that allows the colouring of specific regions in the data plot for better visual representation of specific time intervals. The vector indicates the position of the beginning/end of each colour interval.

Author(s)

Henry Clausen

Maintainer: Henry Clausen <henry.clausen@ed.ac.uk>

References

Fearnhead, Paul, and Chris Sherlock. "An exact Gibbs sampler for the Markov-modulated Poisson process." Journal of the Royal Statistical Society: Series B (Statistical Methodology) 68.5 (2006): 767-784 <doi: 10.1111/j.1467-9868.2006.00566.x>

Clausen, Henry. "A Bayesian Approach to Human Behaviour Modelling in Computer Networks". Master's thesis, Imperial College London, <https://github.com/hc2116/MMPPsampler/blob/master/Master_thesis_Henry.pdf>

See Also

Source-code and more descriptions available under <https://github.com/hc2116/MMPPsampler>

Examples

 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
#Use the flow sample data included in the package to test the hierarchical model
data("Testdataflows")
Test <- Testdataflows
test_samples <- GibbsSampler_hierarchical(y_0T=Test$Bins,
                                           M=Test$M,
                                           Inter = Test$Inter,
                                           alpha_Gamma_rate = Test$alpha_Gamma_rate,
                                           alpha_Gamma_Q = Test$alpha_Gamma_Q,
                                           beta_Gamma_Q = Test$beta_Gamma_Q,
                                           beta_Gamma_rate = Test$beta_Gamma_rate,
                                           alpha_Gamma_Y=Test$alpha_Gamma_Z,
                                           beta_Gamma_Y=Test$beta_Gamma_Z,
                                           B=1,N=5,messages=FALSE)

# Define appropriate new tick labels and colouring intervals
breaks <- data.frame(times=c(0,1800,
                          3600,5600,
                          7200,9000), 
                  names=c("14:00","14:30",
                          "15:00","15:30",
                          "16:00","16:30"))
colour <- c(0, 480, 1200, 2400, 
            2520, 3600, 4800, 6000, 
            7200, 7320, 8400, 9600)

example_plot <- MMPPplot(Sampler_Output=test_samples,
               title="Observations Imperial College Data",
               xaxis="time [hour]",
               breaks=breaks,
               colour=colour)
plot(example_plot)

MMPPsampler documentation built on May 24, 2018, 5:04 p.m.