+ 1 doc1 1 1 6 6 8
+ 2 doc2 2 2 4 8 8
+ 3 doc3 3 3 6 4 10
diff --git a/docs/man/get_clusters_batch.md b/docs/man/get_clusters_batch.md
new file mode 100644
index 00000000..ef96404e
--- /dev/null
+++ b/docs/man/get_clusters_batch.md
@@ -0,0 +1,94 @@
+
+
+# get_clusters_batch
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+get_clusters_batch
+
+## Usage
+
+get_clusters_batch(
+ template,
+ input_dir,
+ output_dir,
+ writer_indices,
+ doc_indices,
+ num_cores = 1
+)
+
+
+## Arguments
+
+
+
+
+template
+ |
+
+A cluster template created with make_clustering_template
+ |
+
+
+
+input_dir
+ |
+
+A directory containing graphs created with
+process_batch_dir
+ |
+
+
+
+output_dir
+ |
+
+Output directory for cluster assignments
+ |
+
+
+
+writer_indices
+ |
+
+Vector of start and end indices for the writer id in the graph file
+names
+ |
+
+
+
+doc_indices
+ |
+
+Vector of start and end indices for the document id in the graph file
+names
+ |
+
+
+
+num_cores
+ |
+
+Integer number of cores to use for parallel processing
+ |
+
+
+
+## Value
+
+A list of cluster assignments
+
+## Examples
+
+``` r
+library(handwriter)
+
+template <- readRDS('path/to/template.rds')
+get_clusters_batch(template=template, input_dir='path/to/dir', output_dir='path/to/dir',
+writer_indices=c(2,5), doc_indices=c(7,18), num_cores=1)
+
+get_clusters_batch(template=template, input_dir='path/to/dir', output_dir='path/to/dir',
+writer_indices=c(1,4), doc_indices=c(5,10), num_cores=5)
+```
diff --git a/docs/man/get_credible_intervals.md b/docs/man/get_credible_intervals.md
new file mode 100644
index 00000000..def6a94b
--- /dev/null
+++ b/docs/man/get_credible_intervals.md
@@ -0,0 +1,102 @@
+
+
+# Get Credible Intervals
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+In a model created with fit_model()
the pi parameters are
+the estimate of the true cluster fill count for a particular writer and
+cluster. The function get_credible_intervals()
calculates
+the credible intervals of the pi parameters for each writer in the
+model.
+
+## Usage
+
+get_credible_intervals(model, interval_min = 0.05, interval_max = 0.95)
+
+
+## Arguments
+
+
+
+
+model
+ |
+
+A model output by fit_model()
+ |
+
+
+
+interval_min
+ |
+
+The lower bound for the credible interval. The number must be between 0
+and 1.
+ |
+
+
+
+interval_max
+ |
+
+The upper bound for the credible interval. The number must be greater
+than interval_min and must be less than 1.
+ |
+
+
+
+## Value
+
+A list of data frames. Each data frame lists the credible intervals for
+a single writer.
+
+## Examples
+
+``` r
+library(handwriter)
+
+get_credible_intervals(model=example_model)
+```
+
+ [[1]]
+ quantile cluster_1 cluster_2 cluster_3 cluster_4 cluster_5 writer
+ 1 5% 0.06042425 0.02493705 0.1418073 0.5529695 0.1306786 w0009
+ 2 50% 0.07366519 0.03478669 0.1647020 0.5782510 0.1489102 w0009
+ 3 95% 0.08875836 0.04671823 0.1840218 0.6088443 0.1701284 w0009
+
+ [[2]]
+ quantile cluster_1 cluster_2 cluster_3 cluster_4 cluster_5 writer
+ 1 5% 0.008342953 5.982238e-05 0.2480043 0.4153643 0.2096460 w0030
+ 2 50% 0.017026968 1.492831e-03 0.2840930 0.4549356 0.2402698 w0030
+ 3 95% 0.029416108 8.076710e-03 0.3161589 0.4931652 0.2830293 w0030
+
+ [[3]]
+ quantile cluster_1 cluster_2 cluster_3 cluster_4 cluster_5 writer
+ 1 5% 0.02039637 0.01621031 0.08938908 0.7044609 0.08201707 w0238
+ 2 50% 0.02877164 0.02494265 0.10993121 0.7323968 0.10357189 w0238
+ 3 95% 0.04086654 0.03510818 0.12997545 0.7596250 0.12387242 w0238
+
+``` r
+get_credible_intervals(model=example_model, interval_min=0.05, interval_max=0.95)
+```
+
+ [[1]]
+ quantile cluster_1 cluster_2 cluster_3 cluster_4 cluster_5 writer
+ 1 5% 0.06042425 0.02493705 0.1418073 0.5529695 0.1306786 w0009
+ 2 50% 0.07366519 0.03478669 0.1647020 0.5782510 0.1489102 w0009
+ 3 95% 0.08875836 0.04671823 0.1840218 0.6088443 0.1701284 w0009
+
+ [[2]]
+ quantile cluster_1 cluster_2 cluster_3 cluster_4 cluster_5 writer
+ 1 5% 0.008342953 5.982238e-05 0.2480043 0.4153643 0.2096460 w0030
+ 2 50% 0.017026968 1.492831e-03 0.2840930 0.4549356 0.2402698 w0030
+ 3 95% 0.029416108 8.076710e-03 0.3161589 0.4931652 0.2830293 w0030
+
+ [[3]]
+ quantile cluster_1 cluster_2 cluster_3 cluster_4 cluster_5 writer
+ 1 5% 0.02039637 0.01621031 0.08938908 0.7044609 0.08201707 w0238
+ 2 50% 0.02877164 0.02494265 0.10993121 0.7323968 0.10357189 w0238
+ 3 95% 0.04086654 0.03510818 0.12997545 0.7596250 0.12387242 w0238
diff --git a/docs/man/get_posterior_probabilities.md b/docs/man/get_posterior_probabilities.md
new file mode 100644
index 00000000..143d1046
--- /dev/null
+++ b/docs/man/get_posterior_probabilities.md
@@ -0,0 +1,62 @@
+
+
+# Get Posterior Probabilities
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Get the posterior probabilities for questioned document analyzed with
+analyze_questioned_documents()
.
+
+## Usage
+
+get_posterior_probabilities(analysis, questioned_doc)
+
+
+## Arguments
+
+
+
+
+analysis
+ |
+
+The output of analyze_questioned_documents() . If more than
+one questioned document was analyzed with this function, then the data
+frame analysis$posterior_probabilities lists the posterior probabilities
+for all questioned documents. get_posterior_probabilities()
+creates a data frame of the posterior probabilities for a single
+questioned document and sorts the known writers from the most likely to
+least likely to have written the questioned document.
+ |
+
+
+
+questioned_doc
+ |
+
+The filename of the questioned document
+ |
+
+
+
+## Value
+
+A data frame of posterior probabilities for the questioned document
+
+## Examples
+
+``` r
+library(handwriter)
+
+get_posterior_probabilities(
+ analysis = example_analysis,
+ questioned_doc = "w0030_s03_pWOZ_r01"
+)
+```
+
+ known_writer w0030_s03_pWOZ_r01
+ 2 known_writer_w0030 1
+ 1 known_writer_w0009 0
+ 3 known_writer_w0238 0
diff --git a/docs/man/graphToPrototype.md b/docs/man/graphToPrototype.md
new file mode 100644
index 00000000..0b602fc0
--- /dev/null
+++ b/docs/man/graphToPrototype.md
@@ -0,0 +1,46 @@
+
+
+# Convert graph to a prototype
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+A graph prototype consists of the starting and ending points of each
+path in the graph, as well as and evenly spaced points along each path.
+The prototype also stores the center point of the graph. All points are
+represented as xy-coordinates and the center point is at (0,0).
+
+## Usage
+
+graphToPrototype(graph, numPathCuts = 8)
+
+
+## Arguments
+
+
+
+
+graph
+ |
+
+A graph from a handwriting sample
+ |
+
+
+
+numPathCuts
+ |
+
+Number of segments to cut the path(s) into
+ |
+
+
+
+## Value
+
+List of pathEnds, pathQuarters, and pathCenters given as (x,y)
+coordinates with the graph centroid at (0,0). The returned list also
+contains path lengths. pathQuarters gives the (x,y) coordinates of the
+path at the cut points and despite the name, the path might not be cut
+into quarters.
diff --git a/docs/man/london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..95bf8111
Binary files /dev/null and b/docs/man/london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..0eb43590
Binary files /dev/null and b/docs/man/london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/london.md b/docs/man/london.md
new file mode 100644
index 00000000..b57fea21
--- /dev/null
+++ b/docs/man/london.md
@@ -0,0 +1,39 @@
+
+
+# Cursive written word: London
+
+## Description
+
+Cursive written word: London
+
+## Usage
+
+london
+
+
+## Format
+
+Binary image matrix. 148 rows and 481 columns.
+
+## Examples
+
+``` r
+library(handwriter)
+
+london_document <- list()
+london_document$image <- london
+plotImage(london_document)
+```
+
+![](london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+london_document$thin <- thinImage(london_document$image)
+plotImageThinned(london_document)
+```
+
+![](london.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
+
+``` r
+london_processList <- processHandwriting(london_document$thin, dim(london_document$image))
+```
diff --git a/docs/man/make_clustering_template.md b/docs/man/make_clustering_template.md
new file mode 100644
index 00000000..c659eb1b
--- /dev/null
+++ b/docs/man/make_clustering_template.md
@@ -0,0 +1,115 @@
+
+
+# Make Clustering Template
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+make_clustering_template()
applies a K-means clustering
+algorithm to the input handwriting samples pre-processed with
+process_batch_dir()
and saved in the input folder
+main_dir \> data \>
+template_graphs
. The K-means algorithm sorts the graphs in the
+input handwriting samples into groups, or clusters, of similar
+graphs.
+
+## Usage
+
+make_clustering_template(
+ main_dir,
+ template_docs,
+ writer_indices,
+ centers_seed,
+ K = 40,
+ num_dist_cores = 1,
+ max_iters = 25
+)
+
+
+## Arguments
+
+
+
+
+main_dir
+ |
+
+Main directory that will store template files
+ |
+
+
+
+template_docs
+ |
+
+A directory containing template training images
+ |
+
+
+
+writer_indices
+ |
+
+A vector of the starting and ending location of the writer ID in the
+file name.
+ |
+
+
+
+centers_seed
+ |
+
+Integer seed for the random number generator when selecting starting
+cluster centers.
+ |
+
+
+
+K
+ |
+
+Integer number of clusters
+ |
+
+
+
+num_dist_cores
+ |
+
+Integer number of cores to use for the distance calculations in the
+K-means algorithm. Each iteration of the K-means algorithm calculates
+the distance between each input graph and each cluster center.
+ |
+
+
+
+max_iters
+ |
+
+Maximum number of iterations to allow the K-means algorithm to run
+ |
+
+
+
+## Value
+
+List containing the cluster template
+
+## Examples
+
+``` r
+library(handwriter)
+
+main_dir <- "path/to/folder"
+template_docs <- "path/to/template_training_docs"
+template_list <- make_clustering_template(
+ main_dir = main_dir,
+ template_docs = template_docs,
+ writer_indices = c(2, 5),
+ K = 10,
+ num_dist_cores = 2,
+ max_iters = 25,
+ centers_seed = 100,
+)
+```
diff --git a/docs/man/message.md b/docs/man/message.md
new file mode 100644
index 00000000..268d446a
--- /dev/null
+++ b/docs/man/message.md
@@ -0,0 +1,33 @@
+
+
+# Full page image of the handwritten London letter.
+
+## Description
+
+Full page image of the handwritten London letter.
+
+## Usage
+
+message
+
+
+## Format
+
+Binary image matrix. 1262 rows and 1162 columns.
+
+## Examples
+
+``` r
+library(handwriter)
+
+message_document <- list()
+message_document$image <- message
+plotImage(message_document)
+
+message_document <- list()
+message_document$image <- message
+plotImage(message_document)
+message_document$thin <- thinImage(message_document$image)
+plotImageThinned(message_document)
+message_processList <- processHandwriting(message_document$thin, dim(message_document$image))
+```
diff --git a/docs/man/nature1.md b/docs/man/nature1.md
new file mode 100644
index 00000000..7366561b
--- /dev/null
+++ b/docs/man/nature1.md
@@ -0,0 +1,34 @@
+
+
+# Full page image of the 4th sample (nature) of handwriting from the first writer.
+
+## Description
+
+Full page image of the 4th sample (nature) of handwriting from the first
+writer.
+
+## Usage
+
+nature1
+
+
+## Format
+
+Binary image matrix. 811 rows and 1590 columns.
+
+## Examples
+
+``` r
+library(handwriter)
+
+nature1_document <- list()
+nature1_document$image <- nature1
+plotImage(nature1_document)
+
+nature1_document <- list()
+nature1_document$image <- nature1
+plotImage(nature1_document)
+nature1_document$thin <- thinImage(nature1_document$image)
+plotImageThinned(nature1_document)
+nature1_processList <- processHandwriting(nature1_document$thin, dim(nature1_document$image))
+```
diff --git a/docs/man/plotImage.md b/docs/man/plotImage.md
new file mode 100644
index 00000000..674e344b
--- /dev/null
+++ b/docs/man/plotImage.md
@@ -0,0 +1,45 @@
+
+
+# Plot Image
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function plots a basic black and white image.
+
+## Usage
+
+plotImage(doc)
+
+
+## Arguments
+
+
+
+
+doc
+ |
+
+A document processed with processDocument() or a binary
+matrix (all entries are 0 or 1)
+ |
+
+
+
+## Value
+
+ggplot plot
+
+## Examples
+
+``` r
+library(handwriter)
+
+csafe_document <- list()
+csafe_document$image <- csafe
+plotImage(csafe_document)
+
+document <- processDocument('path/to/image.png')
+plotImage(document)
+```
diff --git a/docs/man/plotImageThinned.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plotImageThinned.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..8f95d9c0
Binary files /dev/null and b/docs/man/plotImageThinned.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plotImageThinned.md b/docs/man/plotImageThinned.md
new file mode 100644
index 00000000..0e7d1b25
--- /dev/null
+++ b/docs/man/plotImageThinned.md
@@ -0,0 +1,45 @@
+
+
+# Plot Thinned Image
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function returns a plot with the full image plotted in light gray
+and the thinned skeleton printed in black on top.
+
+## Usage
+
+plotImageThinned(doc)
+
+
+## Arguments
+
+
+
+
+doc
+ |
+
+A document processed with processHandwriting()
+ |
+
+
+
+## Value
+
+gpplot plot of thinned image
+
+## Examples
+
+``` r
+library(handwriter)
+
+csafe_document <- list()
+csafe_document$image <- csafe
+csafe_document$thin <- thinImage(csafe_document$image)
+plotImageThinned(csafe_document)
+```
+
+![](plotImageThinned.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
diff --git a/docs/man/plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..1ca7aa85
Binary files /dev/null and b/docs/man/plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..0ea0b136
Binary files /dev/null and b/docs/man/plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plotLetter.md b/docs/man/plotLetter.md
new file mode 100644
index 00000000..b899fdf0
--- /dev/null
+++ b/docs/man/plotLetter.md
@@ -0,0 +1,105 @@
+
+
+# Plot Letter
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function returns a plot of a single graph extracted from a
+document. It uses the letterList parameter from the
+processHandwriting()
or processDocument()
+function and accepts a single value as whichLetter
. Dims
+requires the dimensions of the entire document, since this isn’t
+contained in processHandwriting()
or
+processDocument()
.
+
+## Usage
+
+plotLetter(
+ doc,
+ whichLetter,
+ showPaths = TRUE,
+ showCentroid = TRUE,
+ showSlope = TRUE,
+ showNodes = TRUE
+)
+
+
+## Arguments
+
+
+
+
+doc
+ |
+
+A document processed with processHandwriting() or
+processDocument()
+ |
+
+
+
+whichLetter
+ |
+
+Single value in 1:length(letterList) denoting which letter to plot.
+ |
+
+
+
+showPaths
+ |
+
+Whether the calculated paths on the letter should be shown with numbers.
+ |
+
+
+
+showCentroid
+ |
+
+Whether the centroid should be shown
+ |
+
+
+
+showSlope
+ |
+
+Whether the slope should be shown
+ |
+
+
+
+showNodes
+ |
+
+Whether the nodes should be shown
+ |
+
+
+
+## Value
+
+Plot of single letter.
+
+## Examples
+
+``` r
+library(handwriter)
+
+twoSent_document = list()
+twoSent_document$image = twoSent
+twoSent_document$thin = thinImage(twoSent_document$image)
+twoSent_document$process = processHandwriting(twoSent_document$thin, dim(twoSent_document$image))
+plotLetter(twoSent_document, 1)
+```
+
+![](plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+plotLetter(twoSent_document, 4, showPaths = FALSE)
+```
+
+![](plotLetter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
diff --git a/docs/man/plotLine.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plotLine.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..2d7f9f30
Binary files /dev/null and b/docs/man/plotLine.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plotLine.md b/docs/man/plotLine.md
new file mode 100644
index 00000000..89b42e69
--- /dev/null
+++ b/docs/man/plotLine.md
@@ -0,0 +1,68 @@
+
+
+# Plot Line
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function returns a plot of a single line extracted from a document.
+It uses the letterList parameter from the processHandwriting function
+and accepts a single value as whichLetter. Dims requires the dimensions
+of the entire document, since this isn’t contained in
+processHandwriting.
+
+## Usage
+
+plotLine(letterList, whichLine, dims)
+
+
+## Arguments
+
+
+
+
+letterList
+ |
+
+Letter list from processHandwriting function
+ |
+
+
+
+whichLine
+ |
+
+Single value denoting which line to plot - checked if too big inside
+function.
+ |
+
+
+
+dims
+ |
+
+Dimensions of the original document
+ |
+
+
+
+## Value
+
+ggplot plot of single line
+
+## Examples
+
+``` r
+library(handwriter)
+
+twoSent_document = list()
+twoSent_document$image = twoSent
+twoSent_document$thin = thinImage(twoSent_document$image)
+twoSent_processList = processHandwriting(twoSent_document$thin, dim(twoSent_document$image))
+
+dims = dim(twoSent_document$image)
+plotLine(twoSent_processList$letterList, 1, dims)
+```
+
+![](plotLine.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
diff --git a/docs/man/plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..b40dc0d3
Binary files /dev/null and b/docs/man/plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..57bd57e3
Binary files /dev/null and b/docs/man/plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plotNodes.md b/docs/man/plotNodes.md
new file mode 100644
index 00000000..ec146568
--- /dev/null
+++ b/docs/man/plotNodes.md
@@ -0,0 +1,80 @@
+
+
+# Plot Nodes
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function returns a plot with the full image plotted in light gray
+and the skeleton printed in black, with red triangles over the vertices.
+Also called from plotPath, which is a more useful function, in general.
+
+## Usage
+
+plotNodes(doc, plot_break_pts = FALSE, nodeSize = 3, nodeColor = "red")
+
+
+## Arguments
+
+
+
+
+doc
+ |
+
+A document processed with processHandwriting()
+ |
+
+
+
+plot_break_pts
+ |
+
+Logical value as to whether to plot nodes or break points.
+plot_break_pts=FALSE plots nodes and plot_break_pts=TRUE plots break
+point.
+ |
+
+
+
+nodeSize
+ |
+
+Size of triangles printed. 3 by default. Move down to 2 or 1 for small
+text images.
+ |
+
+
+
+nodeColor
+ |
+
+Which color the nodes should be
+ |
+
+
+
+## Value
+
+Plot of full and thinned image with vertices overlaid.
+
+## Examples
+
+``` r
+library(handwriter)
+
+csafe_document <- list()
+csafe_document$image <- csafe
+csafe_document$thin <- thinImage(csafe_document$image)
+csafe_document$process <- processHandwriting(csafe_document$thin, dim(csafe_document$image))
+plotNodes(csafe_document)
+```
+
+![](plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+plotNodes(csafe_document, nodeSize=6, nodeColor="black")
+```
+
+![](plotNodes.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
diff --git a/docs/man/plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..4390b706
Binary files /dev/null and b/docs/man/plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..78c9b14e
Binary files /dev/null and b/docs/man/plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plot_cluster_centers.md b/docs/man/plot_cluster_centers.md
new file mode 100644
index 00000000..44037d9c
--- /dev/null
+++ b/docs/man/plot_cluster_centers.md
@@ -0,0 +1,76 @@
+
+
+# Plot Template Cluster Centers
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Plot the cluster centers of a cluster template created with
+make_clustering_template
. This function uses a K-Means type
+algorithm to sort graphs from training documents into clusters. On each
+iteration of the algorithm, it calculates the mean graph of each cluster
+and finds the graph in each cluster that is closest to the mean graph.
+The graphs closest to the mean graphs are used as the cluster centers
+for the next iteration. Handwriter stores the cluster centers of a
+cluster template as graph prototypes. A graph prototype consists of the
+starting and ending points of each path in the graph, as well as and
+evenly spaced points along each path. The prototype also stores the
+center point of the graph. All points are represented as xy-coordinates
+and the center point is at (0,0).
+
+## Usage
+
+plot_cluster_centers(template, plot_graphs = FALSE, size = 100)
+
+
+## Arguments
+
+
+
+
+template
+ |
+
+A cluster template created with make_clustering_template
+ |
+
+
+
+plot_graphs
+ |
+
+TRUE plots all graphs in each cluster in addition to the cluster
+centers. FALSE only plots the cluster centers.
+ |
+
+
+
+size
+ |
+
+The size of the output plot
+ |
+
+
+
+## Value
+
+A plot
+
+## Examples
+
+``` r
+library(handwriter)
+
+# plot cluster centers from example template
+plot_cluster_centers(example_cluster_template)
+```
+
+![](plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+plot_cluster_centers(example_cluster_template, plot_graphs = TRUE)
+```
+
+![](plot_cluster_centers.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
diff --git a/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..055ba447
Binary files /dev/null and b/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..11af2f91
Binary files /dev/null and b/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png b/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png
new file mode 100644
index 00000000..9f4228c9
Binary files /dev/null and b/docs/man/plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png differ
diff --git a/docs/man/plot_cluster_fill_counts.md b/docs/man/plot_cluster_fill_counts.md
new file mode 100644
index 00000000..3c828e89
--- /dev/null
+++ b/docs/man/plot_cluster_fill_counts.md
@@ -0,0 +1,68 @@
+
+
+# Plot Cluster Fill Counts
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Plot the cluster fill counts for each document in
+formatted_data
.
+
+## Usage
+
+plot_cluster_fill_counts(formatted_data, facet = TRUE)
+
+
+## Arguments
+
+
+
+
+formatted_data
+ |
+
+Data created by format_template_data() ,
+fit_model() , or analyze_questioned_documents()
+ |
+
+
+
+facet
+ |
+
+TRUE uses facet_wrap to create a subplot for
+each writer. FALSE plots the data on a single plot.
+ |
+
+
+
+## Value
+
+ggplot plot of cluster fill counts
+
+## Examples
+
+``` r
+library(handwriter)
+
+# Plot cluster fill counts for template training documents
+template_data <- format_template_data(example_cluster_template)
+plot_cluster_fill_counts(formatted_data = template_data, facet = TRUE)
+```
+
+![](plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+# Plot cluster fill counts for model training documents
+plot_cluster_fill_counts(formatted_data = example_model, facet = TRUE)
+```
+
+![](plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
+
+``` r
+# Plot cluster fill counts for questioned documents
+plot_cluster_fill_counts(formatted_data = example_analysis, facet = FALSE)
+```
+
+![](plot_cluster_fill_counts.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png)
diff --git a/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..bff80a41
Binary files /dev/null and b/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..b0d5c786
Binary files /dev/null and b/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png b/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png
new file mode 100644
index 00000000..35206658
Binary files /dev/null and b/docs/man/plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png differ
diff --git a/docs/man/plot_cluster_fill_rates.md b/docs/man/plot_cluster_fill_rates.md
new file mode 100644
index 00000000..085194f3
--- /dev/null
+++ b/docs/man/plot_cluster_fill_rates.md
@@ -0,0 +1,68 @@
+
+
+# Plot Cluster Fill Rates
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Plot the cluster fill rates for each document in
+formatted_data
.
+
+## Usage
+
+plot_cluster_fill_rates(formatted_data, facet = FALSE)
+
+
+## Arguments
+
+
+
+
+formatted_data
+ |
+
+Data created by format_template_data() ,
+fit_model() , or analyze_questioned_documents()
+ |
+
+
+
+facet
+ |
+
+TRUE uses facet_wrap to create a subplot for
+each writer. FALSE plots the data on a single plot.
+ |
+
+
+
+## Value
+
+ggplot plot of cluster fill rates
+
+## Examples
+
+``` r
+library(handwriter)
+
+# Plot cluster fill rates for template training documents
+template_data <- format_template_data(example_cluster_template)
+plot_cluster_fill_rates(formatted_data = template_data, facet = TRUE)
+```
+
+![](plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+# Plot cluster fill rates for model training documents
+plot_cluster_fill_rates(formatted_data = example_model, facet = TRUE)
+```
+
+![](plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
+
+``` r
+# Plot cluster fill rates for questioned documents
+plot_cluster_fill_rates(formatted_data = example_analysis, facet = FALSE)
+```
+
+![](plot_cluster_fill_rates.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png)
diff --git a/docs/man/plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..12500ee8
Binary files /dev/null and b/docs/man/plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..44424395
Binary files /dev/null and b/docs/man/plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plot_credible_intervals.md b/docs/man/plot_credible_intervals.md
new file mode 100644
index 00000000..26c389a6
--- /dev/null
+++ b/docs/man/plot_credible_intervals.md
@@ -0,0 +1,80 @@
+
+
+# Plot Credible Intervals
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Plot credible intervals for the model’s pi parameters that estimate the
+true writer cluster fill counts.
+
+## Usage
+
+plot_credible_intervals(
+ model,
+ interval_min = 0.025,
+ interval_max = 0.975,
+ facet = FALSE
+)
+
+
+## Arguments
+
+
+
+
+model
+ |
+
+A model created by fit_model()
+ |
+
+
+
+interval_min
+ |
+
+The lower bound of the credible interval. It must be greater than zero
+and less than 1.
+ |
+
+
+
+interval_max
+ |
+
+The upper bound of the credible interval. It must be greater than the
+interval minimum and less than 1.
+ |
+
+
+
+facet
+ |
+
+TRUE uses facet_wrap to create a subplot for
+each writer. FALSE plots the data on a single plot.
+ |
+
+
+
+## Value
+
+ggplot plot credible intervals
+
+## Examples
+
+``` r
+library(handwriter)
+
+plot_credible_intervals(model = example_model)
+```
+
+![](plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+plot_credible_intervals(model = example_model, facet = TRUE)
+```
+
+![](plot_credible_intervals.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
diff --git a/docs/man/plot_posterior_probabilities.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plot_posterior_probabilities.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..2684778d
Binary files /dev/null and b/docs/man/plot_posterior_probabilities.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plot_posterior_probabilities.md b/docs/man/plot_posterior_probabilities.md
new file mode 100644
index 00000000..0321f68c
--- /dev/null
+++ b/docs/man/plot_posterior_probabilities.md
@@ -0,0 +1,44 @@
+
+
+# Plot Posterior Probabilities
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Creates a tile plot of posterior probabilities of writership for each
+questioned document and each known writer analyzed with
+analyze_questioned_documents()
.
+
+## Usage
+
+plot_posterior_probabilities(analysis)
+
+
+## Arguments
+
+
+
+
+analysis
+ |
+
+A named list of analysis results from
+analyze_questioned_documents() .
+ |
+
+
+
+## Value
+
+A tile plot of posterior probabilities of writership.
+
+## Examples
+
+``` r
+library(handwriter)
+
+plot_posterior_probabilities(analysis = example_analysis)
+```
+
+![](plot_posterior_probabilities.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
diff --git a/docs/man/plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..ebee0a3b
Binary files /dev/null and b/docs/man/plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..a1914ad5
Binary files /dev/null and b/docs/man/plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/plot_trace.md b/docs/man/plot_trace.md
new file mode 100644
index 00000000..8f0217a5
--- /dev/null
+++ b/docs/man/plot_trace.md
@@ -0,0 +1,57 @@
+
+
+# Plot Trace
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Create a trace plot for all chains for a single variable of a fitted
+model created by fit_model()
. If the model contains more
+than one chain, the chains will be combined by pasting them together.
+
+## Usage
+
+plot_trace(variable, model)
+
+
+## Arguments
+
+
+
+
+variable
+ |
+
+The name of a variable in the model
+ |
+
+
+
+model
+ |
+
+A model created by fit_model()
+ |
+
+
+
+## Value
+
+A trace plot
+
+## Examples
+
+``` r
+library(handwriter)
+
+plot_trace(model = example_model, variable = "pi[1,1]")
+```
+
+![](plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+plot_trace(model = example_model, variable = "mu[2,3]")
+```
+
+![](plot_trace.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
diff --git a/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..b8f0d403
Binary files /dev/null and b/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png b/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png
new file mode 100644
index 00000000..a648ce57
Binary files /dev/null and b/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png differ
diff --git a/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png b/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png
new file mode 100644
index 00000000..28f30f26
Binary files /dev/null and b/docs/man/processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png differ
diff --git a/docs/man/processDocument.md b/docs/man/processDocument.md
new file mode 100644
index 00000000..80ad2cfc
--- /dev/null
+++ b/docs/man/processDocument.md
@@ -0,0 +1,57 @@
+
+
+# Process Document
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Load a handwriting sample from a PNG image. Then binarize, thin, and
+split the handwriting into graphs.
+
+## Usage
+
+processDocument(path)
+
+
+## Arguments
+
+
+
+
+path
+ |
+
+File path for handwriting document. The document must be in PNG file
+format.
+ |
+
+
+
+## Value
+
+The processed document as a list
+
+## Examples
+
+``` r
+library(handwriter)
+
+image_path <- system.file("extdata", "phrase_example.png", package = "handwriter")
+doc <- processDocument(image_path)
+plotImage(doc)
+```
+
+![](processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
+
+``` r
+plotImageThinned(doc)
+```
+
+![](processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-2.png)
+
+``` r
+plotNodes(doc)
+```
+
+![](processDocument.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-3.png)
diff --git a/docs/man/processHandwriting.md b/docs/man/processHandwriting.md
new file mode 100644
index 00000000..6fa4849e
--- /dev/null
+++ b/docs/man/processHandwriting.md
@@ -0,0 +1,54 @@
+
+
+# Process Handwriting by Component
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+The main driver of handwriting processing. Takes in an image of thinned
+handwriting created with thinImage()
and splits the the
+handwriting into shapes called graphs. Instead of processing
+the entire document at once, the thinned writing is separated into
+connected components and each component is split into graphs.
+
+## Usage
+
+processHandwriting(img, dims)
+
+
+## Arguments
+
+
+
+
+img
+ |
+
+Thinned binary image created with thinImage() .
+ |
+
+
+
+dims
+ |
+
+Dimensions of thinned binary image.
+ |
+
+
+
+## Value
+
+A list of the processed image
+
+## Examples
+
+``` r
+library(handwriter)
+
+twoSent_document <- list()
+twoSent_document$image <- twoSent
+twoSent_document$thin <- thinImage(twoSent_document$image)
+twoSent_processList <- processHandwriting(twoSent_document$thin, dim(twoSent_document$image))
+```
diff --git a/docs/man/process_batch_dir.md b/docs/man/process_batch_dir.md
new file mode 100644
index 00000000..1ad07b5f
--- /dev/null
+++ b/docs/man/process_batch_dir.md
@@ -0,0 +1,67 @@
+
+
+# Process Batch Directory
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Process a list of handwriting samples saved as PNG images in a
+directory: (1) Load the image and convert it to black and white with
+readPNGBinary()
(2) Thin the handwriting to one pixel in
+width with thinImage()
(3) Run
+processHandwriting()
to split the handwriting into parts
+called edges and place nodes at the ends of edges.
+Then combine edges into component shapes called graphs. (4)
+Save the processed document in an RDS file. (5) Optional. Return a list
+of the processed documents.
+
+## Usage
+
+process_batch_dir(input_dir, output_dir = ".", skip_docs_on_retry = TRUE)
+
+
+## Arguments
+
+
+
+
+input_dir
+ |
+
+Input directory that contains images
+ |
+
+
+
+output_dir
+ |
+
+A directory to save the processed images
+ |
+
+
+
+skip_docs_on_retry
+ |
+
+Logical whether to skip documents in input_dir that caused errors on a
+previous run. The errors and document names are stored in output_dir \>
+problems.txt. If this is the first run, process_batch_list
+will attempt to process all documents in input_dir.
+ |
+
+
+
+## Value
+
+A list of processed documents
+
+## Examples
+
+``` r
+library(handwriter)
+
+process_batch_list("path/to/input_dir", "path/to/output_dir")
+docs <- process_batch_list("path/to/input_dir", "path/to/output_dir")
+```
diff --git a/docs/man/process_batch_list.md b/docs/man/process_batch_list.md
new file mode 100644
index 00000000..3005b552
--- /dev/null
+++ b/docs/man/process_batch_list.md
@@ -0,0 +1,69 @@
+
+
+# Process Batch List
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Process a list of handwriting samples saved as PNG images: (1) Load the
+image and convert it to black and white with
+readPNGBinary()
(2) Thin the handwriting to one pixel in
+width with thinImage()
(3) Run
+processHandwriting()
to split the handwriting into parts
+called edges and place nodes at the ends of edges.
+Then combine edges into component shapes called graphs. (4)
+Save the processed document in an RDS file. (5) Optional. Return a list
+of the processed documents.
+
+## Usage
+
+process_batch_list(images, output_dir, skip_docs_on_retry = TRUE)
+
+
+## Arguments
+
+
+
+
+images
+ |
+
+A vector of image file paths
+ |
+
+
+
+output_dir
+ |
+
+A directory to save the processed images
+ |
+
+
+
+skip_docs_on_retry
+ |
+
+Logical whether to skip documents in the images arguement that caused
+errors on a previous run. The errors and document names are stored in
+output_dir \> problems.txt. If this is the first run,
+process_batch_list will attempt to process all documents in
+the images arguement.
+ |
+
+
+
+## Value
+
+A list of processed documents
+
+## Examples
+
+``` r
+library(handwriter)
+
+images <- c('path/to/image1.png', 'path/to/image2.png', 'path/to/image3.png')
+process_batch_list(images, "path/to/output_dir", FALSE)
+docs <- process_batch_list(images, "path/to/output_dir", TRUE)
+```
diff --git a/docs/man/readPNGBinary.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png b/docs/man/readPNGBinary.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png
new file mode 100644
index 00000000..b8f0d403
Binary files /dev/null and b/docs/man/readPNGBinary.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png differ
diff --git a/docs/man/readPNGBinary.md b/docs/man/readPNGBinary.md
new file mode 100644
index 00000000..57ef0a2b
--- /dev/null
+++ b/docs/man/readPNGBinary.md
@@ -0,0 +1,86 @@
+
+
+# Read PNG Binary
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function reads in and binarizes a PNG image.
+
+## Usage
+
+readPNGBinary(
+ path,
+ cutoffAdjust = 0,
+ clean = TRUE,
+ crop = TRUE,
+ inversion = FALSE
+)
+
+
+## Arguments
+
+
+
+
+path
+ |
+
+File path for image.
+ |
+
+
+
+cutoffAdjust
+ |
+
+Multiplicative adjustment to the K-means estimated binarization cutoff.
+ |
+
+
+
+clean
+ |
+
+Whether to fill in white pixels with 7 or 8 neighbors. This will help a
+lot when thinning – keeps from getting little white bubbles in text.
+ |
+
+
+
+crop
+ |
+
+Logical value dictating whether or not to crop the white out around the
+image. TRUE by default.
+ |
+
+
+
+inversion
+ |
+
+Logical value dictating whether or not to flip each pixel of binarized
+image. Flipping happens after binarization. FALSE by default.
+ |
+
+
+
+## Value
+
+Returns image from path. 0 represents black, and 1 represents white by
+default.
+
+## Examples
+
+``` r
+library(handwriter)
+
+image_path <- system.file("extdata", "phrase_example.png", package = "handwriter")
+csafe_document <- list()
+csafe_document$image = readPNGBinary(image_path)
+plotImage(csafe_document)
+```
+
+![](readPNGBinary.markdown_strict_files/figure-markdown_strict/unnamed-chunk-1-1.png)
diff --git a/docs/man/read_and_process.md b/docs/man/read_and_process.md
new file mode 100644
index 00000000..96fbb81a
--- /dev/null
+++ b/docs/man/read_and_process.md
@@ -0,0 +1,54 @@
+
+
+# Read and Process
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+
+
+Development on read_and_process()
is complete. We recommend
+using processDocument()
. read_and_process(image_name,
+“document”)
is equivalent to
+processDocument(image_name)
.
+
+## Usage
+
+read_and_process(image_name, transform_output)
+
+
+## Arguments
+
+
+
+
+image_name
+ |
+
+The file path to an image
+ |
+
+
+
+transform_output
+ |
+
+The type of transformation to perform on the output
+ |
+
+
+
+## Value
+
+A list of the processed image components
+
+## Examples
+
+``` r
+library(handwriter)
+
+# use handwriting example from handwriter package
+image_path <- system.file("extdata", "phrase_example.png", package = "handwriter")
+doc <- read_and_process(image_path, "document")
+```
diff --git a/docs/man/rgb2grayscale.md b/docs/man/rgb2grayscale.md
new file mode 100644
index 00000000..113284c2
--- /dev/null
+++ b/docs/man/rgb2grayscale.md
@@ -0,0 +1,31 @@
+
+
+# rgba2grayscale
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Changes RGB image to grayscale
+
+## Usage
+
+rgb2grayscale(img)
+
+
+## Arguments
+
+
+
+
+img
+ |
+
+A 3D array with slices R, G, and B
+ |
+
+
+
+## Value
+
+img as a 3D array as grayscale
diff --git a/docs/man/rgba2rgb.md b/docs/man/rgba2rgb.md
new file mode 100644
index 00000000..92e42c56
--- /dev/null
+++ b/docs/man/rgba2rgb.md
@@ -0,0 +1,31 @@
+
+
+# rgba2rgb
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Removes alpha channel from png image.
+
+## Usage
+
+rgba2rgb(img)
+
+
+## Arguments
+
+
+
+
+img
+ |
+
+A 3-d array with slices R, G, B, and alpha.
+ |
+
+
+
+## Value
+
+img as a 3D array with alpha channel removed
diff --git a/docs/man/thinImage.md b/docs/man/thinImage.md
new file mode 100644
index 00000000..481edccc
--- /dev/null
+++ b/docs/man/thinImage.md
@@ -0,0 +1,32 @@
+
+
+# thinImage
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+This function returns a vector of locations for black pixels in the
+thinned image. Thinning done using Zhang - Suen algorithm.
+
+## Usage
+
+thinImage(img)
+
+
+## Arguments
+
+
+
+
+img
+ |
+
+A binary matrix of the text that is to be thinned.
+ |
+
+
+
+## Value
+
+A thinned, one pixel wide, image.
diff --git a/docs/man/twoSent.md b/docs/man/twoSent.md
new file mode 100644
index 00000000..f87ba6ff
--- /dev/null
+++ b/docs/man/twoSent.md
@@ -0,0 +1,33 @@
+
+
+# Two sentence printed example handwriting
+
+## Description
+
+Two sentence printed example handwriting
+
+## Usage
+
+twoSent
+
+
+## Format
+
+Binary image matrix. 396 rows and 1947 columns
+
+## Examples
+
+``` r
+library(handwriter)
+
+twoSent_document <- list()
+twoSent_document$image <- twoSent
+plotImage(twoSent_document)
+
+twoSent_document <- list()
+twoSent_document$image <- twoSent
+plotImage(twoSent_document)
+twoSent_document$thin <- thinImage(twoSent_document$image)
+plotImageThinned(twoSent_document)
+twoSent_processList <- processHandwriting(twoSent_document$thin, dim(twoSent_document$image))
+```
diff --git a/docs/man/whichToFill.md b/docs/man/whichToFill.md
new file mode 100644
index 00000000..1ebb9652
--- /dev/null
+++ b/docs/man/whichToFill.md
@@ -0,0 +1,32 @@
+
+
+# whichToFill
+
+[**Source code**](https://github.com/CSAFE-ISU/handwriter/tree/176-automatic-documentation/R/#L)
+
+## Description
+
+Finds pixels in the plot that shouldn’t be white and makes them black.
+Quick and helpful cleaning for before the thinning algorithm runs.
+
+## Usage
+
+whichToFill(img)
+
+
+## Arguments
+
+
+
+
+img
+ |
+
+A binary matrix.
+ |
+
+
+
+## Value
+
+A cleaned up image.
diff --git a/docs/preamble_man_qmd.yml b/docs/preamble_man_qmd.yml
new file mode 100644
index 00000000..cd2e598a
--- /dev/null
+++ b/docs/preamble_man_qmd.yml
@@ -0,0 +1,6 @@
+---
+format:
+ md:
+ prefer-html: true
+---
+
diff --git a/docs/preamble_vignettes_qmd.yml b/docs/preamble_vignettes_qmd.yml
new file mode 100644
index 00000000..1436a9e2
--- /dev/null
+++ b/docs/preamble_vignettes_qmd.yml
@@ -0,0 +1,6 @@
+---
+format:
+ md:
+ prefer_html: true
+default-image-extension: ""
+---
diff --git a/docs/preamble_vignettes_rmd.yml b/docs/preamble_vignettes_rmd.yml
new file mode 100644
index 00000000..b47a68aa
--- /dev/null
+++ b/docs/preamble_vignettes_rmd.yml
@@ -0,0 +1,4 @@
+---
+always_allow_html: yes
+---
+
diff --git a/docs/vignettes/.gitignore b/docs/vignettes/.gitignore
new file mode 100644
index 00000000..097b2416
--- /dev/null
+++ b/docs/vignettes/.gitignore
@@ -0,0 +1,2 @@
+*.html
+*.R
diff --git a/docs/vignettes/handwriter.Rmd b/docs/vignettes/handwriter.Rmd
new file mode 100644
index 00000000..62b13efd
--- /dev/null
+++ b/docs/vignettes/handwriter.Rmd
@@ -0,0 +1,192 @@
+---
+title: "analyze-writing"
+output: rmarkdown::html_vignette
+vignette: >
+ %\VignetteIndexEntry{analyze-writing}
+ %\VignetteEngine{knitr::rmarkdown}
+ %\VignetteEncoding{UTF-8}
+---
+
+```{r, include = FALSE}
+knitr::opts_chunk$set(
+ collapse = TRUE,
+ comment = "#>",
+ message = FALSE,
+ warning = FALSE
+)
+```
+
+```{r setup, echo = FALSE}
+library(handwriter)
+```
+
+## Introduction
+
+This tutorial explains how to perform handwriting analysis on questioned documents using handwriter. In particular, handwriter addresses the scenario where an investigator has a questioned handwritten document, a group of persons of interest has been identified, and the questioned document had to have been written by one of the persons of interest. For example, imagine that a handwritten bomb threat was left at a office building's main desk and the police discover that the note had to have been written by one of the one hundred employees working that day. More details on this method can be found in [Crawford 2022].
+
+## STEP 1: Create the Main Directory and Subdirectories
+
+Create a new folder called `main_dir` on your computer to hold the handwriting documents to be analyzed. When we create a new clustering template and fit a statistical model, those files will also be stored in this folder. Create a sub-folder in `main_dir` called `data`. In the `data` folder, create sub-folders called `model_docs`, `questioned_docs`, and `template_docs`. The folder structure will look like this:
+```bash
+├── main_dir
+│ ├── data
+│ │ ├── model_docs
+│ │ ├── questioned_docs
+│ │ ├── template_docs
+```
+
+
+## STEP 2: Create a Cluster Template
+
+Save the handwritten documents that you want to use to train a new cluster template as PNG images in `main_dir > data > template_docs`. The template training documents need to be from writers that are NOT people of interest. Name all of the PNG images with a consistent format that includes an ID for the writer. For example, the PNG images could be named "writer0001.png", "writer0002.png", "writer0003.png" and so on.
+
+Next, create a new cluster template from the documents in `main_dir > data > template_docs` with the function `make_clustering_template`. This function
+
+1. Processes the template training documents in `template_docs`, decomposing the handwriting into component shapes called *graphs*. The processed graphs are saved in RDS files in `main_dir \> data \> template_graphs`.
+2. Deletes graphs with more than 30 edges.
+3. Randomly selects `K` starting cluster centers using seed `centers_seed` for reproducibility.
+5. Runs a K-means algorithm with the `K` starting cluster centers and the selected graphs. The algorithm iteratively groups the selected graphs into `K` clusters. The final grouping of `K` clusters is the cluster template.
+6. Stores the writer ID for each training document. `writer_indices` is a vector of the start and stop characters of the writer ID in the PNG image file name. For example, if the PNG images are named "writer0001.png", "writer0002.png", "writer0003.png", and so on, `writer_indices = c(7,10)`
+7. Performs some of the processes in parallel. Set the number of cores for parallel processing with `num_dist_cores`.
+
+```{r, eval=FALSE}
+template <- make_clustering_template(
+ main_dir = "path/to/main_dir",
+ template_docs = "path/to/main_dir/data/template_docs",
+ writer_indices = c(7,10),
+ centers_seed = 100,
+ K = 40,
+ num_dist_cores = 4,
+ max_iters = 25)
+```
+
+Type `?make_clustering_template` in the RStudio console for more information about the function's arguments.
+
+For the remainder of this tutorial, we use a small example cluster template, `example_cluster_template` included in handwriter.
+```{r}
+template <- example_cluster_template
+```
+
+The idea behind the cluster template and the hierarchical model is that we can decompose a handwritten document into component graphs, assign each graph to the *nearest* cluster, the cluster with the closest shape, in the cluster template, and count the number of graphs in each cluster. We characterize writers by the number of a writer's graphs that are assigned to each cluster. We refer to this as a writer's *cluster fill counts* and it serves as writer profile.
+
+We can plot the cluster fill counts for each writer in the template training set. First we format the template data to get the cluster fill counts in the proper format for the plotting function.
+
+```{r}
+template_data <- format_template_data(template = template)
+plot_cluster_fill_counts(template_data, facet = TRUE)
+```
+
+
+## STEP 3: Fit a Hierarchical Model
+
+We will use handwriting samples from each person of interest, calculate the cluster fill counts from each sample using the cluster template, and fit a hierarchical model to estimate each person of interest's true cluster fill counts.
+
+Save your known handwriting samples from the persons of interest in `main_dir \> data \> model_docs` as PNG images. The model requires three handwriting samples from each person of interest. Each sample should be at least one paragraph in length. Name the PNG images with a consistent format so that all file names are the same length and the writer ID's are in the same location. For example, "writer0001_doc1.png", "writer0001_doc2.png", "writer0001_doc3.png", "writer0002_doc1.png", and so on.
+
+We fit a hierarchical model with the function `fit_model`. This function does the following:
+
+1. Processes the model training documents in `model_docs`, decomposing the handwriting into component graphs. The processed graphs are saved in RDS files in `main_dir \> data \> model_graphs`.
+2. Calculates the cluster fill counts for each document by assigning each graph to the nearest cluster in the cluster template and counting the number of graphs assigned to each cluster. The cluster assignments are saved in main_dir \> data \> model_clusters.rds
+3. Fits a hierarchical model to the cluster fill counts using the RJAGS package and draws posterior samples of model parameters with the coda package.
+
+In this example, we use 4000 MCMC iterations for the model. The inputs `writer_indices` and `doc_indices` are the starting and stopping characters in the model training documents file names that contains the writer ID and a document name.
+
+```{r, eval = FALSE}
+model <- fit_model(main_dir = "path/to/main_dir",
+ model_docs = "path/to/main_dir/data/model_docs",
+ num_iters = 4000,
+ num_chains = 1,
+ num_cores = 2,
+ writer_indices = c(7, 10),
+ doc_indices = c(11, 14))
+```
+
+For this tutorial, we will use the small example model, `example_model`, included in handwriter. This model was trained from three documents each from writers 9, 30, 203, 238, and 400 from the [CSAFE handwriting database](https://data.csafe.iastate.edu/HandwritingDatabase/).
+```{r}
+model <- example_model
+```
+
+
+We can plot the cluster fill counts for each person of interest. (NOTE: We had to format the template data to work with the plotting function, but the model data is already in the correct format.)
+
+```{r}
+plot_cluster_fill_counts(formatted_data=model, facet = TRUE)
+```
+The bars across the top of each graph show the Writer ID. Each graph has a line for each known handwriting sample from a given writer.
+
+### Hierarchical Model Variables and Burn-in
+If you are interested in the variables used by the hierarchical model, continue reading this section. Otherwise, feel free to skip to the next section to learn how to analyze questioned documents.
+
+We can list the variables in the model:
+```{r}
+names(as.data.frame(coda::as.mcmc(model$fitted_model[[1]])))
+```
+
+View a description of a variable with the `about_variable` function.
+
+```{r}
+about_variable(variable = "mu[1,1]", model = model)
+```
+
+View a trace plot of a variable.
+
+```{r}
+plot_trace(variable = "mu[1,1]", model = model)
+```
+
+If we need to, we can drop the beginning MCMC iterations for burn-in. For example, if we want to drop the first 25 iterations, we use
+
+```{r}
+model <- drop_burnin(model, burn_in = 25)
+```
+
+If we want to save the updated model as the current model for this project, replace `model.rds` in the `data` folder with
+```{r, eval=FALSE}
+saveRDS(model, file='data/model.rds')
+```
+
+## Analyze Questioned Documents
+Save your questioned document(s) in `main_dir > data > questioned_docs` as PNG images. Assign a new writer ID to the questioned documents and name the documents consistently. E.g. "unknown1000_doc1.png", "unknown1001_doc1.png", and so on.
+
+We estimate the posterior probability of writership for each of the questioned documents with the function `analyze_questioned_documents`. This function does the following:
+
+1. **Process Questioned Document(s):** Processes the questioned documents in `questioned_docs`, decomposing the handwriting into component graphs. The processed graphs are saved in RDS files in `main_dir \> data \> questioned_graphs`.
+2. **Estimate the Writer Profile of the Questioned Document(s):** Calculates the cluster fill counts for each questioned document by assigning each graph to the nearest cluster in the cluster template and counting the number of graphs assigned to each cluster. The cluster assignments are saved in `main_dir \> data \> questioned_clusters.rds`.
+3. **Estimate the Posterior Probability of Writership:** Uses the fitted model from Step 3 to estimate the posterior probability of writership for each questioned document and each person of interest. The results are saved in `main_dir \> data \> analysis.rds`.
+
+```{r, eval = FALSE}
+analysis <- analyze_questioned_documents(
+ main_dir = "path/to/main_dir",
+ questioned_docs = "path/to/main_dir/questioned_docs",
+ model = model,
+ writer_indices = c(8,11),
+ doc_indices = c(13,16),
+ num_cores = 2)
+```
+
+Let's pretend that a handwriting sample from each of the 5 "persons of interest" is a questioned document. These documents are also from the [CSAFE handwriting database](https://data.csafe.iastate.edu/HandwritingDatabase/) and have already been analyzed with `example_model` and the results are included in handwriter as `example_analysis`.
+
+```{r}
+analysis <- example_analysis
+```
+
+
+View the cluster fill counts for each questioned document. Intuitively, the model assesses which writer's cluster fill counts look the most like the cluster fill counts observed in each questioned document.
+
+```{r}
+plot_cluster_fill_counts(analysis, facet = TRUE)
+```
+
+View the posterior probabilities of writership.
+
+```{r}
+analysis$posterior_probabilities
+```
+
+
+### For Research Only
+In practice, we would not know who wrote a questioned document, but in research we often perform tests to evaluate models using data where we know the ground truth. Because in this example, we know the true writer of each questioned document, we can measure the accuracy of the model. We define accuracy as the average posterior probability assigned to the true writer. The accuracy of our model is
+
+```{r}
+calculate_accuracy(analysis)
+```
diff --git a/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-10-1.png b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-10-1.png
new file mode 100644
index 00000000..2d6464bb
Binary files /dev/null and b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-10-1.png differ
diff --git a/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-15-1.png b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-15-1.png
new file mode 100644
index 00000000..9a014ef3
Binary files /dev/null and b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-15-1.png differ
diff --git a/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-4-1.png b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-4-1.png
new file mode 100644
index 00000000..055ba447
Binary files /dev/null and b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-4-1.png differ
diff --git a/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-7-1.png b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-7-1.png
new file mode 100644
index 00000000..11af2f91
Binary files /dev/null and b/docs/vignettes/handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-7-1.png differ
diff --git a/docs/vignettes/handwriter.md b/docs/vignettes/handwriter.md
new file mode 100644
index 00000000..9dec30bf
--- /dev/null
+++ b/docs/vignettes/handwriter.md
@@ -0,0 +1,303 @@
+# analyze-writing
+
+
+## Introduction
+
+This tutorial explains how to perform handwriting analysis on questioned
+documents using handwriter. In particular, handwriter addresses the
+scenario where an investigator has a questioned handwritten document, a
+group of persons of interest has been identified, and the questioned
+document had to have been written by one of the persons of interest. For
+example, imagine that a handwritten bomb threat was left at a office
+building’s main desk and the police discover that the note had to have
+been written by one of the one hundred employees working that day. More
+details on this method can be found in \[Crawford 2022\].
+
+## STEP 1: Create the Main Directory and Subdirectories
+
+Create a new folder called `main_dir` on your computer to hold the
+handwriting documents to be analyzed. When we create a new clustering
+template and fit a statistical model, those files will also be stored in
+this folder. Create a sub-folder in `main_dir` called `data`. In the
+`data` folder, create sub-folders called `model_docs`,
+`questioned_docs`, and `template_docs`. The folder structure will look
+like this:
+
+``` bash
+├── main_dir
+│ ├── data
+│ │ ├── model_docs
+│ │ ├── questioned_docs
+│ │ ├── template_docs
+```
+
+## STEP 2: Create a Cluster Template
+
+Save the handwritten documents that you want to use to train a new
+cluster template as PNG images in `main_dir > data > template_docs`. The
+template training documents need to be from writers that are NOT people
+of interest. Name all of the PNG images with a consistent format that
+includes an ID for the writer. For example, the PNG images could be
+named “writer0001.png”, “writer0002.png”, “writer0003.png” and so on.
+
+Next, create a new cluster template from the documents in
+`main_dir > data > template_docs` with the function
+`make_clustering_template`. This function
+
+1. Processes the template training documents in `template_docs`,
+ decomposing the handwriting into component shapes called *graphs*.
+ The processed graphs are saved in RDS files in
+ `main_dir \> data \> template_graphs`.
+2. Deletes graphs with more than 30 edges.
+3. Randomly selects `K` starting cluster centers using seed
+ `centers_seed` for reproducibility.
+4. Runs a K-means algorithm with the `K` starting cluster centers and
+ the selected graphs. The algorithm iteratively groups the selected
+ graphs into `K` clusters. The final grouping of `K` clusters is the
+ cluster template.
+5. Stores the writer ID for each training document. `writer_indices` is
+ a vector of the start and stop characters of the writer ID in the
+ PNG image file name. For example, if the PNG images are named
+ “writer0001.png”, “writer0002.png”, “writer0003.png”, and so on,
+ `writer_indices = c(7,10)`
+6. Performs some of the processes in parallel. Set the number of cores
+ for parallel processing with `num_dist_cores`.
+
+``` r
+template <- make_clustering_template(
+ main_dir = "path/to/main_dir",
+ template_docs = "path/to/main_dir/data/template_docs",
+ writer_indices = c(7,10),
+ centers_seed = 100,
+ K = 40,
+ num_dist_cores = 4,
+ max_iters = 25)
+```
+
+Type `?make_clustering_template` in the RStudio console for more
+information about the function’s arguments.
+
+For the remainder of this tutorial, we use a small example cluster
+template, `example_cluster_template` included in handwriter.
+
+``` r
+template <- example_cluster_template
+```
+
+The idea behind the cluster template and the hierarchical model is that
+we can decompose a handwritten document into component graphs, assign
+each graph to the *nearest* cluster, the cluster with the closest shape,
+in the cluster template, and count the number of graphs in each cluster.
+We characterize writers by the number of a writer’s graphs that are
+assigned to each cluster. We refer to this as a writer’s *cluster fill
+counts* and it serves as writer profile.
+
+We can plot the cluster fill counts for each writer in the template
+training set. First we format the template data to get the cluster fill
+counts in the proper format for the plotting function.
+
+``` r
+template_data <- format_template_data(template = template)
+plot_cluster_fill_counts(template_data, facet = TRUE)
+```
+
+![](handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-4-1.png)
+
+## STEP 3: Fit a Hierarchical Model
+
+We will use handwriting samples from each person of interest, calculate
+the cluster fill counts from each sample using the cluster template, and
+fit a hierarchical model to estimate each person of interest’s true
+cluster fill counts.
+
+Save your known handwriting samples from the persons of interest in
+`main_dir \> data \> model_docs` as PNG images. The model requires three
+handwriting samples from each person of interest. Each sample should be
+at least one paragraph in length. Name the PNG images with a consistent
+format so that all file names are the same length and the writer ID’s
+are in the same location. For example, “writer0001_doc1.png”,
+“writer0001_doc2.png”, “writer0001_doc3.png”, “writer0002_doc1.png”, and
+so on.
+
+We fit a hierarchical model with the function `fit_model`. This function
+does the following:
+
+1. Processes the model training documents in `model_docs`, decomposing
+ the handwriting into component graphs. The processed graphs are
+ saved in RDS files in `main_dir \> data \> model_graphs`.
+2. Calculates the cluster fill counts for each document by assigning
+ each graph to the nearest cluster in the cluster template and
+ counting the number of graphs assigned to each cluster. The cluster
+ assignments are saved in main_dir \> data \> model_clusters.rds
+3. Fits a hierarchical model to the cluster fill counts using the RJAGS
+ package and draws posterior samples of model parameters with the
+ coda package.
+
+In this example, we use 4000 MCMC iterations for the model. The inputs
+`writer_indices` and `doc_indices` are the starting and stopping
+characters in the model training documents file names that contains the
+writer ID and a document name.
+
+``` r
+model <- fit_model(main_dir = "path/to/main_dir",
+ model_docs = "path/to/main_dir/data/model_docs",
+ num_iters = 4000,
+ num_chains = 1,
+ num_cores = 2,
+ writer_indices = c(7, 10),
+ doc_indices = c(11, 14))
+```
+
+For this tutorial, we will use the small example model, `example_model`,
+included in handwriter. This model was trained from three documents each
+from writers 9, 30, 203, 238, and 400 from the [CSAFE handwriting
+database](https://data.csafe.iastate.edu/HandwritingDatabase/).
+
+``` r
+model <- example_model
+```
+
+We can plot the cluster fill counts for each person of interest. (NOTE:
+We had to format the template data to work with the plotting function,
+but the model data is already in the correct format.)
+
+``` r
+plot_cluster_fill_counts(formatted_data=model, facet = TRUE)
+```
+
+![](handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-7-1.png)
+
+The bars across the top of each graph show the Writer ID. Each graph has
+a line for each known handwriting sample from a given writer.
+
+### Hierarchical Model Variables and Burn-in
+
+If you are interested in the variables used by the hierarchical model,
+continue reading this section. Otherwise, feel free to skip to the next
+section to learn how to analyze questioned documents.
+
+We can list the variables in the model:
+
+``` r
+names(as.data.frame(coda::as.mcmc(model$fitted_model[[1]])))
+#> [1] "eta[1]" "eta[2]" "eta[3]" "eta[4]" "eta[5]" "gamma[1]"
+#> [7] "gamma[2]" "gamma[3]" "gamma[4]" "gamma[5]" "mu[1,1]" "mu[2,1]"
+#> [13] "mu[3,1]" "mu[1,2]" "mu[2,2]" "mu[3,2]" "mu[1,3]" "mu[2,3]"
+#> [19] "mu[3,3]" "mu[1,4]" "mu[2,4]" "mu[3,4]" "mu[1,5]" "mu[2,5]"
+#> [25] "mu[3,5]" "pi[1,1]" "pi[2,1]" "pi[3,1]" "pi[1,2]" "pi[2,2]"
+#> [31] "pi[3,2]" "pi[1,3]" "pi[2,3]" "pi[3,3]" "pi[1,4]" "pi[2,4]"
+#> [37] "pi[3,4]" "pi[1,5]" "pi[2,5]" "pi[3,5]" "tau[1,1]" "tau[2,1]"
+#> [43] "tau[3,1]" "tau[1,2]" "tau[2,2]" "tau[3,2]" "tau[1,3]" "tau[2,3]"
+#> [49] "tau[3,3]" "tau[1,4]" "tau[2,4]" "tau[3,4]" "tau[1,5]" "tau[2,5]"
+#> [55] "tau[3,5]"
+```
+
+View a description of a variable with the `about_variable` function.
+
+``` r
+about_variable(variable = "mu[1,1]", model = model)
+#> [1] "Mu is the location parameter of a wrapped-Cauchy distribution for writer ID w0009 and cluster 1"
+```
+
+View a trace plot of a variable.
+
+``` r
+plot_trace(variable = "mu[1,1]", model = model)
+```
+
+![](handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-10-1.png)
+
+If we need to, we can drop the beginning MCMC iterations for burn-in.
+For example, if we want to drop the first 25 iterations, we use
+
+``` r
+model <- drop_burnin(model, burn_in = 25)
+```
+
+If we want to save the updated model as the current model for this
+project, replace `model.rds` in the `data` folder with
+
+``` r
+saveRDS(model, file='data/model.rds')
+```
+
+## Analyze Questioned Documents
+
+Save your questioned document(s) in `main_dir > data > questioned_docs`
+as PNG images. Assign a new writer ID to the questioned documents and
+name the documents consistently. E.g. “unknown1000_doc1.png”,
+“unknown1001_doc1.png”, and so on.
+
+We estimate the posterior probability of writership for each of the
+questioned documents with the function `analyze_questioned_documents`.
+This function does the following:
+
+1. **Process Questioned Document(s):** Processes the questioned
+ documents in `questioned_docs`, decomposing the handwriting into
+ component graphs. The processed graphs are saved in RDS files in
+ `main_dir \> data \> questioned_graphs`.
+2. **Estimate the Writer Profile of the Questioned Document(s):**
+ Calculates the cluster fill counts for each questioned document by
+ assigning each graph to the nearest cluster in the cluster template
+ and counting the number of graphs assigned to each cluster. The
+ cluster assignments are saved in
+ `main_dir \> data \> questioned_clusters.rds`.
+3. **Estimate the Posterior Probability of Writership:** Uses the
+ fitted model from Step 3 to estimate the posterior probability of
+ writership for each questioned document and each person of interest.
+ The results are saved in `main_dir \> data \> analysis.rds`.
+
+``` r
+analysis <- analyze_questioned_documents(
+ main_dir = "path/to/main_dir",
+ questioned_docs = "path/to/main_dir/questioned_docs",
+ model = model,
+ writer_indices = c(8,11),
+ doc_indices = c(13,16),
+ num_cores = 2)
+```
+
+Let’s pretend that a handwriting sample from each of the 5 “persons of
+interest” is a questioned document. These documents are also from the
+[CSAFE handwriting
+database](https://data.csafe.iastate.edu/HandwritingDatabase/) and have
+already been analyzed with `example_model` and the results are included
+in handwriter as `example_analysis`.
+
+``` r
+analysis <- example_analysis
+```
+
+View the cluster fill counts for each questioned document. Intuitively,
+the model assesses which writer’s cluster fill counts look the most like
+the cluster fill counts observed in each questioned document.
+
+``` r
+plot_cluster_fill_counts(analysis, facet = TRUE)
+```
+
+![](handwriter.markdown_strict_files/figure-markdown_strict/unnamed-chunk-15-1.png)
+
+View the posterior probabilities of writership.
+
+``` r
+analysis$posterior_probabilities
+#> known_writer w0030_s03_pWOZ_r01
+#> 1 known_writer_w0009 0
+#> 2 known_writer_w0030 1
+#> 3 known_writer_w0238 0
+```
+
+### For Research Only
+
+In practice, we would not know who wrote a questioned document, but in
+research we often perform tests to evaluate models using data where we
+know the ground truth. Because in this example, we know the true writer
+of each questioned document, we can measure the accuracy of the model.
+We define accuracy as the average posterior probability assigned to the
+true writer. The accuracy of our model is
+
+``` r
+calculate_accuracy(analysis)
+#> [1] 1
+```
diff --git a/man/figures/README-unnamed-chunk-15-1.png b/man/figures/README-unnamed-chunk-15-1.png
index 7cea935b..9a014ef3 100644
Binary files a/man/figures/README-unnamed-chunk-15-1.png and b/man/figures/README-unnamed-chunk-15-1.png differ
diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png
index f57f1922..055ba447 100644
Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ
diff --git a/man/figures/README-unnamed-chunk-7-1.png b/man/figures/README-unnamed-chunk-7-1.png
index 9f5a5618..11af2f91 100644
Binary files a/man/figures/README-unnamed-chunk-7-1.png and b/man/figures/README-unnamed-chunk-7-1.png differ