Skip to content

Instantly share code, notes, and snippets.

@mayormaier
Last active December 11, 2022 20:28
Show Gist options
  • Save mayormaier/30ef9ca7bd81b0938211a544c8458b70 to your computer and use it in GitHub Desktop.
Save mayormaier/30ef9ca7bd81b0938211a544c8458b70 to your computer and use it in GitHub Desktop.
Unlabeled Log Linear Analysis
# Get the data and factor it as needed
data = data.frame()
# Create contingency tables
data.table = xtabs(~A + B + C, data=data)
# Create models
library(MASS)
model.0 = loglm(~A + B + C + A:B + A:C + B:C + A:B:C, data = table.phishingABC, fit=TRUE)
model.1 = loglm(~A + B + C + A:B + A:C + B:C, data = table.phishingABC, fit=TRUE)
model.2 = loglm(~A + B + C + A:B + A:C, data = table.phishingABC, fit=TRUE)
model.3 = loglm(~A + B + C + A:B + B:C, data = table.phishingABC, fit=TRUE)
model.4 = loglm(~A + B + C + A:C + B:C, data = table.phishingABC, fit=TRUE)
model.5 = loglm(~A + B + A:B, data = table.phishingABC, fit=TRUE)
model.6 = loglm(~A + C + A:C, data = table.phishingABC, fit=TRUE)
model.7 = loglm(~B + C + B:C, data = table.phishingABC, fit=TRUE)
model.8 = loglm(~A + B + C, data = table.phishingABC, fit=TRUE)
#Determine which model you like the best
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment