knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of xmerit
is to facility teaching and researching on Econometrics.
You can install the development version of xmerit from GitHub with:
# install.packages("devtools") devtools::install_github("huhuaping/xmerit")
This is a basic example which shows you how to show math equation (LaTex
equation) easily in Rmarkdown Writing.
library(xmerit) data(mtcars) ## basic example code df <- mtcars mod <- mpg ~ cyl + disp + wt +gear xvars <- all.vars(mod)[-1] yvars <- all.vars(mod)[1] lm.fit <- lm(formula = mod, data = df) summary(lm.fit)
Here we will show the use of function xmerit::lx.psm()
.
#| results = 'asis', #| echo = TRUE, #| eval = FALSE lx.out <- xmerit::lx.psm( x = xvars, y = yvars, begin = 0, #greek.n = length(xvars)+1, n.row = 3, lm.label = "lx-psm", lm.tag = "lx.psm", no_dollar = FALSE)
$$\begin{align} \begin{split} mpg_i=&+\beta_{0}+\beta_{1}cyl_i+\beta_{2}disp_i\\&+\beta_{3}wt_i+\beta_{4}gear_i+u_i \end{split} \quad \text{(lx.psm)}\quad (\#eq:lx-psm) \end{align}$$ The cross-reffer syntax of `see \@ref(eq:lx-psm)` will be rendered as see \@ref(eq:lx-psm).
$$\begin{align} \begin{split} mpg_i=&+\beta_{0}+\beta_{1}cyl_i+\beta_{2}disp_i\&+\beta_{3}wt_i+\beta_{4}gear_i+u_i \end{split} \quad \text{(lx.psm)}\quad (#eq:lx-psm) \end{align}$$
The cross-reference syntax of see \@ref(eq:lx-psm)
will be rendered as see \@ref(eq:lx-psm).
Now let me show the use of function xmerit::lx.est()
.
#| results = 'asis', #| echo = TRUE, #| eval = FALSE lx.out <- xmerit::lx.est( lm.mod = mod, lm.dt = df, lm.n = 3, lm.label = "lx-est", lm.tag = "lx.est", no_dollar = FALSE)
$$\begin{equation} \begin{alignedat}{999} &\widehat{mpg}=&&+43.54&&-1.78cyl_i&&+0.01disp_i\\ &(s)&&(4.8601)&&(0.6139)&&(0.0120)\\ &(t)&&(+8.96)&&(-2.91)&&(+0.58)\\ &(cont.)&&-3.79wt_i&&-0.49gear_i &&\\ &(s)&&(1.0818)&&(0.7903) &&\\ &(t)&&(-3.51)&&(-0.62) && \end{alignedat} \quad \text{(lx.est)}\quad (\#eq:lx-est) \end{equation}$$ The cross-reference syntax of `see \@ref(eq:lx-est)` will be rendered as see \@ref(eq:lx-est).
$$\begin{equation} \begin{alignedat}{999} &\widehat{mpg}=&&+43.54&&-1.78cyl_i&&+0.01disp_i\ &(s)&&(4.8601)&&(0.6139)&&(0.0120)\ &(t)&&(+8.96)&&(-2.91)&&(+0.58)\ &(cont.)&&-3.79wt_i&&-0.49gear_i &&\ &(s)&&(1.0818)&&(0.7903) &&\ &(t)&&(-3.51)&&(-0.62) && \end{alignedat} \quad \text{(lx.est)}\quad (#eq:lx-est) \end{equation}$$
The cross-reference syntax of see \@ref(eq:lx-est)
will be rendered as see \@ref(eq:lx-est).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.