Print equation of linear regression model using RMarkdown - r-markdown

I currently have some rather long inline code for producing an equation of just a simple linear regression:
lm(var1 ~ var2 + var3)
But I could have sworn at some point recently I saw some very succinct inline code to produce an equation of that model, but I seem to not have saved it. Any ideas?

(sorry, I found it, using the equatiomatic package)

You don’t need need a package for inline equations. Just put you equation in Rmarkdown between 2 $, example below
$lm(var1 ~ var2 + var3)$
which looks like this rendered in Rmarkdown

Related

EViews: How to estimate by OLS a more complex regression model?

For example I estimated by OLS the following model:
using an Eviews program file with code:
equation e1.ls log(cons) c log(sw) log(nsw) log(inc)
However, I have to now estimate this model:
But I am not sure how to go about writing the code. I tried typing:
equation e1.ls log(costs|kwh,pl,pk,pf) c log(kwh) log(pl) log(pk) log(pf) (log(kwh))^2
However, the first and last terms do not work and I'm not sure how to do it. I would appreciate any help, thank you!
EViews allows you to put the regression in equation form, as in
equation e1.ls log(costs)= c(1)*log(kwh)+ c(2)*log(pl)+ c(3)*log(pk) + c(4)*log(pf) + c(5)*(log(kwh))^2
but costs|kwh,pl,pk,pf doesn't mean anything in EViews.

Include begin{document}, end{document} in LaTeX tables code generated in Stata

While using estpost/esttab/esttab in Stata to generate LaTeX tables, latex initialization syntax such as documentclass{}, begin{document}, and end{document} are never included. This means that every LaTeX code generated needs for these to be added.
I have many many tables to create. Is it possible to include these through Stata itself?
There are two potential solutions, the first is to include these using the prehead and postfoot options, which allow you to do this directly, but make table formatting a bit more difficult. Or there is the option to simply use include{asdf.tex} in another file.
Solution 1 example:
sysuse auto, clear
reg price mpg
esttab using "temp.tex", ///
prehead("\documentclass{article}\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{document}\begin{tabular}{l*{1}{c}}") ///
postfoot("\end{tabular}\end{document}") ///
replace
This will make a basic table, but doing things like including a title become more difficult with this option.
Second solution, in a tex file, you can include any number of tables thusly:
\documentclass{article}
\begin{document}
\input{any_tex_file.tex}
\input{any_tex_file2.tex}
\end{document}
and in this way you can include all of your tables.
Hope this helps
A better solution could be including this command into your stata esttab output commands
booktabs page(column)

How can I create spline function variables in Stata by hand?

I know there is, in Stata, a command called mkspline that generates cubic spline function. But I want to replicate my Stata output using other software, so I need to learn how to create these spline function variables.
If, say, I use a syntax like this :
mkspline age3sp = age, cubic knots(-13 -7 0 8 16)
How would you do it by hand ?
I would read the Stata documentation for mkspline (see http://www.stata.com/manuals14/rmkspline.pdf for an online copy of the version included with Stata 14) and follow the guidance in the Methods and formulas section.

Use proc glimmix for binomial response-Model statement

Usually we use the following statement
model y/n = block variety / dist=binomial solution;
However, if I have already calculate proprtion=y/n by EXCEL and directly use "proportion" into SAS. i.e
model proportion = block variety /dist=binomial solution;
I get the same result.
However, is there anything wrong with my second code?
You are suppose to get the same result as you have said too. So it is not clear what went wrong with your code!

how to make tables out for Spearman correlation table? [duplicate]

This question already has an answer here:
How to export Spearman correlations
(1 answer)
Closed 3 years ago.
I need to get a Spearman and Pearson correlation table using Stata. Here is what I did to get the results in a table format.
estpost correlate sp_rating srating mrating split split_neg split_ord split_neg_ord tier1_risk tier1_leverage st1 sl mt1 ml adt1 adl dt1 dl offering_amt maturity2 security
enhance timeliness validity disc loan_at cash_dep trading_at real_est intangible other_at sec_sum assets_sold all_residual secinc_ta, matrix quietly
esttab . using "root4.rtf", replace notype unstack compress noobs nogaps nostar
Then, I get this error message:
varlist not allowed
When I used just a few variables, I didn't get the error, but when I put many variables. I don't know how to fix this. Please help me.
I was able to reproduce your error and ran a trace on it. I believe this is a bug at line 946 of estout.ado, perhaps caused by the fact that a very long variable list with RTF tags exceeds the size of the local macro created at that line.
You should send a bug report to Ben Jann (email at the end of help estout). In the meantime, you can try saving to DOC and TXT, both of them might work (you have over 30 variables, I tested both .txt and .doc successfully with something like 20 variables).
Alternately, try the mkcorr command (ssc install mkcorr) to see if it works with your data.
I just had the same problem after I tried a lot of different esttab outputs and had stored a lot in estimates.
So, maybe estimates clear helps if you type it before running your command. At least for me it worked.