knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The TempleMetrics package is a collection of functions implemented by members of the Econometrics Reading Group at Temple University. The main functions (at the moment) are built for distribution regression. That is, one can estimate the distribution of $Y$ conditional on $X$ using a model for a binary outcome. For example, \begin{align} F_{Y|X}(y|x) = \Lambda(x'\beta) \end{align} where $\Lambda$ is some known link function, such as logit.
You can install TempleMetrics from github with:
# install.packages("devtools") devtools::install_github("bcallaway11/TempleMetrics")
or from CRAN using
install.packages("TempleMetrics")
The first example is how to run distribution regression for a single value of $y$ of $Y$. This example uses the igm
dataset which is a collection of 500 parent-child pairs of income along with the parent's education level which comes from the Panel Study of Income Dynamics (PSID).
library(TempleMetrics) data(igm) head(igm)
y0 <- median(igm$lcfincome) dreg <- distreg(lcfincome ~ lfincome + HEDUC, igm, y0) dreg
In many cases, of primary interest with distribution regression is obtaining $\hat{F}_{Y|X}(y|x)$ for some particular values of $y$ and $x$. That's what we do in this example.
yvals <- seq(quantile(igm$lcfincome,.05,type=1), quantile(igm$lcfincome,.95, type=1), length.out=100) dres <- distreg(lcfincome ~ lfincome + HEDUC, igm, yvals) xdf <- data.frame(lfincome=10, HEDUC="LessHS") y0 <- yvals[50] ecdf(igm$lcfincome)(y0) Fycondx(dres, y0, xdf)
This example says that: (1) the fraction of "children" in the dataset with income below r format(exp(y0),digits=4)
is r round(ecdf(igm$lcfincome)(y0),2)
, but (2) we estimate that the fraction of children whose parent's income is r format(exp(10),digits=4)
and have parent's with less than a HS education with income below r format(exp(y0),digits=4)
is r round(Fycondx(dres,y0,xdf)[[1]](y0),2)
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.