Quantcast
Channel: R-bloggers
Viewing all articles
Browse latest Browse all 12081

glueformula: simply build regression formulas from vectors with variable names

$
0
0

[This article was first published on Economics and R - R posts, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The small new package glueformula with a single function gf facilitates constructing regression formulas from vectors with variable names. The syntax is similar to glue strings. Here is an example:

# Example: build a formula# for ivreg with gflibrary(glueformula)# Contol variables and instrumentscontr=c("x1","x2","x3","log(x4)")instr=c("z1","z2",contr)# Create formula for ivreggf(q~p+{contr}|{instr})
## q ~ p + x1 + x2 + x3 + log(x4) | z1 + z2 + x1 + x2 + x3 + log(x4)

There is no big benefit if one wants to estimate a single regression, but in econometrics one often specifies a lot of similar regressions (for robustness checks not p-hacking!) that share a large set of common control variables. Here glueformula can be handy.

You can install it from Github as explained here: https://github.com/skranz/glueformula

There was also a discussion here whether a similar feature should be included into the glue package itself, but it looks as if that is not going to happen.

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' }; (function(d, t) { var s = d.createElement(t); s.type = 'text/javascript'; s.async = true; s.src = '//cdn.viglink.com/api/vglnk.js'; var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r); }(document, 'script'));

To leave a comment for the author, please follow the link and comment on their blog: Economics and R - R posts.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.


Viewing all articles
Browse latest Browse all 12081

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>