Skip to content

adelrtan/maxent.ot

 
 

Repository files navigation

maxent.ot

This package allows you to fit Maximum Entropy Optimality Theory models to data sets, generate the predictions made by such models for novel data, and compare the fit of different models using a variety of metrics. This package is still in development, and is being prepared for submission to CRAN.

The authors of this package are Connor Mayer, Kie Zuraw, and Adeline Tan.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("connormayer/maxent.ot")

Example

This is a simple example workflow of fitting two MaxEnt OT models to the same data (with different constraint sets), examining their predicted frequencies, and comparing their fits using the likelihood ratio test.

library(maxent.ot)

# Get paths to input files.
# This file has two constraints
data_file_simple <- system.file(
   "extdata", "sample_data_file_small.txt", package = "maxent.ot"
)
# This file has three constraints
data_file_complex <- system.file(
   "extdata", "sample_data_file_large.txt", package = "maxent.ot"
)

# Fit weights to both data sets with simple regularization
simple_model <- optimize_weights(data_file_simple, mu_scalar=0, sigma_scalar=10)
complex_model <- optimize_weights(data_file_complex, mu_scalar=0, sigma_scalar=10)

# Examine predicted probabilities of each model
simple_predictions <- predict_probabilities(data_file_simple, simple_model$weights)
complex_predictions <- predict_probabilities(data_file_complex, complex_model$weights)

# Compare model fit to training data using the likelihood ratio test
compare_models(simple_model, complex_model, method='lrt')
#>                                     description   chi_sq k_delta   p_value
#> 1 sample_data_file_large~sample_data_file_small 1.269594       1 0.2598428

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 93.6%
  • R 6.4%