Research Question

Is there a relationship between the restrictiveness of a state’s firearm regulations/laws for individuals with domestic violence related records and homicide rates perpetrated using a firearm?

Background

Since 1996, Federal law has banned the possession of firearms for anyone convicted of a felony or a domestic violence (DV) misdemeanor, or who has a DV-related protective order against them (U.S. Department of Justice, 2020). However, states vary significantly in the number of and restrictiveness of gun laws. Some states do not even explicitly ban the purchase or possession of firearms for DV perpetrators. While federal law takes priority, the explicit statement of firearm restrictions in state laws often follows by additional provisions specifying what constitutes as an intimate partner, what types of offenses are included, how firearms should be relinquished or seized, and what the consequences are for violating provisions (Giffords Law Center, 2021).

The exact impact of gun violence varies across research, but all concur that it is a prevalent issue. Further than that, years of data indicate the substantial presence of domestic violence related matters in firearm homicides, particularly for female victims. Current research finds that nearly 50% of female homicides are perpetrated by a current or former intimate partner, and over half of those are executed using a firearm (Disarm Domestic Violence, 2022). Giffords Law Center (2021) additionally finds that 4.5 million U.S. women have reported being threatened by an intimate partner using a firearm. Also, it is important to note that due to stigma and other factors, many incidents of intimate partner violence go unreported. Additionally, the National Violent Death Reporting System, which compiles state data on violent deaths - focusing on who, where, when, and how - has just in the past few years procured funding to reach all 50 states. Therefore, there is limited available data on DV-specific homicides.

Due to an increased understanding of the prevalence of intimate partner violence (IPV) and its connection to firearms, many states have implemented legal provisions to prevent perpetrators from possessing firearms. For example, many states have closed the “boyfriend loophole” that exists in the federal legislation. This means that states have expanded the definition of an intimate partner to include dating partners, even if they do not live together, share a child, or are married (which are the specifications in federal laws) (Everytown Research & Policy, 2022). Many states have also added legislation that specifies who may petition for a DV protective order and what protective order scenarios would result in firearm prohibitions for the abuser or alleged abuser. Additional provisions pertain to specifications of firearm relinquishment and removal from those with a DV-related criminal or civil imposition (Disarm Domestic Violence, 2022).

Description of Data

Center for Disease Control (CDC) - CDC WONDER

The Centers for Disease Control and Prevention (CDC) provides CDC Wonder, which is an online database that allows for the collection and analysis of public health data. I am using the Underlying Cause of Death database, which allows the selection of Homicide as the Injury Intent and the specification of Firearm as the Injury Mechanism, and the information is determined through death certificates.

I decided to use an average across 3 years to account for any single year abnormalities. The state firearm laws are from 2018. I do not have information on how long each state has had each firearm provision enacted, so I am using homicide rates averages for 2017 through 2019. I’ve also included overall rates and then by gender. Since previous research indicates that a high number of female homicides by firearm has been perpetrated by an intimate partner, I will evaluate female homicide rates in relation to state firearm legislation. Due to the lack of data on confirmed IPH in many states, overall firearm homicides is the closest to that information.

Source: https://wonder.cdc.gov/ucd-icd10.html

# Overall Homicide Rates
HomRates <- suppressMessages(read.delim("../../DACSS 697/DV Research/Homicide_Firearm_2017through2019.txt"))
HomRates <- select(HomRates, State, Deaths, Population, Crude.Rate) %>% mutate(across(everything(), ~ifelse(.=="", NA, as.character(.)))) %>% na.omit()
HomRates <- filter(HomRates, !str_detect(State, "District of Columbia"))
HomRates$Deaths <- as.numeric(HomRates$Deaths)
HomRates$Population <- as.numeric(HomRates$Population)
HomRates$Crude.Rate <- as.numeric(HomRates$Crude.Rate)
A <- function(x) x/3
HomRates$Deaths <- sapply(HomRates$Deaths, A)
HomRates$Population <- sapply(HomRates$Population, A)
HomRates <- HomRates %>%
  mutate_at(vars(Population, Deaths), funs(round(., 0)))
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## Please use a list of either functions or lambdas: 
## 
##   # Simple named list: 
##   list(mean = mean, median = median)
## 
##   # Auto named with `tibble::lst()`: 
##   tibble::lst(mean, median)
## 
##   # Using lambdas
##   list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
# Homicide Rates by Gender
HomRatesG <- suppressMessages(read.delim("../../DACSS 697/DV Research/CDC_Gun_Hom_Gender.txt"))
HomRatesG <- select(HomRatesG, State, Gender, Deaths, Crude.Rate) %>%
  rename(States = State)
HomRatesG <- filter(HomRatesG, !str_detect(States, "District of Columbia")) 
HomRatesG$Deaths <- as.numeric(HomRatesG$Deaths)
HomRatesG$Crude.Rate <- as.numeric(HomRatesG$Crude.Rate)
## Warning: NAs introduced by coercion
A <- function(x) x/3
HomRatesG$Deaths <- sapply(HomRatesG$Deaths, A)
HomRatesG <- HomRatesG %>%
  mutate_at(vars(Deaths), funs(round(., 0)))
HomRatesG <- HomRatesG %>% 
  mutate(across(everything(), ~ifelse(.=="", NA, as.character(.)))) %>%
  filter(!str_detect(States, "NA"))
HomRatesG <- HomRatesG %>%
  pivot_wider(names_from = Gender, values_from = c(Deaths, Crude.Rate))  
# Combine overall rates and gender rates to one dataframe
CDCHomRates <- cbind.data.frame(HomRates, HomRatesG)
CDCHomRates <- select(CDCHomRates, -c(States))
CDCHomRates <- CDCHomRates[, c("State", "Crude.Rate_Female", "Crude.Rate_Male", "Crude.Rate", "Deaths_Female", "Deaths_Male", "Deaths", "Population")]
CDCHomRates <- rename_(CDCHomRates, "Crude_Total" = "Crude.Rate", "Deaths_Total" = "Deaths")
## Warning: `rename_()` was deprecated in dplyr 0.7.0.
## Please use `rename()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
# Fixing suppressed and unreliable rates
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "Maine"] <- "0.7"
CDCHomRates$Crude.Rate_Male[CDCHomRates$State == "Maine"] <- "0.9"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "Vermont"] <- "1.1"
CDCHomRates$Crude.Rate_Male[CDCHomRates$State == "Vermont"] <- "1.3"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "Wyoming"] <- "1.5"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "New Hampshire"] <- "0.8"

CDCHomRates$Deaths_Female[CDCHomRates$State == "Hawaii"] <- "3"
CDCHomRates$Deaths_Female[CDCHomRates$State == "North Dakota"] <- "2"
CDCHomRates$Deaths_Female[CDCHomRates$State == "South Dakota"] <- "1"
CDCHomRates$Deaths_Female[CDCHomRates$State == "Rhode Island"] <- "3"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "Hawaii"] <- "0.1"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "North Dakota"] <- "0.2"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "South Dakota"] <- "0.1"
CDCHomRates$Crude.Rate_Female[CDCHomRates$State == "Rhode Island"] <- "0.2"
# Present data with table
kable(CDCHomRates, col.names = c("State", "Female", "Male", "Total", "Female", "Male", "Total", "Population"), 
      align = c('c', 'c', 'c', 'c', 'c', 'c', 'c', 'c')) %>%
  add_header_above(c("", "Crude Rate (per 100,000)"=3, "Number of Deaths"=3, ""))%>%
  add_header_above(c("Homicide by Firearm (Averages 2017-2019)"=8)) %>%
    kable_styling(fixed_thead = TRUE)%>%
  scroll_box(width = "100%", height = "600px") %>%
  footnote(general = "The CDC marks rates as unreliable when death counts are fewer than 20, which applies here to Female Crude Rates for Hawaii, North Dakota, Rhode Island, and South Dakota")
Homicide by Firearm (Averages 2017-2019)
Crude Rate (per 100,000)
Number of Deaths
State Female Male Total Female Male Total Population
Alabama 3.3 17.1 10.0 82 404 487 4888601
Alaska 3.3 8.6 6.1 12 33 45 736259
Arizona 1.4 6.8 4.1 52 242 294 7155544
Arkansas 2.5 10.8 6.6 38 160 198 3011969
California 1 5.7 3.3 195 1124 1319 39535307
Colorado 1 5 3.0 28 142 171 5687151
Connecticut 0.5 3.2 1.8 9 55 64 3575379
Delaware 1.7 8.8 5.1 8 41 49 967625
Florida 1.6 7.8 4.6 172 807 979 21253821
Georgia 1.9 11 6.3 105 562 667 10522092
Hawaii 0.1 1.4 0.9 3 10 13 1421300
Idaho 1 1.9 1.4 9 17 25 1752739
Illinois 1.4 11.9 6.6 90 746 836 12738308
Indiana 1.8 9.1 5.4 62 302 363 6696972
Iowa 0.5 2.7 1.6 8 42 50 3152309
Kansas 1.5 6.7 4.1 22 98 120 2912647
Kentucky 1.8 7.8 4.7 40 172 212 4463421
Louisiana 3 19.9 11.2 72 453 524 4664368
Maine 0.7 0.9 0.8 5 6 11 1339508
Maryland 1.4 13.9 7.4 43 406 449 6046858
Massachusetts 0.3 2.7 1.5 11 90 101 6884824
Michigan 1.5 7.8 4.6 74 384 458 9981694
Minnesota 0.4 2.5 1.5 13 69 82 5609139
Mississippi 3.6 18.8 11.0 55 272 327 2982260
Missouri 3.1 15.1 9.0 97 455 552 6125804
Montana 1.5 2.6 2.0 8 14 22 1060525
Nebraska 0.9 2.4 1.6 9 23 31 1927917
Nevada 2.1 7.3 4.7 32 111 143 3037529
New Hampshire 0.8 1.2 1.0 6 8 14 1352988
New Jersey 0.6 4.5 2.5 26 198 224 8932118
New Mexico 2.5 10.2 6.3 26 105 132 2093442
New York 0.4 3 1.7 42 289 331 19615056
North Carolina 1.5 8.7 5.0 78 439 517 10381708
North Dakota 0.2 2.1 1.4 2 8 10 759177
Ohio 1.6 8.4 4.9 97 481 578 11679050
Oklahoma 2 9.2 5.6 41 179 220 3943638
Oregon 0.6 2.8 1.7 14 59 73 4183742
Pennsylvania 1.3 7.9 4.5 83 494 577 12804862
Rhode Island 0.2 1.8 1.1 3 9 12 1058772
South Carolina 2.4 13.2 7.6 63 325 388 5085737
South Dakota 0.1 2.7 1.4 1 12 13 878853
Tennessee 2.3 12.2 7.1 80 402 482 6771723
Texas 1.5 7.1 4.3 216 1017 1233 28667441
Utah 0.8 2.1 1.5 12 34 46 3156299
Vermont 1.1 1.3 1.2 3 4 7 624648
Virginia 1.4 6.7 4.0 62 279 340 8507741
Washington 1 3.5 2.2 36 132 168 7518742
West Virginia 2 5.8 3.9 19 52 70 1804612
Wisconsin 1.1 4.2 2.7 33 122 155 5810495
Wyoming 1.5 2.6 2.1 4 8 12 578604
Note: The CDC marks rates as unreliable when death counts are fewer than 20, which applies here to Female Crude Rates for Hawaii, North Dakota, Rhode Island, and South Dakota

National Violent Death Reporting System (NVDRS) - Web-Based Injury Statistics Query and Reporting System (WISQARS)

The National Violent Death Reporting System (NVDRS) is a product of the CDC and specifically the Web-based Injury Statistics Query and Reporting System (WISQARS). This database provides data specifically on confirmed homicides perpetrated by an intimate partner and using a firearm, as opposed to the CDC WONDER dataset above of firearm homicide rates. Confirmed intimate partner homicide (IPH) rates are not available for all states or years, but that will likely change as the CDC began providing NVDRS funding to all states in 2018. The system allows for states to combine law enforcement reports, medical examiner/coroner reports, and death certificates when reporting and surveilling public health matters like homicide.

For the states included in the NVDRS between 2017 and 2019, I will analyze crude rates in relation to state firearm laws.

Source: https://www.cdc.gov/injury/wisqars/nvdrs/

# Confirmed intimate partner homicides (not all states are included)
NVDRSdata <- suppressMessages(read_csv("../../DACSS 697/DV Research/NVDRSdf.csv"))

NVDRSdata <- NVDRSdata %>%
  select(State, Average_Deaths, Crude_Rate)%>%
  filter(!str_detect(`State`, "TOTAL"))

# Present data with table
kable(NVDRSdata, col.names = c("State", "Number of Deaths", "Crude Rate")) %>%
  kable_styling() %>%
  add_header_above(c("Confirmed Intimate Partner Homicides Using a Firearm (2017-2019 Averages)"=3)) %>%
  scroll_box(width = "100%", height = "600px") %>%
  footnote(general = "if NA, value has been suppressed by the CDC as a privacy constraint:",
  number = c("number of deaths count is between 0 and 9", 
    "crude rate unable to be calculated due to suppressed death count"))
Confirmed Intimate Partner Homicides Using a Firearm (2017-2019 Averages)
State Number of Deaths Crude Rate
Alaska 14 0.63
Arizona 84 0.39
California 117 0.21
Colorado 47 0.28
Connecticut 15 0.14
Delaware 10 0.34
Georgia 149 0.47
Illinois 68 0.21
Indiana 57 0.28
Iowa 12 0.13
Kansas 35 0.4
Kentucky 70 0.52
Maine 13 0.32
Maryland 33 0.18
Massachusetts 19 0.09
Michigan 109 0.36
Minnesota 22 0.13
Nevada 50 0.55
New Hampshire 10 0.25
New Jersey 27 0.1
New Mexico 39 0.62
North Carolina 135 0.43
Ohio 133 0.38
Oklahoma 88 0.74
Oregon 35 0.28
Pennsylvania 92 0.29
Rhode Island Suppressed Suppressed
South Carolina 88 0.58
Utah 12 0.13
Vermont Suppressed Suppressed
Virginia 98 0.38
Washington 59 0.27
West Virginia 37 0.68
Wisconsin 52 0.3
Note: if NA, value has been suppressed by the CDC as a privacy constraint: 1 number of deaths count is between 0 and 9 2 crude rate unable to be calculated due to suppressed death count

Disarm Domestic Violence

Disarm Domestic Violence is a website that compiles information on each state’s domestic violence related legislation. Focal points of the source are prohibition, specification of the victim-perpetrator relationship, protective orders, judicial authority, and the firearm removal process.

Source: https://www.disarmdv.org/#

# Read in the data using web-scraping

URL <- "https://www.disarmdv.org/state/"

State <- c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming')

URLS <- URL

# loop through each state-specific URL 
for (i in 1:length(State)){
  URLS <- c(URLS, paste("https://www.disarmdv.org/state/", State[i], sep = ""))
}
StateURL <- paste(URLS, "/?sec=law", sep="")
StateURL <- StateURL[2:51]
disarmdv <- c()
css_selector <- ".auto-navigation-content"

for (i in 1:length(StateURL)){
  
  laws <- StateURL[i] %>% 
  read_html() %>%
  html_nodes(css = css_selector) %>%
  html_text()

  
  disarmdv <- c(disarmdv, laws)
}

Pre-processing and Representing Texts

# create data frame from web-scraped data

disarmData <- as.data.frame(disarmdv)
disarmData$State <- c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming')
disarmData <- disarmData[, c("State", "disarmdv")]
disarmData <- rename_(disarmData, "Text" = "disarmdv")

# give preview of how text scraped in from website for 1st state - Alabama
kable(head(disarmData, 1)) %>% kable_styling()
State Text
alabama Alabama Law ALABAMA DOMESTIC VIOLENCE FIREARM PROHIBITIONS Alabama Domestic Violence Firearm Purchase and Possession Prohibitions Alabama prohibits the following individuals from owning a firearm, possessing a firearm, or having a firearm in their control: Persons convicted of a misdemeanor offense of domestic violence; and Persons subject to a valid protection order for domestic abuse.1 “Valid protection order” is defined as “an order issued after a hearing of which the person received actual notice, and at which the person had an opportunity to participate, that does any of the following: Restrains the person from harassing, stalking, or threatening a  qualified individual* or child of the qualified individual or person or engaging in other conduct that would place a qualified individual in reasonable fear of bodily injury to the individual or child and that includes a finding that the person represents a credible threat to the physical safety of the qualified individual or child. By its terms, explicitly prohibits the use, attempted use, or threatened use of physical force against the qualified individual or child that would reasonably be expected to cause bodily injury.”2 ALABAMA CIVIL PROTECTION ORDER FIREARM REMOVAL Domestic Violence Civil Protection Orders That Require Firearm Removal Alabama law does not require the removal of firearms from persons subject to domestic violence protection orders. Alabama law does allow a judge issuing an ex parte protection order, an ex parte modification of a protection order, a final protection order, or a modification of a protection order issued after notice and hearing to “[o]rder other relief as it deems necessary to provide for the safety and welfare of the plaintiff or any children and any person designated by the court.”3 Individuals Who May Petition for a Protection Order The following persons may petition for a protection order: A spouse (including a common law spouse); A former spouse (including a common law former spouse); A person with whom the defendant has a child in common, regardless of whether the victim or defendant have ever been married and regardless of whether they are currently residing or have in the past resided together in the same household; A person who has or had a dating relationship with the defendant; A person who is or was cohabiting with the defendant and who is in, or was engaged in, a romantic or sexual relationship with the defendant; A relative of a person defined in (e) who also lived with the defendant; or An individual who is a parent, stepparent, child, or stepchild and who is in or has maintained a living arrangement with the defendant.4 Penalties for Violation A violation of a protective order is a Class A misdemeanor.5
# Create corpus and set document names 

laws_corpus <- corpus(disarmData$Text)
docnames(laws_corpus) <- c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming')

summary(laws_corpus)
## Corpus consisting of 50 documents, showing 50 documents:
## 
##            Text Types Tokens Sentences
##         alabama   207    498         5
##          alaska   186    481         8
##         arizona   191    503         7
##        arkansas   138    232         5
##      california   495   1735        22
##        colorado   263   1016         5
##     connecticut   320   1281         3
##        delaware   435   1533        14
##         florida   276    797         8
##         georgia   126    225         4
##          hawaii   241    625         5
##           idaho   155    332         5
##        illinois   380   1378         8
##         indiana   184    472         6
##            iowa   235    670         6
##          kansas   188    408         3
##        kentucky   251    620         7
##       louisiana   482   2087        22
##           maine   390   1423         6
##        maryland   259    991        11
##   massachusetts   359   1329         7
##        michigan   266    708         7
##       minnesota   440   1706         4
##     mississippi   185    397         3
##        missouri   160    329         5
##         montana   196    528         5
##        nebraska   171    359         3
##          nevada   254    972         5
##   new-hampshire   377   1348        27
##      new-jersey   270   1170        12
##      new-mexico   380   1325        14
##        new-york   444   1746        10
##  north-carolina   416   1637        24
##    north-dakota   265    643         4
##            ohio   298    853         9
##        oklahoma   265    782         8
##          oregon   246    684         5
##    pennsylvania   629   3547        65
##    rhode-island   392   1509         8
##  south-carolina   176    470         2
##    south-dakota   219    610         6
##       tennessee   261    761         3
##           texas   233    660         4
##            utah   254    834         4
##         vermont   376   1223         9
##        virginia   278    880         7
##      washington   506   2380        16
##   west-virginia   340   1324        11
##       wisconsin   452   2125        15
##         wyoming   179    396         6
# Create document feature matrix cleaned up for 
# wordcloud to show top features across corpus
dfm_wordcloud <- tokens(laws_corpus, 
                      remove_punct= TRUE,
                      remove_numbers = TRUE,
                      remove_symbols = TRUE) %>%
  tokens_tolower() %>%
  tokens_select(pattern=stopwords("en"),
                selection="remove") %>%
  dfm() 

textplot_wordcloud(dfm_wordcloud, max_words = 50)

After removing punctuation, English stopwords, symbols, and numbers, and making all characters lowercase, we can see that order, firearms, violence, domestic, protection, etc. are common words in the document-feature-matrix. With those preprocessing parameters, lets look at a table with top features.

# Display the 20 top features from the document-feature-matrix
kable(textstat_frequency(dfm_wordcloud, n=30)) %>% kable_styling()
feature frequency rank docfreq group
order 1007 1 50 all
firearm 596 2 50 all
firearms 564 3 50 all
domestic 503 4 50 all
violence 452 5 50 all
protection 433 6 36 all
court 403 7 50 all
person 364 8 45 all
may 346 9 50 all
respondent 326 10 31 all
protective 322 11 23 all
shall 311 12 35 all
law 309 13 50 all
persons 302 14 50 all
ammunition 288 15 39 all
abuse 263 16 28 all
possession 255 17 50 all
party 206 18 19 all
defendant 194 19 17 all
subject 181 20 48 all
removal 174 21 50 all
family 162 22 36 all
child 155 23 47 all
enforcement 152 24 26 all
surrender 145 25 25 all
weapons 145 25 17 all
possessing 143 27 39 all
household 142 28 39 all
orders 141 29 48 all
member 131 30 35 all

Some words appear in all 50 documents. This information may come in handy downstream when performing structural topic modeling if the prevalence of these words disrupts the creation of coherent but unique topics.

# Create document-feature-matrix with no pre-processing of tokens
# just to see how that would look
tokens1 <- tokens(laws_corpus)

# Create document-feature matrix 
dfm_basic <- dfm(tokens1)
head(dfm_basic)
## Document-feature matrix of: 6 documents, 2,253 features (90.47% sparse) and 0 docvars.
##             features
## docs         alabama law domestic violence firearm prohibitions purchase and
##   alabama          7   5        6        5       7            2        1  10
##   alaska           0   4       11       11       8            2        2   8
##   arizona          0   3        7        7      10            2        1   4
##   arkansas         0   2        4        4       4            2        1   1
##   california       0  19       10       12      42            2        2  18
##   colorado         0   9        6        6      18            2        1   7
##             features
## docs         possession prohibits
##   alabama             1         2
##   alaska              4         0
##   arizona             1         2
##   arkansas            1         0
##   california          8         1
##   colorado            9         1
## [ reached max_nfeat ... 2,243 more features ]
# Feature Co-Occurrence Matrix for unprocessed DFM
fcm_basic <- fcm(dfm_basic)
# Pull top features
fcm_basic_feats <- names(topfeatures(fcm_basic, 30))
# Retain top features in fcm
fcm_basic2 <- fcm_select(fcm_basic, pattern = fcm_basic_feats, selection = "keep")
# compute size weight for vertices in network and create plot
size_basicfcm <- log(colSums(fcm_basic2))
textplot_network(fcm_basic2, vertex_size = size_basicfcm / max(size_basicfcm) * 3)

Pre-processing for Structural Topic Modeling

Based on some previous attempts to fit STM models with this text dataset, I know that I have a decent amount of pre-processing to preform. I’ll start with that.

Based on reviewing the website (data source), context is KEY. Each state (thus each document in the corpus) includes the topics that this study is focusing on, like “prohibit” “possession” “removal” in terms of firearms. However, some documents say “do not prohibit” or “may prohibit” etc., so failing to effectively pre-process the DFM will lead to difficulties fitting a topic model.

With that in mind, first I’ll use n-grams to look at the context surrounding some important words.

# Create ngram with 7 consecutive words
d <- tibble(disarmData)
ngram <- d %>%
 unnest_tokens(ngram, Text, token = "ngrams", n = 7)
# Separate ngrams to each word to allow for identifying key word
ngrams_separated <- ngram %>%
  separate(ngram, c("word1", "word2", "word3", "word4", "word5", "word6", "word7"), sep = " ")
# Preview ngrams for Alabama (doc1)
head(ngram$ngram)
## [1] "alabama law alabama domestic violence firearm prohibitions"      
## [2] "law alabama domestic violence firearm prohibitions alabama"      
## [3] "alabama domestic violence firearm prohibitions alabama domestic" 
## [4] "domestic violence firearm prohibitions alabama domestic violence"
## [5] "violence firearm prohibitions alabama domestic violence firearm" 
## [6] "firearm prohibitions alabama domestic violence firearm purchase"
# Context for "prohibit"
# Using middle word of ngram (word4) to see words preceding 
# and following key word
ngrams_separated %>%
  filter(word4 == "prohibit") %>%
  count(word1, word2, word3, word4, word5, word6, word7, sort = TRUE) %>% kable() %>% kable_styling() %>% scroll_box(width = "100%", height = "400px")
word1 word2 word3 word4 word5 word6 word7 n
other dangerous weapons prohibit the party from 4
under washington law prohibit the party from 4
carolina does not prohibit purchase and possession 2
kentucky does not prohibit purchase or possession 2
mississippi does not prohibit purchase and possession 2
missouri does not prohibit purchase and possession 2
oklahoma does not prohibit purchase or possession 2
protective order may prohibit the respondent from 2
wyoming does not prohibit purchase or possession 2
1 arizona may prohibit the subject of 1
2 arizona may prohibit the subject of 1
2 nevada may prohibit the adverse party 1
against stalking may prohibit purchase and possession 1
alaska does not prohibit firearm purchase and 1
arkansas does not prohibit the following persons 1
dakota does not prohibit persons subject to 1
dakota does not prohibit purchase and possession 1
dakota does not prohibit purchase or possession 1
does not broadly prohibit purchase and possession 1
does not broadly prohibit the purchase and 1
does not explicitly prohibit purchase and possession 1
does not explicitly prohibit the adverse party 1
does not explicitly prohibit the subject of 1
does not specifically prohibit the defendant from 1
firearm maryland may prohibit the subject of 1
florida does not prohibit persons convicted of 1
georgia does not prohibit persons convicted of 1
georgia does not prohibit persons subject to 1
hampshire does not prohibit persons convicted of 1
idaho does not prohibit persons convicted of 1
idaho does not prohibit persons subject to 1
law does not prohibit persons subject to 1
maryland does not prohibit the subject of 1
may direct or prohibit any other actions 1
michigan does not prohibit purchase and possession 1
of protection may prohibit a respondent from 1
of protection may prohibit the respondent from 1
ohio does not prohibit purchase and possession 1
or facsimile may prohibit the defendant from 1
order may not prohibit the respondent from 1
order shall also prohibit the respondent from 1
other disqualifications that prohibit the restrained person 1
prohibitions alaska may prohibit the person subject 1
protection order may prohibit the respondent from 1
such injunctions shall prohibit the violent parent 1
the court may prohibit an individual convicted 1
the court may prohibit the person from 1
the court to prohibit the defendant from 1
virginia does not prohibit purchase or possession 1
wisconsin does not prohibit purchase or possession 1

Based on this table, tokens I will create are: * “does not prohibit” * “may prohibit” * “shall prohibit” * “not broadly prohibit” * “not explicitly prohibit” * “not specifically prohibit”

# Context for "removal"
ngrams_separated %>%
  filter(word4 == "removal") %>%
  count(word1, word2, word3, word4, word5, word6, word7, sort = TRUE) %>% kable() %>% kable_styling() %>% scroll_box(width = "100%", height = "400px")
word1 word2 word3 word4 word5 word6 word7 n
does not require removal of firearms or 10
protective order firearm removal civil domestic violence 7
does not require removal of firearms and 6
protective order firearm removal domestic violence civil 6
of protection firearm removal domestic violence civil 5
protection order firearm removal domestic violence civil 5
not require the removal of firearms from 4
of protection firearm removal civil domestic violence 4
orders that require removal a court issuing 3
abuse order firearm removal civil protection from 2
abuse order firearm removal protection from abuse 2
does not require removal of firearms from 2
not require the removal of firearms or 2
orders that require removal a judge issuing 2
orders that require removal upon the issuance 2
protection order firearm removal civil domestic violence 2
that require firearm removal if a court 2
the relationship 10 removal process if the 2
19 exemption from removal requirement the court 1
24 exemption from removal requirement if the 1
8 exemption from removal requirement the prohibition 1
a g 5 removal process as noted 1
abuse injunction firearm removal civil domestic abuse 1
abuse that require removal a court issuing 1
abuse victim 6 removal process an order 1
abusing person 4 removal process if the 1
allow for the removal of firearms from 1
and grandchildren 12 removal process a court 1
bodily injury 7 removal process the subject 1
court order 11 removal process if the 1
court order firearm removal civil orders that 1
dating relationship 10 removal process a judge 1
dating relationship 12 removal process a person 1
dating relationship 7 removal process upon service 1
days of the removal of firearms from 1
domestic abuse firearm removal orders for protection 1
domestic violence firearm removal civil orders for 1
exemption from the removal requirement law enforcement 1
exemption from the removal requirement the prohibition 1
for protection firearm removal domestic violence civil 1
for protection firearm removal dv civil injunctions 1
for protection from removal of firearms or 1
former cohabitant 8 removal process a court 1
have dated 8 removal process a respondent 1
injunctions that require removal a person subject 1
injunctions that require removal florida law does 1
intimate relationship 7 removal process if the 1
judgment require the removal of firearms 4 1
lived together 11 removal process where a 1
may order the removal of firearms or 1
may require such removal when issuing a 1
mentally incapacitated 9 removal process if the 1
minor child 7 removal process as noted 1
not explicitly require removal of firearms and 1
of protection firearm removal civil domestic abuse 1
or cyberstalking 8 removal process a judge 1
order shall require removal of any and 1
orders that require removal a court that 1
orders that require removal a person suffering 1
orders that require removal any court when 1
orders that require removal colorado requires a 1
orders that require removal connecticut requires removal 1
orders that require removal delaware law does 1
orders that require removal georgia does not 1
orders that require removal hawaii requires removal 1
orders that require removal idaho does not 1
orders that require removal kansas does not 1
orders that require removal kentucky does not 1
orders that require removal michigan does not 1
orders that require removal mississippi does not 1
orders that require removal nebraska does not 1
orders that require removal ohio does not 1
orders that require removal oklahoma does not 1
orders that require removal oregon does not 1
orders that require removal texas law does 1
orders that require removal the respondent to 1
orders that require removal utah law does 1
orders that require removal vermont does not 1
persons listed above removal process hawaii law 1
prevention order firearm removal vermont abuse prevention 1
professional capacity 5 removal process a court 1
protection order firearm removal civil domestic abuse 1
protection order firearm removal civil personal protection 1
protection order firearm removal domestic abuse protection 1
protection that require removal a court issuing 1
protection that require removal if a court 1
protection that require removal if the court 1
protection that require removal indiana does not 1
protection that require removal missouri does not 1
protection that require removal montana does not 1
protection that require removal south carolina does 1
protection that require removal the respondent to 1
protection that require removal wyoming law does 1
protective order 7 removal process upon issuance 1
protective order firearm removal civil domestic abuse 1
protective order firearm removal domestic abuse and 1
protective orders firearm removal civil domestic violence 1
removal connecticut requires removal of firearms from 1
removal hawaii requires removal of any firearm 1
restraining order firearm removal civil family abuse 1
restraining order firearm removal domestic violence civil 1
sexual partners 11 removal process if the 1
sexual relationship 11 removal process a court 1
sexual relationship 5 removal process a defendant 1
sexually consummated 7 removal process a judge 1
shall order the removal of any firearms 1
shall require the removal of firearms or 1
social contexts 6 removal process a judge 1
that includes a removal requirement may require 1
that require firearm removal alabama law does 1
that require firearm removal alaska law does 1
that require firearm removal any protective order 1
that require firearm removal arkansas does not 1
that require firearm removal if the petition 1
that require firearm removal nevada does not 1
that require firearm removal north dakota law 1
that require firearm removal south dakota does 1
the offender 12 removal process upon the 1
the petition 9 removal process a respondent 1
this paragraph 3 removal process a court 1
to include firearm removal only for the 1
to order the removal of firearms or 1
unit exemption from removal requirement florida does 1
violence order firearm removal civil family violence 1

Based on this table, tokens I will create are: * “not require the removal” * “require firearm removal” * “does not require removal” * “that require removal” * “removal process” * “exemption from removal requirement” * “requires removal”

# Context for "order"
ngrams_separated %>%
  filter(word4 == "order") %>%
  count(word1, word2, word3, word4, word5, word6, word7, sort = TRUE) %>% kable() %>% kable_styling() %>% scroll_box(width = "100%", height = "400px")
word1 word2 word3 word4 word5 word6 word7 n
domestic violence protective order firearm removal civil 6
family violence protective order an injunction against 6
for a protective order the following persons 6
domestic abuse protective order or domestic assault 5
the court shall order the respondent to 5
violation of an order of protection is 5
while the protective order is in effect 5
by the respondent order the respondent ineligible 4
domestic violence protection order firearm removal domestic 4
firearm license and order the immediate surrender 4
obey a temporary order of protection or 4
petition for an order of protection the 4
a civil protection order that qualifies as 3
a domestic violence order for protection after 3
benefit the protective order is in effect 3
domestic violence protective order firearm removal domestic 3
domestic violence protective order from possessing any 3
firearm while the order is in effect 3
for a protection order the following persons 3
issuing a civil order of protection interim 3
issuing a temporary order of protection or 3
may hold and order the defendant to 3
of protection interim order of protection or 3
petition for an order of protection a 3
protection from abuse order was issued the 3
qualifies as an order pursuant to 18 3
to a protective order in cases of 3
a domestic violence order of protection may 2
a domestic violence order or emergency protective 2
abuse order may order the respondent to 2
an emergency protective order preliminary protective order 2
an ex parte order from contacting threatening 2
an ex parte order of protection or 2
civil domestic violence order of protection firearm 2
control while the order is in effect 2
court shall also order the respondent to 2
domestic abuse protection order shall order the 2
domestic violence protection order firearm removal civil 2
domestic violence protective order from possessing firearms 2
domestic violence protective order including an order 2
domestic violence protective order may direct the 2
domestic violence protective order or evidence obtained 2
domestic violence protective order provides information regarding 2
domestic violence protective order the court shall 2
domestic violence protective order the judge shall 2
domestic violence protective order under 18 u.s.c 2
domestic violence protective order where the violation 2
domestic violence protective order which does not 2
domestic violence restraining order may order the 2
domestic violence restraining order shall require the 2
duration of the order i f the 2
duration of the order if the order 2
duration of the order the court shall 2
final personal protection order against stalking may 2
firearm while the order of protection is 2
for a protective order to protect the 2
issuing a final order of protection determines 2
issuing an extended order for protection against 2
knows of the order is a class 2
of a protective order has a firearm 2
of a protective order or final disposition 2
of an extended order for protection against 2
of protection or order of protection shall 2
of the restraining order or protective order 2
officer serving the order must determine if 2
or ammunition shall order that such firearm 2
or child protective order including an ex 2
order including an order issued by telephone 2
order or protective order or the issuance 2
order preliminary protective order or protective order 2
petition for an order for protection against 2
petition for an order for protection family 2
protection from abuse order a plain language 2
protection from abuse order and the penalty 2
protection from abuse order firearm removal civil 2
protection from abuse order firearm removal protection 2
protection from abuse order is a class 2
protection from abuse order issued pursuant to 2
protection from abuse order may direct the 2
protection from abuse order may order the 2
protection from abuse order the following persons 2
protection or an order of protection the 2
protection or final order of protection may 2
protection or plenary order of protection prohibits 2
rescinds the restraining order or protective order 2
restraining or protective order issued by a 2
specified in the order and any and 2
subject of the order a current or 2
subject of the order to be in 2
the court shall order that the firearm 2
the court shall order the restrained party 2
the emergency protective order that the respondent 2
the judge shall order the transfer of 2
to a court order including an ex 2
to a temporary order of protection or 2
violation of an order is a class 2
violation of an order of protection and 2
violation of an order of protection or 2
whose protection the order of protection was 2
1 valid protection order is defined as 1
12 if the order prohibits the defendant 1
13 if the order includes a requirement 1
2 washington court order firearm removal civil 1
3 arizona civil order of protection firearm 1
3 civil protective order firearm removal domestic 1
6 minnesota civil order for protection in 1
6320 ex parte order enjoining contact credibly 1
6321 ex parte order excluding party from 1
6322 ex parte order enjoining specified behavior 1
8 the protective order shall also prohibit 1
a child protective order on behalf of 1
a civil emergency order of protection may 1
a civil protection order may grant such 1
a civil protection order the court is 1
a civil protection order to refrain from 1
a court to order such temporary relief 1
a domestic abuse order of protection issued 1
a domestic abuse order of protection shall 1
a domestic violence order for protection is 1
a domestic violence order may direct or 1
a domestic violence order of protection 2 1
a domestic violence order of protection a 1
a domestic violence order of protection any 1
a domestic violence order of protection issued 1
a domestic violence order of protection shall 1
a domestic violence order of protection spouses 1
a fapa restraining order 7 abuse is 1
a fapa restraining order a true copy 1
a final protection order or a modification 1
a final protective order and if they 1
a final protective order for family violence 1
a final protective order if their final 1
a final protective order may impose any 1
a final protective order spouses or reciprocal 1
a hearing may order a respondent to 1
a hearing may order the disposition of 1
a judge may order a respondent to 1
a personal protection order or foreign protection 1
a personal protection order spouses former spouses 1
a personal protection order the following persons 1
a preliminary protective order in cases of 1
a prior protective order 7 removal process 1
a substantially similar order issued by a 1
a temporary protection order that includes but 1
a temporary protective order if they are 1
a temporary restraining order or a final 1
a valid protection order for domestic abuse 1
abuse order must order the defendant to 1
abuse order to order or restrain any 1
abuse order which order provides for the 1
abuse temporary restraining order is not required 1
accordance with the order 12 if the 1
against whom an order of protection was 1
alabama civil protection order firearm removal domestic 1
also issue an order prohibiting the defendant 1
an abuse prevention order any family or 1
an abuse prevention order from purchasing or 1
an abuse prevention order is a crime 1
an abuse prevention order may relinquish to 1
an abuse prevention order on behalf of 1
an abuse prevention order or any other 1
an abuse prevention order shall make such 1
an abuse prevention order shall not return 1
an abuse prevention order to surrender their 1
an emergency protective order or a domestic 1
an emergency protective order or domestic violence 1
an emergency protective order or preliminary protective 1
an ex parte order 2 a court 1
an ex parte order for protection may 1
an ex parte order shall if requested 1
and hearing may order firearms and ammunition 1
and hearing may order o ther relief 1
and shall further order a person restrained 1
and shall further order the defendant not 1
and the protective order is no longer 1
any firearm or order the surrender of 1
any prior protective order or any violation 1
any successive protective order is in effect 1
as the protective order is in effect 1
as the protective order or any successive 1
at which the order was issued the 1
authorize courts to order the removal of 1
b if the order requires relinquishment of 1
bail was ordered order the respondent to 1
before enforcing the order 19 a knowing 1
before receiving an order from the court 1
blood or court order as a parent 1
by a protective order and not later 1
by a protective order the subject of 1
by the court order sell or transfer 1
by the court order surrender any firearm 1
by the petitioner order o ther relief 1
by the protective order regardless of whether 1
by the protective order the offender shall 1
carolina domestic abuse order of protection firearm 1
carrying a protective order requiring the surrender 1
cause and the order to appear on 1
civil abuse prevention order firearm removal vermont 1
civil domestic violence order for protection firearm 1
civil family violence order firearm removal civil 1
civil harassment restraining order workplace violence restraining 1
complaint requesting any order which will protect 1
comply with the order before enforcing the 1
consent agreement may order the defendant to 1
contact order antiharassment order domestic violence order 1
contempt or an order for money sanctions 1
content of the order 8 return of 1
contents of the order 17 a violation 1
control and further order ing a person 1
copy of the order and firearm information 1
copy of the order and proof of 1
copy of the order the first violation 1
copy of the order to transfer firearms 1
county where the order was entered 23 1
county where the order was entered in 1
court by separate order shall provide for 1
court for an order of disposition the 1
court issues an order directing that the 1
court issuing an order for protection in 1
court issuing an order of protection may 1
court issuing an order of protection shall 1
court issuing an order that includes a 1
court issuing an order to an abusive 1
court issuing the order of protection shall 1
court may also order temporary surrender of 1
court seeking an order for the return 1
court shall also order the restrained party 1
criminal and protective order history prior to 1
criminal no contact order antiharassment order domestic 1
dating violence protective order if the person 1
dating violence protective order may not prohibit 1
dating violence protective order or child protective 1
defendant 30 such order shall include the 1
defendant if the order prohibits the defendant 1
defendant while an order is in effect 1
defined as an order issued after a 1
designated in the order a written statement 1
directed by court order and provide the 1
domestic abuse protection order 13 upon revocation 1
domestic abuse protection order 8 abuse is 1
domestic abuse protection order a person suffering 1
domestic abuse protection order a temporary domestic 1
domestic abuse protection order firearm removal civil 1
domestic abuse protection order firearm removal domestic 1
domestic abuse protection order for themselves alleging 1
domestic abuse protection order is a misdemeanor 1
domestic abuse protection order may be held 1
domestic abuse protection order may not be 1
domestic abuse protection order may provide relief 1
domestic abuse protection order on behalf of 1
domestic abuse protection order or final domestic 1
domestic abuse protection order shall be returned 1
domestic abuse protection order that requires surrender 1
domestic abuse protection order the court shall 1
domestic abuse protective order 4 a minor 1
domestic abuse protective order 5 domestic abuse 1
domestic abuse protective order a person or 1
domestic abuse protective order a victim of 1
domestic abuse protective order firearm removal civil 1
domestic abuse protective order or a domestic 1
domestic assault protective order 7 domestic abuse 1
domestic assault protective order a person suffering 1
domestic assault protective order domestic abuse protective 1
domestic assault protective order firearm removal domestic 1
domestic assault protective order may order the 1
domestic assault protective order of which the 1
domestic assault protective order shall be returned 1
domestic assault protective order shall not apply 1
domestic assault protective order shall subject the 1
domestic assault protective order the court may 1
domestic violence may order such other relief 1
domestic violence protection order 3 family or 1
domestic violence protection order 5 domestic violence 1
domestic violence protection order a spouse or 1
domestic violence protection order any family or 1
domestic violence protection order any person who 1
domestic violence protection order forms contain a 1
domestic violence protection order forms note that 1
domestic violence protection order harassment protection order 1
domestic violence protection order has been granted 1
domestic violence protection order if the respondent 1
domestic violence protection order issued after notice 1
domestic violence protection order may grant relief 1
domestic violence protection order may o rder 1
domestic violence protection order may order other 1
domestic violence protection order may order such 1
domestic violence protection order may prohibit the 1
domestic violence protection order may require the 1
domestic violence protection order or an ex 1
domestic violence protection order spouses former spouses 1
domestic violence protection order the following persons 1
domestic violence protective order 18 the third 1
domestic violence protective order 4 abuse is 1
domestic violence protective order after notice and 1
domestic violence protective order an adult alleging 1
domestic violence protective order and the court 1
domestic violence protective order civil protective order 1
domestic violence protective order family or household 1
domestic violence protective order family violence is 1
domestic violence protective order for which firearm 1
domestic violence protective order for which the 1
domestic violence protective order from purchasing receiving 1
domestic violence protective order if the court 1
domestic violence protective order is a misdemeanor 1
domestic violence protective order is issued against 1
domestic violence protective order is issued at 1
domestic violence protective order issued by another 1
domestic violence protective order louisiana domestic violence 1
domestic violence protective order may also result 1
domestic violence protective order may be incarcerated 1
domestic violence protective order may prohibit the 1
domestic violence protective order may result in 1
domestic violence protective order may transport a 1
domestic violence protective order on behalf of 1
domestic violence protective order peace officers shall 1
domestic violence protective order penalties for violation 1
domestic violence protective order persons eligible for 1
domestic violence protective order persons who have 1
domestic violence protective order prohibits the respondent 1
domestic violence protective order shall direct the 1
domestic violence protective order shall order the 1
domestic violence protective order shall require removal 1
domestic violence protective order that qualifies for 1
domestic violence protective order the court may 1
domestic violence protective order to surrender firearms 1
domestic violence protective order whether issued ex 1
domestic violence restraining order 9 victim of 1
domestic violence restraining order a victim of 1
domestic violence restraining order and protective order 1
domestic violence restraining order firearm removal domestic 1
domestic violence restraining order may also issue 1
domestic violence restraining order may forbid the 1
domestic violence restraining order or protective order 1
domestic violence restraining order prohibiting the person 1
domestic violence restraining order requires the surrender 1
domestic violence restraining order shall not apply 1
domestic violence7 protective order any parent adult 1
domestic violence8 protective order spouses or former 1
duration of the order 1 a court 1
duration of the order 10 if there 1
duration of the order 12 within 24 1
duration of the order 13 if the 1
duration of the order 14 return of 1
duration of the order 2 new hampshire 1
duration of the order 5 if the 1
duration of the order 8 if there 1
duration of the order and order the 1
duration of the order and orders the 1
duration of the order and relinquish for 1
duration of the order any firearm or 1
duration of the order for protection unless 1
duration of the order if the defendant 1
duration of the order if the demonstrates 1
duration of the order if the respondent 1
duration of the order issue an order 1
duration of the order of protection unless 1
duration of the order or are otherwise 1
duration of the order or two years 1
duration of the order or until otherwise 1
emergency ex parte order that it finds 1
end of the order the firearm s 1
entry of the order a party ordered 1
entry of the order granting return of 1
espondent with this order as follows 4 1
even if the order does not specifically 1
ex parte protection order an ex parte 1
ex parte protective order or child protective 1
ex parte protective order or ex parte 1
ex parte protective order or protective order 1
existence of the order a violation of 1
expiration of an order the local law 1
expiration of the order or dismissal of 1
expiration of the order the court shall 1
expiration of the order the court should 1
extend the protective order the court shall 1
family abuse may order a ny other 1
family violence may order the person found 1
family violence protective order all separation divorce 1
family violence protective order injunction against abuse 1
family violence protective order may be punished 1
family violence protective order past or present 1
filed and an order issued by a 1
final abuse prevention order and attempts to 1
final domestic violence order of protection 8 1
final domestic violence order of protection may 1
final domestic violence order of protection prohibits 1
final domestic violence order of protection who 1
finds that the order has ended no 1
firearm 3 nevada order for protection against 1
firearms 4 an order issued pursuant to 1
firearms and an order to relinquish firearms 1
firearms if the order was issued after 1
fixed in the order 1 additionally if 1
for a protection order a person who 1
for a protection order a spouse including 1
for a protection order spouses former spouses 1
for a protective order a household member 1
for a protective order a victim of 1
for a protective order and use the 1
for a protective order any cohabitant who 1
for a protective order household member includes 1
for a protective order on behalf of 1
for a protective order protective orders in 1
for a protective order spouses former spouses 1
for a protective order to protect a 1
for a restraining order any person who 1
from seeking an order of protection 3 1
g 8 shall order the subject of 1
g 8 to order the subject of 1
grant a protective order 5 domestic violence 1
grant any protective order to bring about 1
has issued an order that rescinds the 1
has violated the order 6 within 24 1
has violated the order of protection may 1
have jurisdiction to order the return of 1
hearing on the order of protection the 1
hearing while the order remains in effect 1
hours of the order to surrender firearms 1
ii includes an order requiring the person 1
in a protective order issued against a 1
in issuing an order to show cause 1
in the court’s order for the duration 1
in the protective order that the court 1
in which the order was issued within 1
injunction or protective order if the injunction 1
injunction or protective order includes a a 1
injunction or protective order informs the subject 1
injunction or protective order post separation family 1
injunction or protective order represents a credible 1
injunction or protective order that the person 1
is violating the order and the injunction 1
issuance of the order of protection involved 1
issuance of the order of protection the 1
issuance of the order that the respondent 1
issuance of the order to transfer all 1
issued the protective order and a copy 1
issuing a final order for protection in 1
issuing a protective order dating violence protective 1
issuing a protective order for a victim 1
issuing a protective order may i nclude 1
issuing a protective order may order a 1
issuing a protective order or child protective 1
issuing a temporary order for protection against 1
issuing a temporary order of protection shall 1
jurisdiction including an order described in 18 1
knowingly violate such order 2 a court 1
knowingly violates an order of protection shall 1
law or court order precluding the ownership 1
law or court order that precludes the 1
license if the order is no longer 1
licensee while the order of protection is 1
long as the order is in effect 1
long as the order of protection or 1
magistrate issuing an order for emergency protection 1
make a new order of protection order 1
may continue the order of surrender and 1
may include an order not to possess 1
may limit the order to exclude that 1
mexico domestic violence order of protection firearm 1
michigan personal protection order firearm removal civil 1
missouri domestic violence order of protection firearm 1
modify an existing order to add reasonable 1
montana domestic violence order of protection firearm 1
named in the order 16 it is 1
named in the order shall be guilty 1
named in the order shall upon conviction 1
not obtain an order of protection against 1
notice of the order 5 in a 1
notice of the order a violation of 1
notice of the order sell and transfer 1
notice of the order shall be guilty 1
notice of the order shall constitute contempt 1
obey a prior order of protection and 1
of a court order or failure to 1
of a court order rescinding the restraining 1
of a court order that rescinds the 1
of a protection order 19 a violation 1
of a protection order a final protection 1
of a protection order is a class 1
of a protection order issued after notice 1
of a protection order or consent agreement 1
of a protection order or no contact 1
of a protection order shall be a 1
of a protection order which is a 1
of a protective order and disorderly conduct 1
of a protective order and who are 1
of a protective order does not file 1
of a protective order is a class 1
of a protective order is guilty of 1
of a protective order listed above the 1
of a protective order may be a 1
of a protective order or any time 1
of a protective order shall be guilty 1
of a protective order shall constitute contempt 1
of a protective order that prohibits purchase 1
of a protective order the respondent shall 1
of a restraining order or a protective 1
of a temporary order for protection against 1
of an emergency order of protection from 1
of an extended order is guilty of 1
of firearms shall order the removal of 1
of protection may order other injunctive relief 1
of protection may order other relief considered 1
of protection or order of protection 2 1
of protection or order of protection is 1
of protection shall order and instruct the 1
of such an order the police officer 1
of the court order including the potential 1
of the extended order and state law 1
of the final order to the sheriff 1
of the protection order and the court 1
of the protection order had notice of 1
of the protection order or b during 1
of the protection order or consent agreement 1
of the protective order are criminal offenses 1
of the protective order fails to pay 1
of the protective order has a firearm 1
of the protective order has any pending 1
of the protective order is disqualified from 1
of the protective order is prohibited from 1
of the protective order is prohibited under 1
of the protective order is subject to 1
of the protective order the defendant is 1
of the protective order the defendant shall 1
of the protective order whether the plaintiff 1
of the temporary order if the petition 1
of the temporary order to the sheriff 1
of violating an order for protection owns 1
of violating an order of protection is 1
officer serving an order that includes an 1
officer serving the order may take custody 1
or a final order of protection may 1
or a foreign order of protection accorded 1
or a foreign order of protection in 1
or a protective order or such person’s 1
or a similar order issued by another 1
or any successive order of protection is 1
or by court order 11 removal process 1
or by the order of any federal 1
or child protective order may prohibit the 1
or child protective order that would qualify 1
or continue to order the immediate suspension 1
or domestic violence order or any adult 1
or emergency protective order 1 the license 1
or emergency protective order 2 kentucky domestic 1
or emergency protective order to surrender his 1
or final protection order may also g 1
or final protective order for family violence 1
or final protective order shall state in 1
or final protective order shall upon conviction 1
or final protective order which causes physical 1
or final protective order who is in 1
or final protective order who violated the 1
or final stalking order of protection if 1
or final stalking order of protection the 1
or foreign protection order and the individual 1
or no contact order restraining the person 1
or preliminary protective order may include s 1
or until such order is no longer 1
order and protective order firearm removal domestic 1
order civil protective order firearm removal domestic 1
order domestic violence order of protection or 1
order harassment protection order or sexual assault 1
order if the order restrains the abusing 1
order if the order was issued after 1
order issue an order directing any law 1
order of protection order the forfeiture of 1
order or protective order 16 a person 1
order or protective order 6 cohabitant is 1
order or protective order 9 penalties for 1
order or protective order any of the 1
order or protective order has expired or 1
order or protective order in cases of 1
order or protective order that the person 1
order or protective order the commissioner of 1
order or protective order to the commissioner 1
order or protective order who fails to 1
order stalking protective order criminal no contact 1
order9 and the order shall state on 1
parte child protective order may order any 1
party to an order of protection has 1
person violates an order of protection if 1
petition for an order for protection in 1
petition for an order of protection 5 1
petition for an order of protection an 1
petition for an order of protection domestic 1
petition for an order of protection if 1
petition for an order of protection persons 1
pistol license the order must be served 1
possessing a firearm order the respondent to 1
prevention act restraining order firearm removal civil 1
protected individuals shall order the respondent to 1
protected under the order or child of 1
protection arkansas civil order of protection firearm 1
protection from abuse order 26 if the 1
protection from abuse order 4 however a 1
protection from abuse order 6 abuse is 1
protection from abuse order 7 a person 1
protection from abuse order a defendant who 1
protection from abuse order after notice and 1
protection from abuse order an acknowledgment that 1
protection from abuse order an adult person 1
protection from abuse order an adult who 1
protection from abuse order and that the 1
protection from abuse order at any staffed 1
protection from abuse order cannot be enforced 1
protection from abuse order consistent with section 1
protection from abuse order exists 17 if 1
protection from abuse order exists 18 a 1
protection from abuse order family defined to 1
protection from abuse order has been dismissed 1
protection from abuse order has been entered 1
protection from abuse order if no such 1
protection from abuse order in either tangible 1
protection from abuse order is not presented 1
protection from abuse order is punishable as 1
protection from abuse order issued on behalf 1
protection from abuse order may be convicted 1
protection from abuse order may be disposed 1
protection from abuse order may direct that 1
protection from abuse order may find the 1
protection from abuse order may relinquish firearms 1
protection from abuse order must order the 1
protection from abuse order not to possess 1
protection from abuse order on behalf of 1
protection from abuse order or a protection 1
protection from abuse order or if the 1
protection from abuse order other than an 1
protection from abuse order persons who are 1
protection from abuse order requiring the relinquishment 1
protection from abuse order requiring the respondent 1
protection from abuse order shall arrest such 1
protection from abuse order shall relinquish any 1
protection from abuse order shall the law 1
protection from abuse order such petition shall 1
protection from abuse order that requires relinquishment 1
protection from abuse order the proof of 1
protection from abuse order through conduct that 1
protection from abuse order to order or 1
protection from abuse order to relinquish any 1
protection from abuse order whether past or 1
protection from abuse order which order provides 1
protection from abuse order which required relinquishment 1
protection from abuse order which requires relinquishment 1
protection from abuse order who wishes to 1
protection from abuse order within the first 1
protection or an order of protection 2 1
protection or an order of protection involves 1
protection or an order of protection issued 1
protection or plenary order of protection may 1
protection or restraining order in a family 1
protection order may order any other relief 1
protection order may order other relief as 1
protection order may order such other relief 1
protection order shall order the immediate surrender 1
protection order shall order the immediate suspension 1
protection the temporary order of protection is 1
protective order may order a ny other 1
protective order may order any further relief 1
protective order may order the defendant to 1
protective order shall order the respondent to 1
provision modified by order of the court 1
pursuant to an order of protection 16the 1
pursuant to an order of protection shall 1
pursuant to an order to surrender firearms 1
pursuant to the order of the court 1
qualify for an order above you may 1
receipt of the order 10 a law 1
receipt of the order and in a 1
removal any protective order that includes any 1
removal process an order of protection that 1
rescinding the restraining order or protective order 1
respondent of the order make a reasonable 1
respondent that the order is effective upon 1
respondent to an order of protection that 1
respondent violates the order for protection within 1
respondent with the order and allow the 1
restraining or protective order 11 family or 1
restraining or protective order any family or 1
restraining or protective order for which possession 1
restraining or protective order who has a 1
restraining or protective order who surrendered a 1
restraining order may order the removal of 1
restraining order may order the search for 1
result if an order is not issued 1
returned until the order has been completely 1
rules for an order directing the release 1
s when the order expires or is 1
seeking a protective order the criminal record 1
served the protective order within 48 hours 1
served with the order 12 the respondent 1
served with the order california law authorizes 1
served with the order engaged in violent 1
served with the order in open court 1
served with the order outside of the 1
served with the order shall inform the 1
service of the order 15 compliance when 1
service of the order 6 penalties for 1
service of the order immediately relinquish the 1
service of the order of protection 8 1
service of the order on the defendant 1
service of the order retain a copy 1
service of the order surrender any firearm 1
service of the order to the appropriate 1
serving a protective order that indicates that 1
serving the protective order or shall allow 1
sexual assault protection order stalking protective order 1
sexual assault protection order who knowingly violate 1
shall either a order the respondent to 1
shall issue an order directing the law 1
shotguns the temporary order of protection or 1
specified in the order 14 upon entry 1
specified in the order 17 the defendant 1
specified in the order 22within 24 hours 1
specifies in the order all firearms muzzle 1
subject of the order 7 a final 1
subject of the order 7 compliance when 1
subject of the order 8 individuals who 1
subject of the order and apply to 1
subject of the order if the court 1
subject of the order is prohibited from 1
subject of the order may make a 1
subject of the order of the terms 1
subject of the order or known to 1
subject of the order possesses to a 1
subject of the order possesses to the 1
subject of the order to surrender to 1
subject to an order for protection in 1
subject to an order of a court 1
subject to an order of protection at 1
subject to an order of protection that 1
subject to an order that qualifies under 1
subject to any order of protection arkansas 1
subject to the order of protection that 1
subject to the order the court shall 1
subsequently return may order the alleged abusive 1
surrender and extend order and schedule a 1
surrender and extend order or lift the 1
suspension or ineligibility order pursuant to a 1
temporary abuse protection order or a similar 1
temporary civil protection order may order any 1
temporary civil protection order which may be 1
temporary emergency protective order issued pursuant to 1
temporary or extended order for protection against 1
temporary or final order of protection may 1
termination of the order or until the 1
terms of the order 10 the respondent 1
terms of the order including that the 1
that includes an order to surrender firearms 1
that issued the order of protection or 1
that issued the order within 24 hours 1
that issued the order within 72 hours 1
that served the order 3 additionally a 1
that the protective order that prohibited the 1
that the restraining order or protective order 1
the aforementioned protection order a current or 1
the civil protection order is required to 1
the civil protection order to relinquish any 1
the court may order a the local 1
the court may order the respondent to 1
the court shall order or continue to 1
the court shall order the abusing party 1
the court shall order the defendant to 1
the court shall order the defendant within 1
the court shall order the local law 1
the court shall order the sheriff to 1
the court shall order the subject of 1
the court shall order the transferred firearms 1
the court to order the release of 1
the current protective order if the subject 1
the domestic violence order if the petitioner 1
the extended temporary order 18 the respondent 1
the injunction or order 13 at the 1
the injunction or order 3 individuals who 1
the order and order the surrender of 1
the period the order is in effect 1
the personal protection order 1 michigan personal 1
the personal protection order 7 a hearing 1
the personal protection order 9 if the 1
the temporary restraining order for 48 hours 1
the temporary restraining order if one was 1
their final protective order is not extended 1
time of such order the court shall 1
time of the order and does not 1
time of the order that the firearm 1
time of the order that the respondent 1
time of the order the person had 1
time while the order remains in effect 1
to a court order prohibiting the possession 1
to a court order that 1 was 1
to a court order that is firearm 1
to a court order that was issued 1
to a disqualifying order listed above under 1
to a protective order 26 return of 1
to a protective order based on the 1
to a protective order for a party 1
to a protective order issued after notice 1
to a protective order may charge the 1
to a protective order or child protective 1
to a protective order relating to a 1
to a protective order return of firearms 1
to a protective order shall not release 1
to a protective order though the fee 1
to a restraining order or protective order 1
to a temporary order may have the 1
to a temporary order may request that 1
to an emergency order of protection individuals 1
to an existing order of protection 5 1
to obey the order may modify an 1
to the restraining order or protective order 1
under wisconsin law order the respondent to 1
underlying domestic violence order or emergency protective 1
violated the protective order and causes physical 1
violates a protection order after service or 1
violates a protection order is subject to 1
violates a protective order may be prosecuted 1
violates a protective order shall be guilty 1
violates an extended order for protection against 1
violating a protection order or analogous municipal 1
violating a protection order shall be guilty 1
violating a protection order who has a 1
violating a protective order or of an 1
violation of an order for any further 1
violation of an order for protection also 1
violation of an order for protection shall 1
violation of an order of protection after 1
violation of an order of protection the 1
violation of an order prohibiting the respondent 1
violation of an order to surrender all 1
violation of such order at any noticed 1
violation of such order in issuing an 1
violation of such order the court may 1
violation of such order upon conviction shall 1
violation of the order 22 the law 1
violation of the order is a misdemeanor 1
violation of the order shall be guilty 1
violation the protective order should indicate which 1
violation whenever an order for protection is 1
violence a magistrate’s order for emergency protection 1
violence personal protection order may restrain or 1
violence personal protection order or an ex 1
violence restraining protective order firearm removal civil 1
weapons until further order of the court 1
whether the protective order has been renewed 1
whether the temporary order of protection from 1
whether the temporary order of protection is 1
while the protective order was in effect 1
who issued the order terminates the suspension 1
who violates an order to surrender any 1
with the court’s order 20 if the 1
with the court’s order to surrender or 1
with the protective order and the respondent 1
with the protective order the defendant must 1
with the protective order the respondent may 1
with violating an order of protection shall 1
without a court order 15 a respondent 1
without a court order granting such release 1
workplace violence restraining order or elder or 1

Based on this table, tokens I will create are: * “protective order” * “restraining order” * “temporary order” * “temporary order” * “order may” * “order shall” * “shall order” * “may order”

# Context for "order"
ngrams_separated %>%
  filter(word4 == "order") %>%
  count(word1, word2, word3, word4, word5, word6, word7, sort = TRUE) %>% kable() %>% kable_styling() %>% scroll_box(width = "100%", height = "400px")
word1 word2 word3 word4 word5 word6 word7 n
domestic violence protective order firearm removal civil 6
family violence protective order an injunction against 6
for a protective order the following persons 6
domestic abuse protective order or domestic assault 5
the court shall order the respondent to 5
violation of an order of protection is 5
while the protective order is in effect 5
by the respondent order the respondent ineligible 4
domestic violence protection order firearm removal domestic 4
firearm license and order the immediate surrender 4
obey a temporary order of protection or 4
petition for an order of protection the 4
a civil protection order that qualifies as 3
a domestic violence order for protection after 3
benefit the protective order is in effect 3
domestic violence protective order firearm removal domestic 3
domestic violence protective order from possessing any 3
firearm while the order is in effect 3
for a protection order the following persons 3
issuing a civil order of protection interim 3
issuing a temporary order of protection or 3
may hold and order the defendant to 3
of protection interim order of protection or 3
petition for an order of protection a 3
protection from abuse order was issued the 3
qualifies as an order pursuant to 18 3
to a protective order in cases of 3
a domestic violence order of protection may 2
a domestic violence order or emergency protective 2
abuse order may order the respondent to 2
an emergency protective order preliminary protective order 2
an ex parte order from contacting threatening 2
an ex parte order of protection or 2
civil domestic violence order of protection firearm 2
control while the order is in effect 2
court shall also order the respondent to 2
domestic abuse protection order shall order the 2
domestic violence protection order firearm removal civil 2
domestic violence protective order from possessing firearms 2
domestic violence protective order including an order 2
domestic violence protective order may direct the 2
domestic violence protective order or evidence obtained 2
domestic violence protective order provides information regarding 2
domestic violence protective order the court shall 2
domestic violence protective order the judge shall 2
domestic violence protective order under 18 u.s.c 2
domestic violence protective order where the violation 2
domestic violence protective order which does not 2
domestic violence restraining order may order the 2
domestic violence restraining order shall require the 2
duration of the order i f the 2
duration of the order if the order 2
duration of the order the court shall 2
final personal protection order against stalking may 2
firearm while the order of protection is 2
for a protective order to protect the 2
issuing a final order of protection determines 2
issuing an extended order for protection against 2
knows of the order is a class 2
of a protective order has a firearm 2
of a protective order or final disposition 2
of an extended order for protection against 2
of protection or order of protection shall 2
of the restraining order or protective order 2
officer serving the order must determine if 2
or ammunition shall order that such firearm 2
or child protective order including an ex 2
order including an order issued by telephone 2
order or protective order or the issuance 2
order preliminary protective order or protective order 2
petition for an order for protection against 2
petition for an order for protection family 2
protection from abuse order a plain language 2
protection from abuse order and the penalty 2
protection from abuse order firearm removal civil 2
protection from abuse order firearm removal protection 2
protection from abuse order is a class 2
protection from abuse order issued pursuant to 2
protection from abuse order may direct the 2
protection from abuse order may order the 2
protection from abuse order the following persons 2
protection or an order of protection the 2
protection or final order of protection may 2
protection or plenary order of protection prohibits 2
rescinds the restraining order or protective order 2
restraining or protective order issued by a 2
specified in the order and any and 2
subject of the order a current or 2
subject of the order to be in 2
the court shall order that the firearm 2
the court shall order the restrained party 2
the emergency protective order that the respondent 2
the judge shall order the transfer of 2
to a court order including an ex 2
to a temporary order of protection or 2
violation of an order is a class 2
violation of an order of protection and 2
violation of an order of protection or 2
whose protection the order of protection was 2
1 valid protection order is defined as 1
12 if the order prohibits the defendant 1
13 if the order includes a requirement 1
2 washington court order firearm removal civil 1
3 arizona civil order of protection firearm 1
3 civil protective order firearm removal domestic 1
6 minnesota civil order for protection in 1
6320 ex parte order enjoining contact credibly 1
6321 ex parte order excluding party from 1
6322 ex parte order enjoining specified behavior 1
8 the protective order shall also prohibit 1
a child protective order on behalf of 1
a civil emergency order of protection may 1
a civil protection order may grant such 1
a civil protection order the court is 1
a civil protection order to refrain from 1
a court to order such temporary relief 1
a domestic abuse order of protection issued 1
a domestic abuse order of protection shall 1
a domestic violence order for protection is 1
a domestic violence order may direct or 1
a domestic violence order of protection 2 1
a domestic violence order of protection a 1
a domestic violence order of protection any 1
a domestic violence order of protection issued 1
a domestic violence order of protection shall 1
a domestic violence order of protection spouses 1
a fapa restraining order 7 abuse is 1
a fapa restraining order a true copy 1
a final protection order or a modification 1
a final protective order and if they 1
a final protective order for family violence 1
a final protective order if their final 1
a final protective order may impose any 1
a final protective order spouses or reciprocal 1
a hearing may order a respondent to 1
a hearing may order the disposition of 1
a judge may order a respondent to 1
a personal protection order or foreign protection 1
a personal protection order spouses former spouses 1
a personal protection order the following persons 1
a preliminary protective order in cases of 1
a prior protective order 7 removal process 1
a substantially similar order issued by a 1
a temporary protection order that includes but 1
a temporary protective order if they are 1
a temporary restraining order or a final 1
a valid protection order for domestic abuse 1
abuse order must order the defendant to 1
abuse order to order or restrain any 1
abuse order which order provides for the 1
abuse temporary restraining order is not required 1
accordance with the order 12 if the 1
against whom an order of protection was 1
alabama civil protection order firearm removal domestic 1
also issue an order prohibiting the defendant 1
an abuse prevention order any family or 1
an abuse prevention order from purchasing or 1
an abuse prevention order is a crime 1
an abuse prevention order may relinquish to 1
an abuse prevention order on behalf of 1
an abuse prevention order or any other 1
an abuse prevention order shall make such 1
an abuse prevention order shall not return 1
an abuse prevention order to surrender their 1
an emergency protective order or a domestic 1
an emergency protective order or domestic violence 1
an emergency protective order or preliminary protective 1
an ex parte order 2 a court 1
an ex parte order for protection may 1
an ex parte order shall if requested 1
and hearing may order firearms and ammunition 1
and hearing may order o ther relief 1
and shall further order a person restrained 1
and shall further order the defendant not 1
and the protective order is no longer 1
any firearm or order the surrender of 1
any prior protective order or any violation 1
any successive protective order is in effect 1
as the protective order is in effect 1
as the protective order or any successive 1
at which the order was issued the 1
authorize courts to order the removal of 1
b if the order requires relinquishment of 1
bail was ordered order the respondent to 1
before enforcing the order 19 a knowing 1
before receiving an order from the court 1
blood or court order as a parent 1
by a protective order and not later 1
by a protective order the subject of 1
by the court order sell or transfer 1
by the court order surrender any firearm 1
by the petitioner order o ther relief 1
by the protective order regardless of whether 1
by the protective order the offender shall 1
carolina domestic abuse order of protection firearm 1
carrying a protective order requiring the surrender 1
cause and the order to appear on 1
civil abuse prevention order firearm removal vermont 1
civil domestic violence order for protection firearm 1
civil family violence order firearm removal civil 1
civil harassment restraining order workplace violence restraining 1
complaint requesting any order which will protect 1
comply with the order before enforcing the 1
consent agreement may order the defendant to 1
contact order antiharassment order domestic violence order 1
contempt or an order for money sanctions 1
content of the order 8 return of 1
contents of the order 17 a violation 1
control and further order ing a person 1
copy of the order and firearm information 1
copy of the order and proof of 1
copy of the order the first violation 1
copy of the order to transfer firearms 1
county where the order was entered 23 1
county where the order was entered in 1
court by separate order shall provide for 1
court for an order of disposition the 1
court issues an order directing that the 1
court issuing an order for protection in 1
court issuing an order of protection may 1
court issuing an order of protection shall 1
court issuing an order that includes a 1
court issuing an order to an abusive 1
court issuing the order of protection shall 1
court may also order temporary surrender of 1
court seeking an order for the return 1
court shall also order the restrained party 1
criminal and protective order history prior to 1
criminal no contact order antiharassment order domestic 1
dating violence protective order if the person 1
dating violence protective order may not prohibit 1
dating violence protective order or child protective 1
defendant 30 such order shall include the 1
defendant if the order prohibits the defendant 1
defendant while an order is in effect 1
defined as an order issued after a 1
designated in the order a written statement 1
directed by court order and provide the 1
domestic abuse protection order 13 upon revocation 1
domestic abuse protection order 8 abuse is 1
domestic abuse protection order a person suffering 1
domestic abuse protection order a temporary domestic 1
domestic abuse protection order firearm removal civil 1
domestic abuse protection order firearm removal domestic 1
domestic abuse protection order for themselves alleging 1
domestic abuse protection order is a misdemeanor 1
domestic abuse protection order may be held 1
domestic abuse protection order may not be 1
domestic abuse protection order may provide relief 1
domestic abuse protection order on behalf of 1
domestic abuse protection order or final domestic 1
domestic abuse protection order shall be returned 1
domestic abuse protection order that requires surrender 1
domestic abuse protection order the court shall 1
domestic abuse protective order 4 a minor 1
domestic abuse protective order 5 domestic abuse 1
domestic abuse protective order a person or 1
domestic abuse protective order a victim of 1
domestic abuse protective order firearm removal civil 1
domestic abuse protective order or a domestic 1
domestic assault protective order 7 domestic abuse 1
domestic assault protective order a person suffering 1
domestic assault protective order domestic abuse protective 1
domestic assault protective order firearm removal domestic 1
domestic assault protective order may order the 1
domestic assault protective order of which the 1
domestic assault protective order shall be returned 1
domestic assault protective order shall not apply 1
domestic assault protective order shall subject the 1
domestic assault protective order the court may 1
domestic violence may order such other relief 1
domestic violence protection order 3 family or 1
domestic violence protection order 5 domestic violence 1
domestic violence protection order a spouse or 1
domestic violence protection order any family or 1
domestic violence protection order any person who 1
domestic violence protection order forms contain a 1
domestic violence protection order forms note that 1
domestic violence protection order harassment protection order 1
domestic violence protection order has been granted 1
domestic violence protection order if the respondent 1
domestic violence protection order issued after notice 1
domestic violence protection order may grant relief 1
domestic violence protection order may o rder 1
domestic violence protection order may order other 1
domestic violence protection order may order such 1
domestic violence protection order may prohibit the 1
domestic violence protection order may require the 1
domestic violence protection order or an ex 1
domestic violence protection order spouses former spouses 1
domestic violence protection order the following persons 1
domestic violence protective order 18 the third 1
domestic violence protective order 4 abuse is 1
domestic violence protective order after notice and 1
domestic violence protective order an adult alleging 1
domestic violence protective order and the court 1
domestic violence protective order civil protective order 1
domestic violence protective order family or household 1
domestic violence protective order family violence is 1
domestic violence protective order for which firearm 1
domestic violence protective order for which the 1
domestic violence protective order from purchasing receiving 1
domestic violence protective order if the court 1
domestic violence protective order is a misdemeanor 1
domestic violence protective order is issued against 1
domestic violence protective order is issued at 1
domestic violence protective order issued by another 1
domestic violence protective order louisiana domestic violence 1
domestic violence protective order may also result 1
domestic violence protective order may be incarcerated 1
domestic violence protective order may prohibit the 1
domestic violence protective order may result in 1
domestic violence protective order may transport a 1
domestic violence protective order on behalf of 1
domestic violence protective order peace officers shall 1
domestic violence protective order penalties for violation 1
domestic violence protective order persons eligible for 1
domestic violence protective order persons who have 1
domestic violence protective order prohibits the respondent 1
domestic violence protective order shall direct the 1
domestic violence protective order shall order the 1
domestic violence protective order shall require removal 1
domestic violence protective order that qualifies for 1
domestic violence protective order the court may 1
domestic violence protective order to surrender firearms 1
domestic violence protective order whether issued ex 1
domestic violence restraining order 9 victim of 1
domestic violence restraining order a victim of 1
domestic violence restraining order and protective order 1
domestic violence restraining order firearm removal domestic 1
domestic violence restraining order may also issue 1
domestic violence restraining order may forbid the 1
domestic violence restraining order or protective order 1
domestic violence restraining order prohibiting the person 1
domestic violence restraining order requires the surrender 1
domestic violence restraining order shall not apply 1
domestic violence7 protective order any parent adult 1
domestic violence8 protective order spouses or former 1
duration of the order 1 a court 1
duration of the order 10 if there 1
duration of the order 12 within 24 1
duration of the order 13 if the 1
duration of the order 14 return of 1
duration of the order 2 new hampshire 1
duration of the order 5 if the 1
duration of the order 8 if there 1
duration of the order and order the 1
duration of the order and orders the 1
duration of the order and relinquish for 1
duration of the order any firearm or 1
duration of the order for protection unless 1
duration of the order if the defendant 1
duration of the order if the demonstrates 1
duration of the order if the respondent 1
duration of the order issue an order 1
duration of the order of protection unless 1
duration of the order or are otherwise 1
duration of the order or two years 1
duration of the order or until otherwise 1
emergency ex parte order that it finds 1
end of the order the firearm s 1
entry of the order a party ordered 1
entry of the order granting return of 1
espondent with this order as follows 4 1
even if the order does not specifically 1
ex parte protection order an ex parte 1
ex parte protective order or child protective 1
ex parte protective order or ex parte 1
ex parte protective order or protective order 1
existence of the order a violation of 1
expiration of an order the local law 1
expiration of the order or dismissal of 1
expiration of the order the court shall 1
expiration of the order the court should 1
extend the protective order the court shall 1
family abuse may order a ny other 1
family violence may order the person found 1
family violence protective order all separation divorce 1
family violence protective order injunction against abuse 1
family violence protective order may be punished 1
family violence protective order past or present 1
filed and an order issued by a 1
final abuse prevention order and attempts to 1
final domestic violence order of protection 8 1
final domestic violence order of protection may 1
final domestic violence order of protection prohibits 1
final domestic violence order of protection who 1
finds that the order has ended no 1
firearm 3 nevada order for protection against 1
firearms 4 an order issued pursuant to 1
firearms and an order to relinquish firearms 1
firearms if the order was issued after 1
fixed in the order 1 additionally if 1
for a protection order a person who 1
for a protection order a spouse including 1
for a protection order spouses former spouses 1
for a protective order a household member 1
for a protective order a victim of 1
for a protective order and use the 1
for a protective order any cohabitant who 1
for a protective order household member includes 1
for a protective order on behalf of 1
for a protective order protective orders in 1
for a protective order spouses former spouses 1
for a protective order to protect a 1
for a restraining order any person who 1
from seeking an order of protection 3 1
g 8 shall order the subject of 1
g 8 to order the subject of 1
grant a protective order 5 domestic violence 1
grant any protective order to bring about 1
has issued an order that rescinds the 1
has violated the order 6 within 24 1
has violated the order of protection may 1
have jurisdiction to order the return of 1
hearing on the order of protection the 1
hearing while the order remains in effect 1
hours of the order to surrender firearms 1
ii includes an order requiring the person 1
in a protective order issued against a 1
in issuing an order to show cause 1
in the court’s order for the duration 1
in the protective order that the court 1
in which the order was issued within 1
injunction or protective order if the injunction 1
injunction or protective order includes a a 1
injunction or protective order informs the subject 1
injunction or protective order post separation family 1
injunction or protective order represents a credible 1
injunction or protective order that the person 1
is violating the order and the injunction 1
issuance of the order of protection involved 1
issuance of the order of protection the 1
issuance of the order that the respondent 1
issuance of the order to transfer all 1
issued the protective order and a copy 1
issuing a final order for protection in 1
issuing a protective order dating violence protective 1
issuing a protective order for a victim 1
issuing a protective order may i nclude 1
issuing a protective order may order a 1
issuing a protective order or child protective 1
issuing a temporary order for protection against 1
issuing a temporary order of protection shall 1
jurisdiction including an order described in 18 1
knowingly violate such order 2 a court 1
knowingly violates an order of protection shall 1
law or court order precluding the ownership 1
law or court order that precludes the 1
license if the order is no longer 1
licensee while the order of protection is 1
long as the order is in effect 1
long as the order of protection or 1
magistrate issuing an order for emergency protection 1
make a new order of protection order 1
may continue the order of surrender and 1
may include an order not to possess 1
may limit the order to exclude that 1
mexico domestic violence order of protection firearm 1
michigan personal protection order firearm removal civil 1
missouri domestic violence order of protection firearm 1
modify an existing order to add reasonable 1
montana domestic violence order of protection firearm 1
named in the order 16 it is 1
named in the order shall be guilty 1
named in the order shall upon conviction 1
not obtain an order of protection against 1
notice of the order 5 in a 1
notice of the order a violation of 1
notice of the order sell and transfer 1
notice of the order shall be guilty 1
notice of the order shall constitute contempt 1
obey a prior order of protection and 1
of a court order or failure to 1
of a court order rescinding the restraining 1
of a court order that rescinds the 1
of a protection order 19 a violation 1
of a protection order a final protection 1
of a protection order is a class 1
of a protection order issued after notice 1
of a protection order or consent agreement 1
of a protection order or no contact 1
of a protection order shall be a 1
of a protection order which is a 1
of a protective order and disorderly conduct 1
of a protective order and who are 1
of a protective order does not file 1
of a protective order is a class 1
of a protective order is guilty of 1
of a protective order listed above the 1
of a protective order may be a 1
of a protective order or any time 1
of a protective order shall be guilty 1
of a protective order shall constitute contempt 1
of a protective order that prohibits purchase 1
of a protective order the respondent shall 1
of a restraining order or a protective 1
of a temporary order for protection against 1
of an emergency order of protection from 1
of an extended order is guilty of 1
of firearms shall order the removal of 1
of protection may order other injunctive relief 1
of protection may order other relief considered 1
of protection or order of protection 2 1
of protection or order of protection is 1
of protection shall order and instruct the 1
of such an order the police officer 1
of the court order including the potential 1
of the extended order and state law 1
of the final order to the sheriff 1
of the protection order and the court 1
of the protection order had notice of 1
of the protection order or b during 1
of the protection order or consent agreement 1
of the protective order are criminal offenses 1
of the protective order fails to pay 1
of the protective order has a firearm 1
of the protective order has any pending 1
of the protective order is disqualified from 1
of the protective order is prohibited from 1
of the protective order is prohibited under 1
of the protective order is subject to 1
of the protective order the defendant is 1
of the protective order the defendant shall 1
of the protective order whether the plaintiff 1
of the temporary order if the petition 1
of the temporary order to the sheriff 1
of violating an order for protection owns 1
of violating an order of protection is 1
officer serving an order that includes an 1
officer serving the order may take custody 1
or a final order of protection may 1
or a foreign order of protection accorded 1
or a foreign order of protection in 1
or a protective order or such person’s 1
or a similar order issued by another 1
or any successive order of protection is 1
or by court order 11 removal process 1
or by the order of any federal 1
or child protective order may prohibit the 1
or child protective order that would qualify 1
or continue to order the immediate suspension 1
or domestic violence order or any adult 1
or emergency protective order 1 the license 1
or emergency protective order 2 kentucky domestic 1
or emergency protective order to surrender his 1
or final protection order may also g 1
or final protective order for family violence 1
or final protective order shall state in 1
or final protective order shall upon conviction 1
or final protective order which causes physical 1
or final protective order who is in 1
or final protective order who violated the 1
or final stalking order of protection if 1
or final stalking order of protection the 1
or foreign protection order and the individual 1
or no contact order restraining the person 1
or preliminary protective order may include s 1
or until such order is no longer 1
order and protective order firearm removal domestic 1
order civil protective order firearm removal domestic 1
order domestic violence order of protection or 1
order harassment protection order or sexual assault 1
order if the order restrains the abusing 1
order if the order was issued after 1
order issue an order directing any law 1
order of protection order the forfeiture of 1
order or protective order 16 a person 1
order or protective order 6 cohabitant is 1
order or protective order 9 penalties for 1
order or protective order any of the 1
order or protective order has expired or 1
order or protective order in cases of 1
order or protective order that the person 1
order or protective order the commissioner of 1
order or protective order to the commissioner 1
order or protective order who fails to 1
order stalking protective order criminal no contact 1
order9 and the order shall state on 1
parte child protective order may order any 1
party to an order of protection has 1
person violates an order of protection if 1
petition for an order for protection in 1
petition for an order of protection 5 1
petition for an order of protection an 1
petition for an order of protection domestic 1
petition for an order of protection if 1
petition for an order of protection persons 1
pistol license the order must be served 1
possessing a firearm order the respondent to 1
prevention act restraining order firearm removal civil 1
protected individuals shall order the respondent to 1
protected under the order or child of 1
protection arkansas civil order of protection firearm 1
protection from abuse order 26 if the 1
protection from abuse order 4 however a 1
protection from abuse order 6 abuse is 1
protection from abuse order 7 a person 1
protection from abuse order a defendant who 1
protection from abuse order after notice and 1
protection from abuse order an acknowledgment that 1
protection from abuse order an adult person 1
protection from abuse order an adult who 1
protection from abuse order and that the 1
protection from abuse order at any staffed 1
protection from abuse order cannot be enforced 1
protection from abuse order consistent with section 1
protection from abuse order exists 17 if 1
protection from abuse order exists 18 a 1
protection from abuse order family defined to 1
protection from abuse order has been dismissed 1
protection from abuse order has been entered 1
protection from abuse order if no such 1
protection from abuse order in either tangible 1
protection from abuse order is not presented 1
protection from abuse order is punishable as 1
protection from abuse order issued on behalf 1
protection from abuse order may be convicted 1
protection from abuse order may be disposed 1
protection from abuse order may direct that 1
protection from abuse order may find the 1
protection from abuse order may relinquish firearms 1
protection from abuse order must order the 1
protection from abuse order not to possess 1
protection from abuse order on behalf of 1
protection from abuse order or a protection 1
protection from abuse order or if the 1
protection from abuse order other than an 1
protection from abuse order persons who are 1
protection from abuse order requiring the relinquishment 1
protection from abuse order requiring the respondent 1
protection from abuse order shall arrest such 1
protection from abuse order shall relinquish any 1
protection from abuse order shall the law 1
protection from abuse order such petition shall 1
protection from abuse order that requires relinquishment 1
protection from abuse order the proof of 1
protection from abuse order through conduct that 1
protection from abuse order to order or 1
protection from abuse order to relinquish any 1
protection from abuse order whether past or 1
protection from abuse order which order provides 1
protection from abuse order which required relinquishment 1
protection from abuse order which requires relinquishment 1
protection from abuse order who wishes to 1
protection from abuse order within the first 1
protection or an order of protection 2 1
protection or an order of protection involves 1
protection or an order of protection issued 1
protection or plenary order of protection may 1
protection or restraining order in a family 1
protection order may order any other relief 1
protection order may order other relief as 1
protection order may order such other relief 1
protection order shall order the immediate surrender 1
protection order shall order the immediate suspension 1
protection the temporary order of protection is 1
protective order may order a ny other 1
protective order may order any further relief 1
protective order may order the defendant to 1
protective order shall order the respondent to 1
provision modified by order of the court 1
pursuant to an order of protection 16the 1
pursuant to an order of protection shall 1
pursuant to an order to surrender firearms 1
pursuant to the order of the court 1
qualify for an order above you may 1
receipt of the order 10 a law 1
receipt of the order and in a 1
removal any protective order that includes any 1
removal process an order of protection that 1
rescinding the restraining order or protective order 1
respondent of the order make a reasonable 1
respondent that the order is effective upon 1
respondent to an order of protection that 1
respondent violates the order for protection within 1
respondent with the order and allow the 1
restraining or protective order 11 family or 1
restraining or protective order any family or 1
restraining or protective order for which possession 1
restraining or protective order who has a 1
restraining or protective order who surrendered a 1
restraining order may order the removal of 1
restraining order may order the search for 1
result if an order is not issued 1
returned until the order has been completely 1
rules for an order directing the release 1
s when the order expires or is 1
seeking a protective order the criminal record 1
served the protective order within 48 hours 1
served with the order 12 the respondent 1
served with the order california law authorizes 1
served with the order engaged in violent 1
served with the order in open court 1
served with the order outside of the 1
served with the order shall inform the 1
service of the order 15 compliance when 1
service of the order 6 penalties for 1
service of the order immediately relinquish the 1
service of the order of protection 8 1
service of the order on the defendant 1
service of the order retain a copy 1
service of the order surrender any firearm 1
service of the order to the appropriate 1
serving a protective order that indicates that 1
serving the protective order or shall allow 1
sexual assault protection order stalking protective order 1
sexual assault protection order who knowingly violate 1
shall either a order the respondent to 1
shall issue an order directing the law 1
shotguns the temporary order of protection or 1
specified in the order 14 upon entry 1
specified in the order 17 the defendant 1
specified in the order 22within 24 hours 1
specifies in the order all firearms muzzle 1
subject of the order 7 a final 1
subject of the order 7 compliance when 1
subject of the order 8 individuals who 1
subject of the order and apply to 1
subject of the order if the court 1
subject of the order is prohibited from 1
subject of the order may make a 1
subject of the order of the terms 1
subject of the order or known to 1
subject of the order possesses to a 1
subject of the order possesses to the 1
subject of the order to surrender to 1
subject to an order for protection in 1
subject to an order of a court 1
subject to an order of protection at 1
subject to an order of protection that 1
subject to an order that qualifies under 1
subject to any order of protection arkansas 1
subject to the order of protection that 1
subject to the order the court shall 1
subsequently return may order the alleged abusive 1
surrender and extend order and schedule a 1
surrender and extend order or lift the 1
suspension or ineligibility order pursuant to a 1
temporary abuse protection order or a similar 1
temporary civil protection order may order any 1
temporary civil protection order which may be 1
temporary emergency protective order issued pursuant to 1
temporary or extended order for protection against 1
temporary or final order of protection may 1
termination of the order or until the 1
terms of the order 10 the respondent 1
terms of the order including that the 1
that includes an order to surrender firearms 1
that issued the order of protection or 1
that issued the order within 24 hours 1
that issued the order within 72 hours 1
that served the order 3 additionally a 1
that the protective order that prohibited the 1
that the restraining order or protective order 1
the aforementioned protection order a current or 1
the civil protection order is required to 1
the civil protection order to relinquish any 1
the court may order a the local 1
the court may order the respondent to 1
the court shall order or continue to 1
the court shall order the abusing party 1
the court shall order the defendant to 1
the court shall order the defendant within 1
the court shall order the local law 1
the court shall order the sheriff to 1
the court shall order the subject of 1
the court shall order the transferred firearms 1
the court to order the release of 1
the current protective order if the subject 1
the domestic violence order if the petitioner 1
the extended temporary order 18 the respondent 1
the injunction or order 13 at the 1
the injunction or order 3 individuals who 1
the order and order the surrender of 1
the period the order is in effect 1
the personal protection order 1 michigan personal 1
the personal protection order 7 a hearing 1
the personal protection order 9 if the 1
the temporary restraining order for 48 hours 1
the temporary restraining order if one was 1
their final protective order is not extended 1
time of such order the court shall 1
time of the order and does not 1
time of the order that the firearm 1
time of the order that the respondent 1
time of the order the person had 1
time while the order remains in effect 1
to a court order prohibiting the possession 1
to a court order that 1 was 1
to a court order that is firearm 1
to a court order that was issued 1
to a disqualifying order listed above under 1
to a protective order 26 return of 1
to a protective order based on the 1
to a protective order for a party 1
to a protective order issued after notice 1
to a protective order may charge the 1
to a protective order or child protective 1
to a protective order relating to a 1
to a protective order return of firearms 1
to a protective order shall not release 1
to a protective order though the fee 1
to a restraining order or protective order 1
to a temporary order may have the 1
to a temporary order may request that 1
to an emergency order of protection individuals 1
to an existing order of protection 5 1
to obey the order may modify an 1
to the restraining order or protective order 1
under wisconsin law order the respondent to 1
underlying domestic violence order or emergency protective 1
violated the protective order and causes physical 1
violates a protection order after service or 1
violates a protection order is subject to 1
violates a protective order may be prosecuted 1
violates a protective order shall be guilty 1
violates an extended order for protection against 1
violating a protection order or analogous municipal 1
violating a protection order shall be guilty 1
violating a protection order who has a 1
violating a protective order or of an 1
violation of an order for any further 1
violation of an order for protection also 1
violation of an order for protection shall 1
violation of an order of protection after 1
violation of an order of protection the 1
violation of an order prohibiting the respondent 1
violation of an order to surrender all 1
violation of such order at any noticed 1
violation of such order in issuing an 1
violation of such order the court may 1
violation of such order upon conviction shall 1
violation of the order 22 the law 1
violation of the order is a misdemeanor 1
violation of the order shall be guilty 1
violation the protective order should indicate which 1
violation whenever an order for protection is 1
violence a magistrate’s order for emergency protection 1
violence personal protection order may restrain or 1
violence personal protection order or an ex 1
violence restraining protective order firearm removal civil 1
weapons until further order of the court 1
whether the protective order has been renewed 1
whether the temporary order of protection from 1
whether the temporary order of protection is 1
while the protective order was in effect 1
who issued the order terminates the suspension 1
who violates an order to surrender any 1
with the court’s order 20 if the 1
with the court’s order to surrender or 1
with the protective order and the respondent 1
with the protective order the defendant must 1
with the protective order the respondent may 1
with violating an order of protection shall 1
without a court order 15 a respondent 1
without a court order granting such release 1
workplace violence restraining order or elder or 1
# I'll take a look at tri-grams to see if there are any noteworthy 
# word combinations I'll want to tokenize
trigram <- d %>%
 unnest_tokens(ngram, Text, token = "ngrams", n = 3)
trigrams_separated <- trigram %>%
  separate(ngram, c("word1", "word2", "word3"), sep = " ")
# Look at top 200 trigrams 
trigrams_counts <- trigrams_separated %>%
  count(word1, word2, word3, sort = TRUE) 
kable(head(trigrams_counts, 200)) %>% kable_styling() %>% 
  scroll_box(width = "100%", height = "400px")
word1 word2 word3 n
order of protection 129
may petition for 92
family or household 89
law enforcement agency 89
of the order 89
domestic violence firearm 88
domestic violence protective 84
protection from abuse 81
violence protective order 80
from abuse order 73
petition for a 71
purchase and possession 66
a court issuing 63
a domestic violence 63
or household member 63
a protective order 62
persons subject to 61
the court shall 61
the subject of 57
firearm purchase and 52
is defined as 52
and possession prohibitions 51
the third party 51
violence firearm purchase 51
of domestic violence 49
firearms or ammunition 48
individuals who may 47
an ex parte 46
an order of 46
a law enforcement 45
penalties for violation 45
who may petition 45
firearm or ammunition 44
subject to a 44
persons convicted of 43
firearms and ammunition 42
of the following 42
a person who 41
court issuing a 41
domestic violence protection 41
possessing a firearm 41
the respondent to 41
firearms other weapons 40
licensed firearms dealer 40
that require removal 40
a firearm or 38
possession of firearms 38
the protective order 38
for a domestic 37
a child in 36
final domestic violence 36
violence firearm prohibitions 36
weapons or ammunition 36
if the court 35
orders that require 35
child in common 34
not more than 34
order firearm removal 34
from possessing a 33
law enforcement officer 33
of firearms or 33
other weapons or 33
removal of firearms 33
a fine of 32
persons who have 32
prohibited from possessing 32
subject of the 32
that the respondent 32
a family or 31
federally licensed firearms 31
local law enforcement 31
the law enforcement 31
a domestic abuse 30
a violation of 30
duration of the 30
for the duration 30
order for protection 30
the duration of 30
all firearms and 29
any firearm or 29
does not prohibit 29
domestic violence order 29
if the respondent 29
protective order or 29
return of firearms 29
the following persons 29
civil domestic violence 28
firearm or other 28
firearms ammunition or 28
the court may 28
a protection from 27
at the time 27
concealed pistol license 27
for violation a 27
of a firearm 27
person who is 27
petition for an 27
the respondent is 27
violation of a 27
a dating relationship 26
does not require 26
law domestic violence 26
possession of the 26
the abusing party 26
violence protection order 26
by the respondent 25
firearm removal civil 25
or protective order 25
persons who are 25
ammunition by persons 24
court issuing an 24
member of the 24
or ammunition by 24
or other dangerous 24
orders of protection 24
pursuant to a 24
subject to domestic 24
that the person 24
who has been 24
current or former 23
domestic abuse protection 23
ex parte or 23
for protection against 23
is a class 23
on behalf of 23
possession or control 23
the time of 23
violation of an 23
a third party 22
any of the 22
from possessing firearms 22
is in effect 22
of the firearm 22
order the respondent 22
protective order the 22
related by blood 22
shall order the 22
the respondent has 22
to domestic violence 22
to the defendant 22
to the sheriff 22
by the court 21
convicted of a 21
following persons may 21
of firearms to 21
or final domestic 21
other dangerous weapons 21
parte or final 21
possess a firearm 21
possession of a 21
protective order is 21
temporary or final 21
weapon or ammunition 21
and all firearms 20
any and all 20
convicted of misdemeanor 20
final protection from 20
firearm removal domestic 20
for an order 20
of any firearm 20
of protection or 20
persons may petition 20
require removal of 20
the firearm s 20
to a domestic 20
to the respondent 20
a federally licensed 19
a protection order 19
a temporary or 19
abuse is defined 19
abuse protection order 19
any person who 19
cause to believe 19
from persons subject 19
have a child 19
of an order 19
or other weapon 19
or possessing firearms 19
protective order may 19
the order of 19
against domestic violence 18
crimes of domestic 18
domestic violence civil 18
domestic violence restraining 18
from purchasing or 18
guilty of a 18
in the same 18
issuing an ex 18
member is defined 18
misdemeanor crimes of 18
not prohibit purchase 18
not require removal 18
of misdemeanor crimes 18
of not more 18
or other weapons 18
or possession of 18
order is in 18
persons related by 18
protection against domestic 18
removal civil domestic 18
# I'll take a look at bigrams as well 
bigram <- d %>%
 unnest_tokens(ngram, Text, token = "ngrams", n = 2)
bigrams_separated <- bigram %>%
  separate(ngram, c("word1", "word2"), sep = " ")
# Look at top bigrams 
bigrams_counts <- bigrams_separated %>%
  count(word1, word2, sort = TRUE) 
kable(head(bigrams_counts, 200)) %>% kable_styling() %>% 
  scroll_box(width = "100%", height = "400px")
word1 word2 n
of the 555
domestic violence 388
protective order 277
the respondent 274
the court 258
to the 251
of a 230
a firearm 180
the defendant 177
to a 170
the order 167
in the 166
or ammunition 163
that the 159
of protection 155
law enforcement 151
order of 138
if the 137
for a 135
of firearms 130
subject to 121
by the 110
the person 110
possession of 108
order the 104
a person 103
petition for 102
protection order 102
a domestic 98
may petition 98
an order 97
or a 97
violence protective 97
does not 96
a court 92
household member 92
any firearm 91
family or 90
or household 90
the following 90
enforcement agency 89
domestic abuse 88
the firearm 88
third party 88
violence firearm 88
firearm or 87
from abuse 86
for the 84
protection from 83
by a 81
firearms and 81
from possessing 78
or other 78
persons who 77
abuse order 76
in a 75
with the 73
and ammunition 72
order or 71
a child 69
is defined 68
person who 68
to surrender 68
court issuing 67
and possession 66
purchase and 66
all firearms 65
who is 65
convicted of 64
firearms or 64
of domestic 64
violation of 64
court shall 63
ex parte 63
shall be 63
the sheriff 63
a protective 62
and the 62
other weapons 62
firearm removal 61
persons subject 61
has been 60
require removal 60
of any 59
the firearms 58
the third 58
subject of 57
the subject 57
pursuant to 55
who have 55
individuals who 54
is a 54
defined as 53
a temporary 52
at the 52
firearm purchase 52
issuing a 52
order may 52
possessing a 52
the petitioner 52
more than 51
order is 51
possession prohibitions 51
penalties for 50
that require 50
who may 50
for violation 49
is not 49
return of 49
for protection 47
of an 47
or final 47
who are 47
a law 46
a protection 46
an ex 46
firearms other 46
order for 46
bodily injury 45
or possessing 45
respondent to 45
firearms to 44
persons convicted 44
prohibited from 44
or control 43
protective orders 43
a fine 42
a misdemeanor 42
by persons 42
up to 42
any person 41
firearms dealer 41
licensed firearms 41
or former 41
possessing firearms 41
violence protection 41
who has 41
punishable by 40
weapons or 40
a dating 39
as a 39
a family 38
child in 38
dangerous weapons 38
firearms ammunition 38
in law 38
or the 38
other dangerous 38
the protective 38
weapons and 38
ammunition or 37
final domestic 37
a class 36
a final 36
firearm prohibitions 36
in common 36
or any 36
order shall 36
orders that 36
removal of 36
a respondent 35
as the 35
from purchasing 35
from the 35
restraining order 35
the time 35
which the 35
civil domestic 34
federally licensed 34
firearm s 34
is in 34
not more 34
of such 34
order firearm 34
order that 34
related by 34
to be 34
court may 33
dating relationship 33
enforcement officer 33
for an 33
or both 33
the law 33
a violation 32
fine of 32
have been 32
issuing an 32
order and 32
order to 32
to carry 32
and a 31
and any 31
any other 31
former spouses 31
in effect 31
local law 31
member of 31
other weapon 31
the abusing 31
duration of 30
# Preprocessing corpus for STM: 
# Tokenizing and creating a document feature matrix;
# changing all tokens to lowercase, removing punctuation,
# removing symbols and numbers; 
# Based on initial models, the topics were including state names often
# so I'll remove tokens of state names as well 
DFM_laws <- tokens(laws_corpus, 
                      remove_punct= TRUE,
                      remove_numbers = TRUE, 
                   remove_symbols = TRUE) %>%
  tokens_tolower() %>%
  tokens_select(pattern=stopwords("en"),
                selection="remove") %>%
  tokens_remove(pattern = c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming', 'new', 'north', 'south', 'dakota', 'york', 'carolina', 'jersey', 'hampshire', 'mexico', 'rhode', 'island', 'west')) %>% 
  tokens_compound(pattern = phrase(c("does not prohibit", "may prohibit", "shall prohibit", "not broadly prohibit", "not explicitly prohibit", "not specifically prohibit", "not require the removal", "require firearm removal", "does not require removal", "that require removal", "removal process", "exemption from removal requirement", "requires removal", "protective order", "restraining order", "temporary order", "temporary order", "order may", "order shall", "shall order", "may order", "law enforcement", "may petition for", "dating relationship", "child in common", "current or former", "domestic violence", "ex parte", "family or household member"))) %>%
  dfm()  
head(DFM_laws)
## Document-feature matrix of: 6 documents, 2,016 features (92.39% sparse) and 0 docvars.
##             features
## docs         law domestic_violence firearm prohibitions purchase possession
##   alabama      5                 5       6            2        1          1
##   alaska       4                11       7            2        2          4
##   arizona      2                 7       9            2        1          1
##   arkansas     2                 4       3            2        1          1
##   california   4                10      41            2        2          8
##   colorado     3                 6      18            2        1          9
##             features
## docs         prohibits following individuals owning
##   alabama            2         3           2      1
##   alaska             0         0           1      0
##   arizona            2         1           1      0
##   arkansas           0         2           1      0
##   california         1         4           1      1
##   colorado           1         3           1      0
## [ reached max_nfeat ... 2,006 more features ]

Now that I’ve added some tokens that are key phrases (in an attempt to maintain context), I will proceed with some analysis. First - some text representation again to see how it has changed since pre-processing, then proceed with structural topic modeling.

Once I run some analysis, I may need to backtrack again to remove some words that are overly dominant in all of the documents, like “order”, if it affects the models ability to develop unique topics. Also, I may backtrack and add some stopwords (not all, just relevant contextual stopwords) to the DFM.

topfeatures(DFM_laws, 20) 
##           firearm             order          firearms        protection 
##               586               571               564               433 
##             court domestic_violence            person        respondent 
##               403               387               364               326 
##           persons        ammunition               may             abuse 
##               302               288               267               263 
##        possession             shall  protective_order             party 
##               255               246               244               206 
##         defendant           subject            family               law 
##               194               181               162               158
textplot_wordcloud(DFM_laws, max_words = 50)

# Feature Co-Occurrence Matrix for processed DFM
fcm_processed1 <- fcm(DFM_laws)
# Pull top features
fcm_processed1_feats <- names(topfeatures(fcm_processed1, 30))
# Retain top features in fcm
fcm_processed1 <- fcm_select(fcm_processed1, pattern = fcm_processed1_feats, selection = "keep")
# compute size weight for vertices in network and create plot
size_processed1fcm <- log(colSums(fcm_processed1))
textplot_network(fcm_processed1, vertex_size = size_processed1fcm / max(size_processed1fcm) * 3)

Okay, it seems like this DFM better highlights the focus of the data source and this research. I’ll being with STM.

# Convert dfm to stm
DFM_STM <- convert(DFM_laws, to = "stm")

Choosing K - number of topics

# Choosing K - Statistical fit criterion 
# Evaluate K 4 through 15
K <- c(4:15)
fit <- searchK(DFM_STM$documents, DFM_STM$vocab, K = K, verbose = FALSE)
# Create table with K value and coherence/exclusivity
Kplot <- data.frame("K" = K, 
                   "Coherence" = unlist(fit$results$semcoh),
                   "Exclusivity" = unlist(fit$results$exclus))
# Reshape table to long format
Kplot <- melt(Kplot, id=c("K"))
Kplot
##     K    variable      value
## 1   4   Coherence -16.770229
## 2   5   Coherence -28.988916
## 3   6   Coherence -26.356990
## 4   7   Coherence -25.975434
## 5   8   Coherence -18.901090
## 6   9   Coherence -26.140954
## 7  10   Coherence -24.093347
## 8  11   Coherence -27.998195
## 9  12   Coherence -31.055103
## 10 13   Coherence -26.806255
## 11 14   Coherence -31.647480
## 12 15   Coherence -31.251084
## 13  4 Exclusivity   7.815334
## 14  5 Exclusivity   8.232668
## 15  6 Exclusivity   8.430752
## 16  7 Exclusivity   8.532567
## 17  8 Exclusivity   8.580087
## 18  9 Exclusivity   8.756855
## 19 10 Exclusivity   8.822895
## 20 11 Exclusivity   8.888449
## 21 12 Exclusivity   8.996638
## 22 13 Exclusivity   9.019790
## 23 14 Exclusivity   9.104469
## 24 15 Exclusivity   9.152230
#Plot results of K statistical testing
ggplot(Kplot, aes(K, value, color = variable)) +
  geom_line(size = 1.5, show.legend = FALSE) +
  facet_wrap(~variable,scales = "free_y") +
  labs(x = "Number of topics K",
       title = "Statistical fit of models with different K")

Based on this, I’ll take a look at the topics produced for K = 6 and K = 10 to start.

# Fit models for K = 6 and K = 10
model_6K <- stm(documents = DFM_STM$documents,
         vocab = DFM_STM$vocab, 
         K = 6,
         verbose = FALSE)
model_10K <- stm(documents = DFM_STM$documents,
         vocab = DFM_STM$vocab, 
         K = 10,
         verbose = FALSE)
# Evaluate interpretability and relevance of models with selected K-values
# by looking at top 10 features for each topic model
# for K = 6
topics_6 <- labelTopics(model_6K, n=10)
topics_6 <- data.frame("features" = t(topics_6$frex))
colnames(topics_6) <- paste("Topics", c(1:6))
topics_6 
##             Topics 1        Topics 2    Topics 3       Topics 4
## 1            persons         adverse     hearing muzzle-loading
## 2           ex_parte           party     permits            fid
## 3        misdemeanor      restrained      deadly           card
## 4         protection         abusing  injunction   relinquished
## 5           personal          agency  respondent    safekeeping
## 6            however         receipt   aggrieved          abuse
## 7             relief         party's        duty      defendant
## 8            removal law_enforcement surrendered          large
## 9              class        transfer    schedule           foid
## 10 domestic_violence         control     located        weapons
##            Topics 5     Topics 6
## 1          violence     revolver
## 2  protective_order       pistol
## 3        protective    dangerous
## 4            family      license
## 5           divorce       degree
## 6       transferred    concealed
## 7   post-separation commissioner
## 8       preliminary       police
## 9        imprisoned    obtaining
## 10          parents  restraining
#%>% kable() %>% kable_styling() %>% scroll_box(height = "100%", width = "600px")
# for K = 10
topics_10 <- labelTopics(model_10K, n=10)
topics_10 <- data.frame("features" = t(topics_10$frex))
colnames(topics_10) <- paste("Topics", c(1:10))
topics_10
##             Topics 1        Topics 2          Topics 3  Topics 4
## 1           ex_parte         adverse         qualified  domestic
## 2        misdemeanor         abusing  protective_order       fid
## 3            removal           party            relief     large
## 4  domestic_violence      restrained             child      guns
## 5            persons         party's domestic_violence  capacity
## 6             victim        transfer            spouse   machine
## 7             orders          agency      respondent's    rifles
## 8         protection         control           provide  shotguns
## 9            however       federally            parent suffering
## 10          prohibit law_enforcement           current complaint
##            Topics 5          Topics 6       Topics 7        Topics 8   Topics 9
## 1          violence            pistol         deadly        personal injunction
## 2        protective          revolver       duration            obey prevention
## 3            family         dangerous           foid temporary_order    hearing
## 4           divorce         concealed muzzle-loading             3rd       stay
## 5       transferred       restraining        partner       possessed          s
## 6   post-separation         obtaining       intimate          degree respondent
## 7             cases             valid      defendant             2nd       make
## 8       preliminary           license           card    constituting   approved
## 9        proceeding restraining_order      specified           found  possesses
## 10 protective_order       immediately         direct          county       form
##         Topics 10
## 1         permits
## 2     safekeeping
## 3    relinquished
## 4  acknowledgment
## 5          permit
## 6         weapons
## 7     defendant's
## 8       sheriff's
## 9       aggrieved
## 10      defendant

The topics don’t seem very exclusive, so I’ll increase K to see if that helps.

# Fit models for K = 12
model_12K <- stm(documents = DFM_STM$documents,
         vocab = DFM_STM$vocab, 
         K = 12,
         verbose = FALSE)
# top features for K = 12
topics_12 <- labelTopics(model_12K, n=10)
topics_12 <- data.frame("features" = t(topics_12$frex))
colnames(topics_12) <- paste("Topics", c(1:12))
topics_12
##             Topics 1   Topics 2         Topics 3  Topics 4         Topics 5
## 1        misdemeanor    adverse           relief  domestic         violence
## 2             orders    abusing         eligible     abuse      transferred
## 3            persons      party             step  physical          divorce
## 4            removal restrained        emergency federally            cases
## 5            however    party's       respondent    police           family
## 6           prohibit   transfer           adults suffering  post-separation
## 7           ex_parte     agency           minors complaint       protective
## 8         protection  federally        qualified      harm protective_order
## 9             relief     dealer       vulnerable    adults       proceeding
## 10 domestic_violence    control protective_order  licensed      preliminary
##        Topics 6       Topics 7        Topics 8   Topics 9      Topics 10
## 1        pistol       duration        personal injunction        chapter
## 2      revolver        partner temporary_order       stay      purchaser
## 3     concealed           foid            obey    hearing         weapon
## 4     dangerous muzzle-loading             3rd          s identification
## 5       license       intimate       possessed       form        located
## 6     obtaining           card          rifles  surrender      belonging
## 7       weapons      defendant        shotguns      adult           duty
## 8         valid      plaintiff          degree respondent          judge
## 9   immediately       credible             2nd  possesses       ex_parte
## 10 commissioner         direct    constituting    sheriff           card
##           Topics 11      Topics 12
## 1           permits            fid
## 2          shipping   relinquished
## 3         ownership    safekeeping
## 4            deadly     prevention
## 5        ammunition        weapons
## 6         receiving acknowledgment
## 7         aggrieved           guns
## 8      transporting          large
## 9         specified          third
## 10 protective_order         rifles

I’m gonna do some more/different pre-processing to see if that helps the topic model.

# Rewind to un-processed corpus, tokenize, and try kwic() for keywords
NewTokens <- tokens(laws_corpus)
kwic(NewTokens, pattern = "remov", valuetype = "regex", window = 2)
## Keyword-in-context with 182 matches.                                                                             
##         [alabama, 210]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##         [alabama, 219]      Require Firearm | Removal  | Alabama law         
##         [alabama, 226]          require the | removal  | of firearms         
##          [alaska, 110]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##          [alaska, 119]      Require Firearm | Removal  | Alaska law          
##          [alaska, 126]          require the | removal  | of firearms         
##          [alaska, 370]                  ] 3 | Removal  | Process A           
##         [arizona, 163]   PROTECTION FIREARM | REMOVAL  | Domestic Violence   
##         [arizona, 173]      Require Firearm | Removal  | If a                
##         [arizona, 224]              for the | removal  | of firearms         
##         [arizona, 408]                  . 5 | Removal  | Process A           
##         [arkansas, 54]   PROTECTION FIREARM | REMOVAL  | Domestic Violence   
##         [arkansas, 64]      Require Firearm | Removal  | Arkansas does       
##         [arkansas, 69]          not require | removal  | of firearms         
##       [california, 98]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##      [california, 107]      Require Firearm | Removal  | Any protective      
##      [california, 137]          require the | removal  | of firearms         
##      [california, 489]                  . 7 | Removal  | Process Upon        
##      [california, 960]       Exemption from | Removal  | Requirement The     
##        [colorado, 103]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##        [colorado, 111]         that Require | Removal  | Colorado requires   
##        [colorado, 308]      include firearm | removal  | only for            
##        [colorado, 344]                  . 8 | Removal  | Process A           
##     [connecticut, 548]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##     [connecticut, 558]         that Require | Removal  | Connecticut requires
##     [connecticut, 561] Connecticut requires | removal  | of firearms         
##     [connecticut, 716]                 . 12 | Removal  | Process A           
##        [delaware, 144]        ORDER FIREARM | REMOVAL  | Civil Protection    
##        [delaware, 152]         that Require | Removal  | Delaware law        
##        [delaware, 161]          firearms be | removed  | from persons        
##        [delaware, 203]        ammunition be | removed  | from the            
##        [delaware, 408]                  " 6 | Removal  | Process A           
##         [florida, 106]   PROTECTION FIREARM | REMOVAL  | DV Civil            
##         [florida, 112]         that Require | Removal  | Florida law         
##         [florida, 119]          require the | removal  | of firearms         
##         [florida, 140]            order the | removal  | of firearms         
##         [florida, 624]       Exemption from | Removal  | Requirement Florida 
##         [florida, 642]      protection from | removal  | of firearms         
##          [georgia, 59]        ORDER FIREARM | REMOVAL  | Civil Family        
##          [georgia, 66]         that Require | Removal  | Georgia does        
##          [georgia, 71]          not require | removal  | of firearms         
##          [hawaii, 185]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##          [hawaii, 196]         that Require | Removal  | Hawaii requires     
##          [hawaii, 199]      Hawaii requires | removal  | of any              
##          [hawaii, 339]               above. | Removal  | Process Hawaii      
##            [idaho, 61]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##            [idaho, 69]         that Require | Removal  | Idaho does          
##            [idaho, 74]          not require | removal  | of firearms         
##        [illinois, 472]   PROTECTION FIREARM | REMOVAL  | Domestic Violence   
##        [illinois, 481]         that Require | Removal  | If the              
##        [illinois, 886]                 " 11 | Removal  | Process If          
##          [indiana, 76]   PROTECTION FIREARM | REMOVAL  | Domestic Violence   
##          [indiana, 85]         that Require | Removal  | Indiana does        
##          [indiana, 90]          not require | removal  | of firearms         
##         [indiana, 299]                  . 5 | Removal  | Process As          
##             [iowa, 83]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##             [iowa, 91]         that Require | Removal  | A court             
##            [iowa, 311]                  " 5 | Removal  | Process A           
##            [iowa, 485]       Exemption from | Removal  | Requirement The     
##          [kansas, 215]        ORDER FIREARM | REMOVAL  | Civil Protection    
##          [kansas, 223]         that Require | Removal  | Kansas does         
##          [kansas, 228]          not require | removal  | of firearms         
##        [kentucky, 119]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##        [kentucky, 127]         that Require | Removal  | Kentucky does       
##        [kentucky, 132]          not require | removal  | of firearms         
##       [louisiana, 220]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##       [louisiana, 228]         that Require | Removal  | Upon the            
##       [louisiana, 814]                 " 12 | Removal  | Process Upon        
##           [maine, 276]        ORDER FIREARM | REMOVAL  | Protection from     
##           [maine, 283]         that Require | Removal  | A court             
##           [maine, 880]                  by: | Removing | that person         
##          [maine, 1035]                 " 11 | Removal  | Process If          
##        [maryland, 320]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##        [maryland, 329]      Require Firearm | Removal  | If a                
##        [maryland, 681]                  . 9 | Removal  | Process A           
##   [massachusetts, 351]        ORDER FIREARM | REMOVAL  | Domestic Abuse      
##   [massachusetts, 358]         that Require | Removal  | A court             
##   [massachusetts, 651]                 . 10 | Removal  | Process If          
##  [massachusetts, 1161]         and licenses | removed  | pursuant to         
##  [massachusetts, 1221]         and licenses | removed  | pursuant to         
##         [michigan, 78]        ORDER FIREARM | REMOVAL  | Civil Personal      
##         [michigan, 85]         that Require | Removal  | Michigan does       
##         [michigan, 90]          not require | removal  | of firearms         
##       [minnesota, 352]        ABUSE FIREARM | REMOVAL  | Orders for          
##       [minnesota, 363]         that Require | Removal  | A court             
##       [minnesota, 385]            order the | removal  | of any              
##       [minnesota, 728]                 . 11 | Removal  | Process A           
##      [minnesota, 1347]               of the | removal  | of firearms         
##      [mississippi, 58]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##      [mississippi, 66]         that Require | Removal  | Mississippi does    
##      [mississippi, 71]          not require | removal  | of firearms         
##         [missouri, 58]   PROTECTION FIREARM | REMOVAL  | Civil Domestic      
##         [missouri, 67]         that Require | Removal  | Missouri does       
##         [missouri, 72]          not require | removal  | of firearms         
##         [montana, 156]   PROTECTION FIREARM | REMOVAL  | Civil Domestic      
##         [montana, 165]         that Require | Removal  | Montana does        
##         [montana, 170]          not require | removal  | of firearms         
##        [nebraska, 109]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##        [nebraska, 117]         that Require | Removal  | Nebraska does       
##        [nebraska, 122]          not require | removal  | of firearms         
##          [nevada, 139]     VIOLENCE FIREARM | REMOVAL  | Civil Orders        
##          [nevada, 150]      Require Firearm | Removal  | Nevada does         
##          [nevada, 155]          not require | removal  | of firearms         
##          [nevada, 349]                  . 7 | Removal  | Process As          
##   [new-hampshire, 137]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##   [new-hampshire, 145]         that Require | Removal  | A judge             
##   [new-hampshire, 157]        shall require | removal  | of any              
##   [new-hampshire, 178]         require such | removal  | when issuing        
##   [new-hampshire, 447]                  " 7 | Removal  | Process A           
##   [new-hampshire, 722]      relinquished or | removed  | pursuant to         
##   [new-hampshire, 810]      relinquished or | removed  | pursuant to         
##      [new-jersey, 322]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##      [new-jersey, 330]         that Require | Removal  | A judge             
##      [new-jersey, 344]            order the | removal  | of firearms         
##      [new-jersey, 377]          require the | removal  | of firearms         
##      [new-jersey, 551]                 " 10 | Removal  | Process A           
##      [new-jersey, 978]             from the | Removal  | Requirement The     
##     [new-jersey, 1054]         surrender or |  remove  | a firearm           
##      [new-mexico, 170]   PROTECTION FIREARM | REMOVAL  | Civil Domestic      
##      [new-mexico, 179]         that Require | Removal  | If a                
##      [new-mexico, 309]          not require | removal  | of firearms         
##      [new-mexico, 532]                  . 7 | Removal  | Process If          
##        [new-york, 261]   PROTECTION FIREARM | REMOVAL  | Domestic Violence   
##        [new-york, 270]         that Require | Removal  | A court             
##        [new-york, 986]                 . 11 | Removal  | Process Where       
##  [north-carolina, 187]       ORDERS FIREARM | REMOVAL  | Civil Domestic      
##  [north-carolina, 195]         that Require | Removal  | Upon the            
##  [north-carolina, 708]                  " 7 | Removal  | Process Upon        
##  [north-carolina, 965]             from the | Removal  | Requirement Law     
##    [north-dakota, 206]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##    [north-dakota, 215]      Require Firearm | Removal  | North Dakota        
##    [north-dakota, 223]          require the | removal  | of firearms         
##    [north-dakota, 429]                  . 4 | Removal  | Process If          
##            [ohio, 103]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##            [ohio, 111]         that Require | Removal  | Ohio does           
##            [ohio, 117]   explicitly require | removal  | of firearms         
##        [oklahoma, 129]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##        [oklahoma, 137]         that Require | Removal  | Oklahoma does       
##        [oklahoma, 142]          not require | removal  | of firearms         
##          [oregon, 330]        ORDER FIREARM | REMOVAL  | Civil Family        
##          [oregon, 340]         that Require | Removal  | Oregon does         
##          [oregon, 345]          not require | removal  | of firearms         
##    [pennsylvania, 170]        ORDER FIREARM | REMOVAL  | Protection from     
##    [pennsylvania, 177]         that Require | Removal  | A court             
##    [pennsylvania, 737]                  " 7 | Removal  | Process The         
##    [rhode-island, 124]        ORDER FIREARM | REMOVAL  | Domestic Abuse      
##    [rhode-island, 134]         that Require | Removal  | A person            
##    [rhode-island, 615]                  . 8 | Removal  | Process A           
##  [south-carolina, 441]   PROTECTION FIREARM | REMOVAL  | Civil Domestic      
##  [south-carolina, 450]         that Require | Removal  | South Carolina      
##  [south-carolina, 456]          not require | removal  | of firearms         
##     [south-dakota, 67]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##     [south-dakota, 76]      Require Firearm | Removal  | South Dakota        
##     [south-dakota, 83]          require the | removal  | of firearms         
##        [tennessee, 99]   PROTECTION FIREARM | REMOVAL  | Domestic Violence   
##       [tennessee, 108]         that Require | Removal  | The respondent      
##       [tennessee, 407]                  " 6 | Removal  | Process An          
##           [texas, 335]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##           [texas, 343]         that Require | Removal  | Texas law           
##           [texas, 349]          not require | removal  | of firearms         
##            [utah, 329]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##            [utah, 337]         that Require | Removal  | Utah law            
##            [utah, 343]          not require | removal  | of firearms         
##         [vermont, 264]        ORDER FIREARM | REMOVAL  | Vermont Abuse       
##         [vermont, 271]         that Require | Removal  | Vermont does        
##         [vermont, 510]                  " 8 | Removal  | Process A           
##        [virginia, 248]        ORDER FIREARM | REMOVAL  | Domestic Violence   
##        [virginia, 256]         that Require | Removal  | The respondent      
##      [washington, 303]        ORDER FIREARM | REMOVAL  | Civil Orders        
##      [washington, 308]         that Require | Removal  | " Any               
##     [washington, 1140]                 . 12 | Removal  | Process A           
##     [washington, 1150]           includes a | removal  | requirement"        
##   [west-virginia, 322]        ORDER FIREARM | REMOVAL  | Civil Domestic      
##   [west-virginia, 331]      Require Firearm | Removal  | If the              
##   [west-virginia, 769]                  ; 9 | Removal  | Process If          
##       [wisconsin, 123]   INJUNCTION FIREARM | REMOVAL  | Civil Domestic      
##       [wisconsin, 130]         that Require | Removal  | A person            
##       [wisconsin, 515]                 . 10 | Removal  | Process If          
##      [wisconsin, 1212]       Exemption from | Removal  | Requirement If      
##          [wyoming, 62]   PROTECTION FIREARM | REMOVAL  | Civil Domestic      
##          [wyoming, 71]         that Require | Removal  | Wyoming law         
##          [wyoming, 78]          require the | removal  | of firearms

I’m realizing that the website has headlines on all states that specify the section to be discussed. Example: “DOMESTIC VIOLENCE FIREARM PROHIBITIONS”. I think the high prevalence of these words are muddying the topic modeling, but I don’t want to remove “firearm” or “domestic violence” from the entire dfm because those are key topics to the dataset/research. Before making all words lowercase, I’ll remove words in all caps, since only headlines are all caps on the site.

all_caps <- unlist(str_match_all(NewTokens, "\\b[A-Z]+\\b"))
## Warning in stri_match_all_regex(string, pattern, omit_no_match = TRUE,
## opts_regex = opts(pattern)): argument is not an atomic vector; coercing
head(all_caps, 30)
##  [1] "ALABAMA"      "DOMESTIC"     "VIOLENCE"     "FIREARM"      "PROHIBITIONS"
##  [6] "ALABAMA"      "CIVIL"        "PROTECTION"   "ORDER"        "FIREARM"     
## [11] "REMOVAL"      "A"            "A"            "A"            "A"           
## [16] "A"            "A"            "A"            "A"            "DOMESTIC"    
## [21] "VIOLENCE"     "FIREARM"      "PROHIBITIONS" "CIVIL"        "PROTECTIVE"  
## [26] "ORDER"        "FIREARM"      "REMOVAL"      "A"            "A"

Great, this will also include list identifiers like “A, B, C”. Now I need to remove these tokens from the new tokens object.

# Create character vector of all caps words, then remove from tokens
all_caps <- as.vector(all_caps)
# English stopwords
ENstopwords <- stopwords(kind = "en")
#CustomStopwords <- ENstopwords[-c(39, 40, 50, 51, 88, 89, 115, 166, 112, 165, 167, 169)]
dfm_states <- c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming', 'new', 'north', 'south', 'dakota', 'york', 'carolina', 'jersey', 'hampshire', 'mexico', 'rhode', 'island', 'west')
extra_words <- c("order", "domestic", "violence")
NewDFM <- tokens(laws_corpus, 
                     remove_punct = TRUE,
                 split_hyphens = TRUE,
                     remove_numbers = TRUE,
                     remove_symbols = TRUE) %>%
  tokens_remove(all_caps) %>%
  tokens_compound(pattern = phrase(c("does not prohibit", "may prohibit", "shall prohibit", "not broadly prohibit", "not explicitly prohibit", "not specifically prohibit", "not require the removal", "require firearm removal", "does not require removal", "that require removal", "removal process", "exemption from removal requirement", "requires removal", "protective order", "restraining order", "temporary order", "temporary order", "order may", "order shall", "shall order", "may order", "law enforcement", "may petition for", "dating relationship", "child in common", "current or former", "domestic violence", "ex parte", "family or household member"))) %>% dfm(tolower = TRUE) %>%
  dfm_remove(c(ENstopwords, dfm_states, extra_words))
NewDFM
## Document-feature matrix of: 50 documents, 1,908 features (90.92% sparse) and 0 docvars.
##             features
## docs         law purchase possession prohibits following individuals owning
##   alabama      5        1          1         2         3           2      1
##   alaska       4        2          4         0         0           1      0
##   arizona      6        1          1         2         1           1      0
##   arkansas     2        1          1         0         2           1      0
##   california   4        2          8         1         4           1      1
##   colorado     3        1          9         1         3           1      0
##             features
## docs         possessing control persons
##   alabama             1       1       4
##   alaska              1       0       4
##   arizona             4       0       7
##   arkansas            1       0       8
##   california          4       3       4
##   colorado            3       6       6
## [ reached max_ndoc ... 44 more documents, reached max_nfeat ... 1,898 more features ]
# Feature Co-Occurrence Matrix for new DFM
fcm_NewDFM <- fcm(NewDFM)
# Pull top features
fcm_NewDFM_feats <- names(topfeatures(fcm_NewDFM, 30))
# Retain top features in fcm
fcm_NewDFM <- fcm_select(fcm_NewDFM, pattern = fcm_NewDFM_feats, selection = "keep")
# compute size weight for vertices in network and create plot
size_NewDFM <- log(colSums(fcm_NewDFM))
textplot_network(fcm_NewDFM, vertex_size = size_NewDFM / max(size_NewDFM) * 3)

I’ll see how STM looks now with the difference pre-processing

# Convert dfm to stm
NewDFM_STM <- convert(NewDFM, to = "stm")

Choosing K - number of topics

# Choosing K - Statistical fit criterion 
# Evaluate K 4 through 15
K <- c(4:15)
fit <- searchK(NewDFM_STM$documents, NewDFM_STM$vocab, K = K, verbose = FALSE)
# Create table with K value and coherence/exclusivity
Kplot <- data.frame("K" = K, 
                   "Coherence" = unlist(fit$results$semcoh),
                   "Exclusivity" = unlist(fit$results$exclus))
# Reshape table to long format
Kplot <- melt(Kplot, id=c("K"))
Kplot
##     K    variable      value
## 1   4   Coherence -24.657889
## 2   5   Coherence -34.312268
## 3   6   Coherence -29.397624
## 4   7   Coherence -33.244255
## 5   8   Coherence -34.637491
## 6   9   Coherence -33.538132
## 7  10   Coherence -37.548675
## 8  11   Coherence -38.804030
## 9  12   Coherence -37.357198
## 10 13   Coherence -38.786731
## 11 14   Coherence -39.301030
## 12 15   Coherence -39.229979
## 13  4 Exclusivity   7.813171
## 14  5 Exclusivity   8.194956
## 15  6 Exclusivity   8.353633
## 16  7 Exclusivity   8.580573
## 17  8 Exclusivity   8.651512
## 18  9 Exclusivity   8.776054
## 19 10 Exclusivity   8.866539
## 20 11 Exclusivity   8.954273
## 21 12 Exclusivity   9.023425
## 22 13 Exclusivity   9.079230
## 23 14 Exclusivity   9.134980
## 24 15 Exclusivity   9.186494
#Plot results of K statistical testing
ggplot(Kplot, aes(K, value, color = variable)) +
  geom_line(size = 1.5, show.legend = FALSE) +
  facet_wrap(~variable,scales = "free_y") +
  labs(x = "Number of topics K",
       title = "Statistical fit of models with different K")

Let’s try K = 4, 7, 9 to start:

# Fit models for K = 6 and K = 10
model_6 <- stm(documents = NewDFM_STM$documents,
         vocab = NewDFM_STM$vocab, 
         K = 6,
         verbose = FALSE)
model_7 <- stm(documents = NewDFM_STM$documents,
         vocab = NewDFM_STM$vocab, 
         K = 7,
         verbose = FALSE)
model_9 <- stm(documents = NewDFM_STM$documents,
         vocab = NewDFM_STM$vocab, 
         K = 9,
         verbose = FALSE)
# Evaluate interpretability and relevance 
# for K = 6
topics_6 <- labelTopics(model_6, n=10)
topics_6 <- data.frame("features" = t(topics_6$frex))
colnames(topics_6) <- paste("Topics", c(1:6))
topics_6 
##             Topics 1   Topics 2    Topics 3       Topics 4  Topics 5
## 1           ex_parte    adverse      minors      defendant  revolver
## 2  does_not_prohibit restrained   possessed acknowledgment    pistol
## 3              final    abusing  respondent        loading   machine
## 4             relief      party    approved         muzzle      guns
## 5            persons    party's     hearing    defendant's concealed
## 6            chapter   transfer surrendered        sheriff   license
## 7          currently  federally       owned   relinquished   permits
## 8       imprisonment     agency      adults        weapons     large
## 9            however    control        obey     separation     carry
## 10       misdemeanor   licensee     brother    safekeeping dangerous
##        Topics 6
## 1     qualified
## 2       partner
## 3      intimate
## 4  transporting
## 5      shipping
## 6        spouse
## 7         force
## 8         child
## 9        bodily
## 10    knowingly
labelTopics(model_6, n=5)
## Topic 1 Top Words:
##       Highest Prob: persons, may, person, firearms, ammunition 
##       FREX: ex_parte, does_not_prohibit, final, relief, persons 
##       Lift: directives, impose, punished, vulnerable, 4th 
##       Score: chapter, 4th, punished, vulnerable, does_not_prohibit 
## Topic 2 Top Words:
##       Highest Prob: party, firearms, possession, shall, law_enforcement 
##       FREX: adverse, restrained, abusing, party, party's 
##       Lift: automatic, best, bureau, elects, interests 
##       Score: adverse, abusing, restrained, licensee, party's 
## Topic 3 Top Words:
##       Highest Prob: respondent, firearms, shall, may, person 
##       FREX: minors, possessed, respondent, approved, hearing 
##       Lift: 2nd, constituting, satisfied, 3rd, appeals 
##       Score: respondent, minors, obey, stay, adults 
## Topic 4 Top Words:
##       Highest Prob: firearms, defendant, shall, weapons, ammunition 
##       FREX: defendant, acknowledgment, loading, muzzle, defendant's 
##       Lift: 22within, able, acknowledgement, acknowledgment, advise 
##       Score: defendant, acknowledgment, relinquished, transferred, separation 
## Topic 5 Top Words:
##       Highest Prob: firearms, person, pistol, surrender, ammunition 
##       FREX: revolver, pistol, machine, guns, concealed 
##       Lift: accessing, aggrieved, allows, blind, borrow 
##       Score: pistol, revolver, machine, guns, large 
## Topic 6 Top Words:
##       Highest Prob: person, persons, child, respondent, household 
##       FREX: qualified, partner, intimate, transporting, shipping 
##       Lift: high, preceding, prevent, regard, adjudicated 
##       Score: shipping, preliminary, high, card, prevent
# Evaluate interpretability and relevance 
# for K = 7
topics_7 <- labelTopics(model_7, n=10)
topics_7 <- data.frame("features" = t(topics_7$frex))
colnames(topics_7) <- paste("Topics", c(1:7))
topics_7
##             Topics 1   Topics 2    Topics 3       Topics 4  Topics 5
## 1           ex_parte    adverse  respondent        loading  revolver
## 2            persons restrained     hearing         muzzle    pistol
## 3  does_not_prohibit    abusing   possessed    defendant's   machine
## 4              final      party surrendered      defendant      guns
## 5             relief    party's        obey    safekeeping concealed
## 6        misdemeanor   transfer      minors        weapons   license
## 7            chapter    control       owned   relinquished   permits
## 8            spouses     agency      adults acknowledgment     carry
## 9          currently  federally   possesses         deadly     large
## 10      imprisonment   licensee         3rd        address dangerous
##        Topics 6    Topics 7
## 1     qualified  separation
## 2      intimate     divorce
## 3       partner  proceeding
## 4  transporting  imprisoned
## 5         force        post
## 6        spouse transferred
## 7      shipping     storage
## 8         child     sheriff
## 9        dating     battery
## 10    household       fined
# Evaluate interpretability and relevance 
# for K = 9
topics_9 <- labelTopics(model_9, n=10)
topics_9 <- data.frame("features" = t(topics_9$frex))
colnames(topics_9) <- paste("Topics", c(1:9))
topics_9
##               Topics 1   Topics 2    Topics 3  Topics 4     Topics 5
## 1          misdemeanor    adverse  respondent defendant       pistol
## 2              persons    abusing   possessed   loading     revolver
## 3    does_not_prohibit restrained     hearing    muzzle    dangerous
## 4               victim      party      minors    deadly    concealed
## 5              spouses    party's      adults qualified      license
## 6            currently   transfer surrendered purchaser    obtaining
## 7              however     agency       owned      step     prohibit
## 8            necessary     dealer        obey plaintiff        valid
## 9  dating_relationship  federally   possesses     judge commissioner
## 10            formerly    control   surrender     place      weapons
##        Topics 6    Topics 7     Topics 8   Topics 9
## 1      shipping  separation         guns     spouse
## 2  transporting     divorce        large   ex_parte
## 3          card  proceeding      permits    chapter
## 4   preliminary transferred      machine      final
## 5          high  imprisoned relinquished     relief
## 6      intimate        post  safekeeping respondent
## 7     receiving       fined      weapons   eligible
## 8       prevent     battery       rifles     parent
## 9        regard     sheriff     shotguns  temporary
## 10      similar        less    aggrieved   contempt
labelTopics(model_9, n=5)
## Topic 1 Top Words:
##       Highest Prob: persons, may, ammunition, firearms, person 
##       FREX: misdemeanor, persons, does_not_prohibit, victim, spouses 
##       Lift: punished, 4th, accorded, activity, administer 
##       Score: 4th, punished, does_not_prohibit, currently, formerly 
## Topic 2 Top Words:
##       Highest Prob: party, firearms, possession, shall, law_enforcement 
##       FREX: adverse, abusing, restrained, party, party's 
##       Lift: 13within, 3and, acknowledge, adjudications, advisement 
##       Score: adverse, restrained, abusing, party's, licensee 
## Topic 3 Top Words:
##       Highest Prob: respondent, firearms, shall, may, surrender 
##       FREX: respondent, possessed, hearing, minors, adults 
##       Lift: 2nd, cal, constituting, done, fam 
##       Score: minors, computed, obey, stay, respondent 
## Topic 4 Top Words:
##       Highest Prob: defendant, firearms, person, shall, may 
##       FREX: defendant, loading, muzzle, deadly, qualified 
##       Lift: bow, bows, crossbow, crossbows, loading 
##       Score: loading, muzzle, defendant, purchaser, four 
## Topic 5 Top Words:
##       Highest Prob: pistol, person, firearms, dangerous, weapons 
##       FREX: pistol, revolver, dangerous, concealed, license 
##       Lift: accessing, certificate, acceptance, allows, amount 
##       Score: pistol, revolver, concealed, obtaining, dangerous 
## Topic 6 Top Words:
##       Highest Prob: person, persons, respondent, household, ammunition 
##       FREX: shipping, transporting, card, preliminary, high 
##       Lift: high, plenary, prevent, regard, aged 
##       Score: shipping, card, transporting, preliminary, apparent 
## Topic 7 Top Words:
##       Highest Prob: firearms, shall, person, sheriff, transferred 
##       FREX: separation, divorce, proceeding, transferred, imprisoned 
##       Lift: benefit, hard, labor, negligent, parish 
##       Score: separation, sheriff, proceeding, individual's, transferred 
## Topic 8 Top Words:
##       Highest Prob: firearms, ammunition, weapons, defendant, shall 
##       FREX: guns, large, permits, machine, relinquished 
##       Lift: acknowledgement, armory, birth, commercial, devices 
##       Score: guns, large, sheriff, machine, permits 
## Topic 9 Top Words:
##       Highest Prob: respondent, person, may, persons, final 
##       FREX: spouse, ex_parte, chapter, final, relief 
##       Lift: vulnerable, abusive, adjudicated, alternatively, answer 
##       Score: chapter, constable, vulnerable, spouse, respondents
# Fit models for K = 15
model_15 <- stm(documents = NewDFM_STM$documents,
         vocab = NewDFM_STM$vocab, 
         K = 15,
         verbose = FALSE)
topics_15 <- labelTopics(model_15, n=10)
topics_15 <- data.frame("features" = t(topics_15$frex))
colnames(topics_15) <- paste("Topics", c(1:15))
topics_15
##       Topics 1   Topics 2   Topics 3  Topics 4     Topics 5     Topics 6
## 1      persons    adverse     minors    deadly     revolver transporting
## 2  misdemeanor restrained       obey specified       pistol     shipping
## 3    currently      party     adults defendant    dangerous  preliminary
## 4     ex_parte    party's  possessed complaint    concealed    receiving
## 5    including    receipt respondent suffering    obtaining    qualified
## 6    necessary    control        3rd plaintiff      license       commit
## 7   purchasing   licensee       stay ownership     prohibit      similar
## 8     children   extended      owned  evidence commissioner     specific
## 9        using    custody  surrender     peace        valid   prohibited
## 10  petitioner     agency        2nd   weapons  immediately      prevent
##       Topics 7  Topics 8    Topics 9   Topics 10 Topics 11      Topics 12
## 1   separation      guns     chapter     partner household      purchaser
## 2      divorce   permits    eligible     loading      harm identification
## 3   imprisoned     large       final      muzzle     adult        located
## 4   proceeding   machine      relief    intimate    member      belonging
## 5  transferred     carry      spouse        step  physical         weapon
## 6         post    rifles  vulnerable   qualified   parents           duty
## 7      sheriff  shotguns  respondent        risk    victim           card
## 8      battery aggrieved     alleged  individual  ex_parte          judge
## 9        fined  capacity   temporary grandparent   married       actually
## 10        less   feeding respondents        aunt    living          armed
##       Topics 13         Topics 14      Topics 15
## 1     federally            living        abusing
## 2        dealer            dating          third
## 3      licensed        committing    safekeeping
## 4    relinquish              acts acknowledgment
## 5        unable          together          party
## 6        agency            nature   relinquished
## 7    respondent does_not_prohibit    defendant's
## 8    background         emergency      affidavit
## 9  relinquished           spouses        weapons
## 10    statement            relief      sheriff's
labelTopics(model_15, n=5)
## Topic 1 Top Words:
##       Highest Prob: persons, may, ammunition, firearms, possession 
##       FREX: persons, misdemeanor, currently, ex_parte, including 
##       Lift: 4th, administer, adopt, allowed, beneficiaries 
##       Score: 4th, currently, ex_parte, directives, chief 
## Topic 2 Top Words:
##       Highest Prob: party, restrained, adverse, possession, firearms 
##       FREX: adverse, restrained, party, party's, receipt 
##       Lift: 13within, advisement, appointed, arising, category 
##       Score: adverse, restrained, party, licensee, extended 
## Topic 3 Top Words:
##       Highest Prob: respondent, firearms, surrender, person, may 
##       FREX: minors, obey, adults, possessed, respondent 
##       Lift: 2nd, constituting, 16the, 1or, 1st 
##       Score: sheriff, obey, minors, stay, respondent 
## Topic 4 Top Words:
##       Highest Prob: defendant, firearms, person, ammunition, shall 
##       FREX: deadly, specified, defendant, complaint, suffering 
##       Lift: amilies, arraignment, arrests, attest, attestation 
##       Score: deadly, defendant, four, suffering, complaint 
## Topic 5 Top Words:
##       Highest Prob: pistol, person, dangerous, weapons, firearms 
##       FREX: revolver, pistol, dangerous, concealed, obtaining 
##       Lift: barrel, blind, certificate, confirmation, disabled 
##       Score: pistol, revolver, dangerous, concealed, license 
## Topic 6 Top Words:
##       Highest Prob: ammunition, persons, person, possessing, transporting 
##       FREX: transporting, shipping, preliminary, receiving, qualified 
##       Lift: apparent, applied, associations, brothers, clause 
##       Score: shipping, transporting, preliminary, apparent, specific 
## Topic 7 Top Words:
##       Highest Prob: firearms, shall, sheriff, person, transferred 
##       FREX: separation, divorce, imprisoned, proceeding, transferred 
##       Lift: negligent, advise, affectionate, agreed, asks 
##       Score: sheriff, separation, transferred, proceeding, divorce 
## Topic 8 Top Words:
##       Highest Prob: firearms, ammunition, shall, subject, carry 
##       FREX: guns, permits, large, machine, carry 
##       Lift: devices, enables, feeding, large, academy 
##       Score: guns, large, machine, permits, rifles 
## Topic 9 Top Words:
##       Highest Prob: respondent, persons, may, final, person 
##       FREX: chapter, eligible, final, relief, spouse 
##       Lift: vulnerable, abusive, alternatively, answer, arrested 
##       Score: chapter, constable, vulnerable, respondent, respondents 
## Topic 10 Top Words:
##       Highest Prob: person, firearms, respondent, child, law 
##       FREX: partner, loading, muzzle, intimate, step 
##       Lift: abstain, aged, annulment, appeals, assistants 
##       Score: loading, muzzle, card, partner, bow 
## Topic 11 Top Words:
##       Highest Prob: persons, household, person, member, may 
##       FREX: household, harm, adult, member, physical 
##       Lift: regard, activity, adoptive, applicant's, boldface 
##       Score: activity, regard, punished, adult, living 
## Topic 12 Top Words:
##       Highest Prob: weapon, defendant, shall, firearms, person 
##       FREX: purchaser, identification, located, belonging, weapon 
##       Lift: scene, accompany, anticipates, antique, appropriately 
##       Score: purchaser, identification, anticipates, card, located 
## Topic 13 Top Words:
##       Highest Prob: respondent, firearms, ammunition, may, shall 
##       FREX: federally, dealer, licensed, relinquish, unable 
##       Lift: amendment, analogous, applies, approval, assertion 
##       Score: dealer, relinquish, analogous, licensed, federally 
## Topic 14 Top Words:
##       Highest Prob: persons, may, person, firearms, ammunition 
##       FREX: living, dating, committing, acts, together 
##       Lift: accorded, affection, anyone, assistance, authorize 
##       Score: anyone, unmarried, living, committing, nature 
## Topic 15 Top Words:
##       Highest Prob: firearms, party, ammunition, third, weapons 
##       FREX: abusing, third, safekeeping, acknowledgment, party 
##       Lift: acknowledgement, armory, birth, commercial, accepts 
##       Score: abusing, third, sheriff, party, acknowledgment
# make a document-topic-matrix
# topic association by state (gamma)
gamma <- tidy(model_6, matrix = "gamma") %>%
  pivot_wider(names_from = topic, values_from = gamma)
gamma$state <- c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming')
gamma <- gamma[, c('document', 'state', '1', '2', '3', '4', '5', '6')]
gamma
## # A tibble: 50 x 8
##    document state           `1`      `2`      `3`      `4`      `5`      `6`
##       <int> <chr>         <dbl>    <dbl>    <dbl>    <dbl>    <dbl>    <dbl>
##  1        1 alabama     0.359   0.00184  0.00213  0.0244   0.00330  0.609   
##  2        2 alaska      0.326   0.00178  0.662    0.00258  0.00112  0.00602 
##  3        3 arizona     0.500   0.00387  0.222    0.192    0.00296  0.0791  
##  4        4 arkansas    0.989   0.00132  0.00160  0.00172  0.00164  0.00477 
##  5        5 california  0.00257 0.000931 0.994    0.000842 0.000235 0.00102 
##  6        6 colorado    0.00342 0.992    0.00111  0.000591 0.00100  0.00159 
##  7        7 connecticut 0.00271 0.000809 0.000180 0.000682 0.995    0.000539
##  8        8 delaware    0.00279 0.000710 0.994    0.00116  0.000203 0.00104 
##  9        9 florida     0.994   0.000658 0.000754 0.000867 0.000912 0.00288 
## 10       10 georgia     0.990   0.00118  0.00147  0.00161  0.00152  0.00451 
## # ... with 40 more rows
# Plot topic association (gamma) for each state
gamma1 <- gamma %>%
  pivot_longer(c('1', '2', '3', '4', '5', '6'), names_to = "topic", values_to = "gamma") 
gamma1 %>% 
  ggplot(aes(factor(topic), gamma)) +
  geom_boxplot() +
  facet_wrap(~ state) +
  labs(x = "topic", y = expression(gamma))

# make a document-topic-matrix
# topic association by state (gamma)
gamma <- tidy(model_15, matrix = "gamma") %>%
  pivot_wider(names_from = topic, values_from = gamma)
gamma$state <- c('alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi', 'missouri', 'montana', 'nebraska', 'nevada', 'new-hampshire', 'new-jersey', 'new-mexico', 'new-york', 'north-carolina', 'north-dakota', 'ohio', 'oklahoma', 'oregon', 'pennsylvania', 'rhode-island', 'south-carolina', 'south-dakota', 'tennessee', 'texas', 'utah', 'vermont', 'virginia', 'washington', 'west-virginia', 'wisconsin', 'wyoming')
gamma <- gamma[, c('document', 'state', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15')]
gamma
## # A tibble: 50 x 17
##    document state            `1`     `2`     `3`     `4`     `5`     `6`     `7`
##       <int> <chr>          <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
##  1        1 alabama     0.244    7.31e-4 6.44e-4 2.18e-3 2.87e-4 5.07e-4 2.95e-4
##  2        2 alaska      0.332    4.67e-4 6.54e-1 1.67e-3 3.91e-4 7.49e-4 5.63e-4
##  3        3 arizona     0.350    1.50e-3 1.07e-3 2.44e-1 4.36e-4 8.09e-4 3.86e-4
##  4        4 arkansas    0.984    3.60e-4 2.21e-3 1.82e-3 2.47e-4 3.52e-4 6.50e-4
##  5        5 california  0.000615 2.30e-4 2.68e-4 3.62e-4 1.54e-4 2.64e-4 8.42e-5
##  6        6 colorado    0.000780 2.54e-4 2.55e-4 3.91e-4 1.56e-4 3.04e-4 1.02e-4
##  7        7 connecticut 0.00115  9.73e-4 1.89e-4 1.18e-4 9.96e-1 2.46e-4 9.70e-5
##  8        8 delaware    0.000634 1.65e-4 2.24e-4 3.28e-4 1.18e-4 2.49e-4 8.08e-5
##  9        9 florida     0.00192  3.18e-4 3.05e-4 8.38e-5 9.72e-5 4.00e-4 1.08e-4
## 10       10 georgia     0.982    3.94e-4 2.17e-3 1.92e-3 2.51e-4 3.92e-4 6.88e-4
## # ... with 40 more rows, and 8 more variables: `8` <dbl>, `9` <dbl>,
## #   `10` <dbl>, `11` <dbl>, `12` <dbl>, `13` <dbl>, `14` <dbl>, `15` <dbl>
# Plot topic association (gamma) for each state
gamma1 <- gamma %>%
  pivot_longer(c('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'), names_to = "topic", values_to = "gamma") 
gamma1 %>% 
  ggplot(aes(factor(topic), gamma)) +
  geom_boxplot() +
  facet_wrap(~ state, ncol = 6) +
  labs(x = "topic", y = expression(gamma))