datalorax / equatiomatic

Convert models to LaTeX equations
https://datalorax.github.io/equatiomatic/
Creative Commons Attribution 4.0 International
617 stars 43 forks source link

Indices to variables #108

Open ChristophHanck opened 4 years ago

ChristophHanck commented 4 years ago

Great initiative!

Often, regression equations are reported so as to indicate the dimensions over which variables vary, like in (LaTeX) $$ y_i=\beta_0+\beta_1x_i+u_i, $$ typically for cross-sectional data, $$ y_t=\beta_0+\beta_1x_t+ut, $$ for time series models and something like $$ y{it}=\beta_{0,i}+\beta1x{it}+u_{it} $$ for panel data models. Could that be incorporated as an option?

datalorax commented 4 years ago

Hi, thanks for your interest! Yes, I think that could be incorporated pretty easily. I have a few other things I'm working on that are a little higher priority for me, but I will circle back to this when I have the time. I'd also welcome a PR if you feel up for that.

datalorax commented 3 years ago

Hi - circling back to this (about a year later). Can you possibly expand on this a bit? Apparently it made sense to me when you opened this issue but now that I'm revisiting it I'm not actually sure what's being requested. We now support mixed effects models, which vary randomly. But I'm thinking this is something different?

ChristophHanck commented 3 years ago

Yes, something like this, so data varying over more than one dimension and the two (possibly more, although that is more rare in practice) indices to the variables reflecting that. Personally, I though of the plm package (https://cran.r-project.org/web/packages/plm/vignettes/A_plmPackage.html), but there are others around that have similar functionality.

datalorax commented 3 years ago

Could you possibly provide an example model along with what you would expect the output to look like?

ChristophHanck commented 3 years ago
library(plm)
library(equatiomatic)

data("Grunfeld", package="plm")
grun.fe <- plm(inv~value+capital, data = Grunfeld, model = "within")

might yield something like

$$ inv_{it}=\hat{\alpha}_i+\hat{\beta}1value{it}+\hat{\beta}2capital{it} $$ (not sure why the subindices do not work in the output next to the betas and value and capital)

datalorax commented 3 years ago

Thanks, so it sounds like this is really about supporting a new model type.