Zheng Zhang

Penn State 2020er, Computing Statistics & Data Sciences

rmodel2tex

R Package that Converts Various R Models to Latex Syntax

Link to Project

Idea

The idea comes from the final project of my regression class (STAT 462), where our dataset contains more than 60 predictors, and we have to fit 24 of them to the regression model. When completing the presentation as well as the report, we felt it was so annoying and boring for translating the model to latex code by hand because we did so much typing, copying, and pasting. Therefore, I developed this simple r package afterward to do all the work by one line of simple code.

Current Development Objective

  • Create the function for converting the logistic regression and robust regression to latex syntax.
  • Add some simple examples for demo purposes.

Features

Linear Model:

  • Treat the normal, categorical predictors and interaction differently.

Installing

If you’re using r studio, follow the code below to install this package.

install.packages("devtools")
library(devtools)
devtools::install_github("SecantZhang/rmodel2tex")
library(rmodel2tex)

Current Supported Model

Name Description Primary Function Code in this package
Linear Models Linear regression lm( ) lm2tex(model, type, round_num)
Logistic Regression Model Logistic Regression glm( ) glm2tex(glm_model, glm_type, glm_form, glm_round_num)

Simple Documentation and Examples

For linear model:

lm2tex(model, type, round_num)

  • model: The model generated by lm() function.
  • type: Whether you want the latex syntax for population model, fitted model or both.
    • “fit”: Fitted model
    • “pop”: Population model
    • “both”: Both fitted and population model.
  • round_num: Number of siginificant digits for the predictor coefficients.