Written and maintained by CASRAI Editorial Board
Published
On this page
Stylometry is the quantitative study of literary style: it counts features of how texts are written, most often how frequently common words occur, and uses statistics to compare authors, texts or periods. In research it is mainly used for authorship attribution, and the free stylo package for R is the standard route into it for people who do not want to write their own code.
This guide explains what stylometry means and how far it can be trusted, then walks through installing stylo, preparing a corpus, running an analysis, reading the plots and the Burrows Delta distance, fixing common problems and choosing a Python alternative. Everything about the tools comes from their own documentation and from two peer-reviewed or editor-reviewed method papers, listed under Sources.
What stylometry is used for in research
What does stylometry mean?
Stylometry means measuring style. The Programming Historian lesson on the method defines it as “the quantitative study of literary style through computational distant reading methods.” Instead of reading a text closely and judging its voice, the researcher turns each text into numbers, typically counts of words or character sequences, and compares those numbers across texts.
The method rests on a premise stated in the same lesson: authors tend to write consistently, and some features of their writing are produced largely without conscious choice. Function words such as articles, prepositions and conjunctions are the usual example, because they appear in every text whatever its subject. The lesson cites Stamatatos for the point that such words are used “in a largely unconscious manner” and are topic-independent, which is why they are a better fingerprint than content words like names and places.
What is stylometry used for?
The most common use is authorship attribution: given a text of unknown or disputed authorship and a set of candidate authors with known writings, decide which candidate’s habits the unknown text most resembles. The Programming Historian lesson also lists other applications, including inferring the gender of an author, detecting plagiarism, and tracing change in song lyrics over time. The stylo package’s own description on CRAN frames it as software for “computational stylistics and authorship attribution”, with both supervised and unsupervised multivariate methods.
Research offices and editors meet stylometry in two places. In the humanities it is a routine tool of digital literary studies, applied to questions such as who wrote a disputed essay. In research integrity it is sometimes proposed for questions of authorship and text reuse, which is why it overlaps with the topics covered in our guides on how AI-text detection works and on authorship. A stylometric result is a statistical comparison, not proof of who wrote a text; the reliability section below explains why.
What is the object of study of stylistics?
Stylistics is the study of style in language and literature, and stylometry is its quantitative branch. The stylo package’s authors describe the software as serving “computational stylistics”, and the Programming Historian lesson describes stylometry as the quantitative study of literary style. So the object of study is style itself: the characteristic, measurable choices a writer or a genre makes in vocabulary, word frequency and sequence of words. Stylometry restricts that object to what can be counted and compared statistically.
What are the types of stylistics?
The method literature used here does not divide the field into named branches of stylistics. It divides stylometric work by method and by task, and that division is the useful one when choosing software. In the stylo documentation the main distinction is between unsupervised analysis, where texts are grouped by similarity with no labels given (cluster analysis, principal component analysis), and supervised classification, where the software learns from texts of known class and assigns unknown texts to those classes. Two further task types are comparing word use between two subsets of a corpus, and following how style changes inside a single long text.
How to install or access stylo
stylo is an R package. It is listed on CRAN as “stylo: Stylometric Multivariate Analyses”, under the GPL (version 3 or later), with Maciej Eder as maintainer and Jan Rybicki, Mike Kestemont and Steffen Pielström as co-authors. When this page was checked on 2026-12-03, CRAN listed version 0.7.71, published 2026-06-16. Install R first from the R Project, then use one of the routes in the project README.
- From CRAN, the simplest route: run
install.packages("stylo")in R and choose a CRAN mirror when asked. - From GitHub, for the development version: run
install.packages("devtools"), thenlibrary(devtools), theninstall_github("computationalstylistics/stylo"). - From a downloaded CRAN archive: set the working directory to the folder holding the file and run
install.packages("stylo_0.7.4.tar.gz", repos = NULL, type = "source"), adjusting the file name to the version you downloaded.
The README points to a beginner slide deck (“stylo in a nutshell”), a short HOWTO in PDF form, the CRAN reference manual, and blog posts on features that are not obvious from the menus: batch mode, performance measures, authorship verification with imposters, cross-validation with the classification function, custom distances, rolling stylometry and use with languages other than English. Cite the R Journal paper by Eder, Rybicki and Kestemont (2016) when publishing results obtained with the package.
If R and its packages are new to you, our guides on installing R and using RStudio cover the setup that comes before this step.
How to run a stylometric analysis with stylo step by step
The R Journal paper describes two ways of working with the package: graphical interfaces aimed at novices, students and humanities scholars without programming experience, and a scripting interface for experienced users who want more flexibility. The steps below follow the paper’s workflow and use only commands and settings it shows.
- Collect the texts. Put each text in its own plain-text file, saved as UTF-8, in one folder. The paper loads texts from a dedicated folder.
- Name the files with class labels. The paper states the convention: any string of characters followed by an underscore becomes a class identifier, and it is case sensitive. A file called
Austen_Emma.txtgets the classAusten, andCBronte_Jane.txtgetsCBronte. Common file extensions are dropped from the labels shown on plots. Keep spellings of the author part identical across files, becauseAustenandaustenwould count as two classes. - Load and inspect the corpus (scripting route). The paper’s loading command is
load.corpus(files = "all", corpus.dir = "corpus_files", encoding = "UTF-8"), wherecorpus_filesis the folder name. - Choose the features. When loading from text files, the default features are most frequent words, that is lowercased single words. The paper also supports word or character n-grams as features. By default, a cluster analysis of the 100 most frequent features is performed.
- Run the analysis. The paper’s example call is
stylo(corpus.dir = "directory_containing_the_files", mfw.min = 200, mfw.max = 200, analysis.type = "PCR", sampling = "normal.sampling", sample.size = 10000, gui = FALSE). Heremfw.minandmfw.maxset the range of most frequent words used,analysis.type = "PCR"asks for a principal component analysis based on a correlation matrix, andgui = FALSEskips the graphical window. Leave theguiargument out and callstylo()to work through the graphical interface instead. - Save the graphics. Setting
write.png.file = TRUEwrites the plots as PNG files. Plots colour each sample by the class label taken from its file name. - Repeat with different settings. Change the number of words, the culling level and the sampling, and compare results. The paper warns that feature selection and sampling settings may interact, so culling has to be considered together with them. Its own example uses
culling.level = 80.
Which stylo function does which task
The package has one main function per kind of question, and picking the right one is the first real decision. The data table below lists them with the task each performs, as described in the R Journal paper. In short: stylo() is for exploring a corpus without labels, classify() is for assigning unknown texts to known classes, oppose() compares two subsets of a corpus, and rolling.delta() and rolling.classify() follow style across the length of a single text.
What Burrows Delta does, with a worked example
Burrows Delta is the best-known distance measure in the field; the R Journal paper calls it “the best example” of the reference distance metrics. The Programming Historian lesson spells out the calculation, which is worth understanding even if stylo performs it for you.
- Assemble a corpus of texts by candidate authors whose authorship is known, one sub-corpus per author.
- Choose n, the number of most frequent words to use.
- For each author’s sub-corpus, work out the relative frequency of each of those n words.
- Work out the mean and standard deviation of those frequencies across the sub-corpora, which the lesson calls the “mean of means”.
- Convert each author’s frequencies to z-scores: how many standard deviations each is above or below the mean.
- Do the same for the anonymous text, using the same words and the same means and standard deviations.
- Delta for each candidate is the mean of the absolute differences between the anonymous text’s z-scores and that candidate’s z-scores. The lowest Delta marks the most likely author.
The lesson applies this to Federalist Paper No. 64 with five candidate authors. The lowest Delta was John Jay’s, at 1.53. The lesson adds that the authorship of some Federalist papers remains contested, with Hamilton and Madison possibly having written together, which is exactly why a lowest-Delta result should be reported as evidence and not as a verdict.
How to read the output
With the default settings the main product is a hierarchical clustering plot: a dendrogram in which texts that are close in style are joined near the leaves. A text by an unknown author that joins a branch with one candidate’s works is evidence of stylistic similarity to that candidate. Principal component analysis plots show the same similarity as a scatterplot, with samples coloured by the class label in the file name; samples that sit together have similar profiles on the chosen words. The paper also mentions t-SNE plots and bootstrap consensus trees as further output types.
Three reading rules follow from the documentation. First, similarity is relative to the corpus you supplied: a text can only resemble the candidates you gave it, and it will appear to resemble one of them even if the true author is not among them. Second, read the plot at several word counts, not one. Third, check what is driving the grouping. The paper notes that pronouns are often removed because they can correlate with topic or genre, and it presents this as a common step, not a requirement; if clusters form by subject or text type instead of by author, the analysis is measuring the wrong thing.
Is stylometry reliable?
Stylometry is useful evidence but not reliable enough to settle authorship alone, and its own method papers say so. The R Journal paper states that replicability and benchmarking “still pose significant challenges in the field”, and describes its case studies as “dummy” examples, not validated benchmarks. The Programming Historian lesson describes choosing the number of words as a “dark art”, suggests trying figures between 100 and 1,000, and states a test: if a small change in n flips the attribution, the result is not meaningful evidence. The same lesson says Mendenhall’s characteristic curves of word length are not particularly trustworthy.
A practical reliability checklist, each item traceable to those sources:
- Run the analysis at several values of n across the 100 to 1,000 range and report whether the attribution holds.
- Vary culling and sampling settings, remembering that they interact.
- Remove or test pronouns, which can follow topic and genre.
- Include enough candidate authors and enough text of known authorship, and state that the unknown text can only be compared with the candidates supplied.
- Report the software, version and settings, so others can replicate the run.
- Treat the output as one line of evidence next to historical and documentary evidence.
For counting-based approaches to text more generally, see text mining and content analysis.
Troubleshooting stylo
- Every file ends up in one class, or classes are split unexpectedly. Check the file names. The class is whatever comes before the first underscore and it is case sensitive, so
Austen_Emma.txtandausten_Persuasion.txtare different classes. - Accented or non-English characters appear garbled. Save the text files as UTF-8 and load them with
encoding = "UTF-8", as in the paper’s loading command. - macOS: stylo reports that X11 support is needed. The README says the package requires X11 support and recommends installing XQuartz; if needed, create a symlink from
/opt/X11to/usr/X11. - macOS: R warns about a non-UTF-8 locale. The README’s fix is to run
defaults write org.R-project.R force.LANG en_US.UTF-8in Terminal and restart R. - macOS Mojave: Tcl/Tk support is not recognised. Run
xcode-select --installand accept the license agreement. - The result changes when you change a setting. That is expected behaviour, not a fault: see the reliability checklist above, and report the range of results.
Free alternatives to stylo
stylo is itself free software under the GPL. The other route documented in the sources is writing the method yourself in Python. The data below compares the two ways of working that the sources describe.
| Option | What it involves | Source |
|---|---|---|
| stylo graphical interface | Point-and-click preprocessing through results in one interface, designed for users without programming experience | Eder, Rybicki and Kestemont (2016), The R Journal |
| stylo scripting functions | R commands such as stylo(), classify() and oppose() for repeatable, batch and customised analyses |
Eder, Rybicki and Kestemont (2016), The R Journal; stylo README |
| Python with nltk and matplotlib | Implement Burrows Delta step by step in Python; the Programming Historian lesson uses Python 3.6.4, nltk and matplotlib and recommends stylo for further work | Programming Historian, Introduction to Stylometry with Python |
The Python route is the better way to learn what Delta does, because every step in the list above is explicit code. For results you intend to publish, the lesson itself points readers to stylo for more extensive work.
Frequently asked questions
What does stylometry mean?
It is the quantitative study of literary style: texts are turned into counts, usually of frequent words, and compared statistically, most often to attribute disputed texts to an author.
What is the object of study of stylistics?
Style in language and literature: the characteristic choices of vocabulary and word use that distinguish a writer, genre or period. Stylometry studies the part of it that can be counted.
Is stylometry reliable?
It gives useful but not conclusive evidence. The method papers note that replicability and benchmarking remain challenges, that the number of words is a judgement call, and that an attribution which flips when that number changes is not meaningful evidence.
What are the types of stylistics?
The stylometry documentation separates work by method rather than by branches of stylistics: unsupervised analysis (clustering, PCA), supervised classification, comparison of two corpus subsets, and rolling analysis of style within one text.
How do I install stylo?
Run install.packages("stylo") in R, or install the development version from GitHub with devtools.
Does stylo need programming skills?
No. It includes graphical interfaces for novices, and a scripting interface for people who want finer control.
Sources
- Programming Historian: Introduction to Stylometry with Python, checked 2026-12-03
- CRAN: stylo, Stylometric Multivariate Analyses, checked 2026-12-03
- GitHub: computationalstylistics/stylo README, checked 2026-12-03
- The R Journal: Stylometry with R (Eder, Rybicki and Kestemont, 2016), checked 2026-12-03
Data: stylo functions and the stylometric task each performs
Compiled from the 2016 R Journal paper by the package authors: the main stylo functions, the kind of analysis each performs and the question it answers. Used to choose a function before running an analysis.
| Function | Analysis type | Task described in the paper |
|---|---|---|
| stylo() | Unsupervised multivariate analysis | Clusters or projects texts by similarity (cluster analysis, PCA) without class labels being used to decide |
| classify() | Supervised classification | Applies machine-learning classification procedures to assign texts to known classes |
| oppose() | Contrastive comparison | Inspects differences in word usage between two subsets of a corpus |
| rolling.delta() | Rolling analysis | Studies how writing style evolves within a single text |
| rolling.classify() | Rolling analysis | Studies how writing style evolves within a single text using classification |
Sources
- Stylometry with R (Eder, Rybicki and Kestemont, The R Journal, 2016) (accessed 2026-12-03)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







