Skip to content

Commit

Permalink
quantile reg estimate and test, python reticulate examples
Browse files Browse the repository at this point in the history
  • Loading branch information
FanWangEcon committed Sep 27, 2020
1 parent c2a9785 commit a67b53f
Show file tree
Hide file tree
Showing 256 changed files with 7,312 additions and 6,878 deletions.
3 changes: 2 additions & 1 deletion .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ library(REconTools)
library(formatR)

# jointly use R and Python Together
library(reticulate)

# RMD Options
options(knitr.duplicate.label = "allow")
Expand All @@ -19,7 +20,7 @@ options(bookdown.render.file_scope = FALSE)
knitr::opts_chunk$set(fig.width=7, fig.height=4, fig.align="center")
# knitr::opts_chunk$set(tidy.opts=list(width.cutoff=60), tidy=TRUE)
knitr::opts_chunk$set(warning=FALSE, message=FALSE, cache=FALSE)
opts_chunk$set(engine.path = "C:/ProgramData/Anaconda3/envs/wk_pyfan/python.exe")
knitr::opts_chunk$set(engine.path = "C:/ProgramData/Anaconda3/envs/wk_pyfan/python.exe")

# Output HTML or Latex
if (knitr::is_latex_output()) {
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Materials gathered from various [projects](https://fanwangecon.github.io/researc

Bullet points show which [base R](https://www.rdocumentation.org/packages/base/versions/3.5.2), [tidyverse](https://www.tidyverse.org/) or other functions/commands are used to achieve various objectives. An effort is made to use only [base R](https://www.rdocumentation.org/packages/base/versions/3.5.2) and [tidyverse](https://www.tidyverse.org/) packages whenever possible to reduce dependencies. The goal of this repository is to make it easier to find/re-use codes produced for various projects.

From other repositories: For dynamic borrowing and savings problems, see [Dynamic Asset Repository](https://fanwangecon.github.io/CodeDynaAsset/); For code examples, see also [Matlab Example Code](https://fanwangecon.github.io/M4Econ/) and [Stata Example Code](https://fanwangecon.github.io/Stata4Econ/); For intro econ with Matlab, see [Intro Mathematics for Economists](https://fanwangecon.github.io/Math4Econ/), and for intro stat with R, see [Intro Statistics for Undergraduates](https://fanwangecon.github.io/Stat4Econ/). See [here](https://github.com/FanWangEcon) for all of [Fan](https://fanwangecon.github.io/)'s public repositories.
From other repositories: For dynamic borrowing and savings problems, see [MEconTools](https://fanwangecon.github.io/MEconTools/) and [Dynamic Asset Repository](https://fanwangecon.github.io/CodeDynaAsset/); For code examples, see also [Matlab Example Code](https://fanwangecon.github.io/M4Econ/), [Stata Example Code](https://fanwangecon.github.io/Stata4Econ/), [Python Example Code](https://fanwangecon.github.io/pyfan/); For intro econ with Matlab, see [Intro Mathematics for Economists](https://fanwangecon.github.io/Math4Econ/), and for intro stat with R, see [Intro Statistics for Undergraduates](https://fanwangecon.github.io/Stat4Econ/). See [here](https://github.com/FanWangEcon) for all of [Fan](https://fanwangecon.github.io/)'s public repositories.

Please contact [FanWangEcon](https://fanwangecon.github.io/) for issues or problems.

Expand Down Expand Up @@ -205,6 +205,12 @@ Please contact [FanWangEcon](https://fanwangecon.github.io/) for issues or probl
+ Logit regression testing and prediction.
+ **stats**: *glm(as.formula(), data, family='binomial') + predict(rs, newdata, type = "response")*

## 6.2 Quantile Regression

1. [Quantile Regressions with Quantreg](https://fanwangecon.github.io/R4Econ/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.html): [**rmd**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg//fs_quantreg_intro.Rmd) \| [**r**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.R) \| [**pdf**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.pdf) \| [**html**](https://fanwangecon.github.io/R4Econ/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.html)
+ Quantile regression with continuous outcomes. Estimates and tests quantile coefficients.
+ **quantreg**: *rq(mpg ~ disp + hp + factor(am), tau = c(0.25, 0.50, 0.75), data = mtcars) + anova(rq(), test = "Wald", joint=TRUE) + anova(rq(), test = "Wald", joint=FALSE)*

# 7 Optimization

## 7.1 Bisection
Expand Down Expand Up @@ -279,6 +285,12 @@ Please contact [FanWangEcon](https://fanwangecon.github.io/) for issues or probl
+ Modify markdown pounds hierarchy.
+ **r**: *file() + writeLines() + readLines() + close() + gsub()*

## 11.2 Python with R

1. [Python in R with Reticulate](https://fanwangecon.github.io/R4Econ/development/python/htmlpdfr/fs_python_reticulate.html): [**rmd**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python//fs_python_reticulate.Rmd) \| [**r**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python/htmlpdfr/fs_python_reticulate.R) \| [**pdf**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python/htmlpdfr/fs_python_reticulate.pdf) \| [**html**](https://fanwangecon.github.io/R4Econ/development/python/htmlpdfr/fs_python_reticulate.html)
+ Use Python in R with Reticulate
+ **reticulate**: *py_config() + use_condaenv() + py_run_string() + Sys.which('python')*

----
Please contact [![](https://img.shields.io/github/followers/fanwangecon?label=FanWangEcon&style=social)](https://github.com/FanWangEcon) [![](https://img.shields.io/twitter/follow/fanwangecon?label=%20&style=social)](https://twitter.com/fanwangecon) for issues or problems.

Expand Down
12 changes: 12 additions & 0 deletions README_appendix.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@
+ Logit regression testing and prediction.
+ **stats**: *glm(as.formula(), data, family='binomial') + predict(rs, newdata, type = "response")*

### [Section 6.2 Quantile Regression][Quantile Regression] links

1. [Quantile Regressions with Quantreg](https://fanwangecon.github.io/R4Econ/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.html): [**rmd**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg//fs_quantreg_intro.Rmd) \| [**r**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.R) \| [**pdf**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.pdf) \| [**html**](https://fanwangecon.github.io/R4Econ/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.html)
+ Quantile regression with continuous outcomes. Estimates and tests quantile coefficients.
+ **quantreg**: *rq(mpg ~ disp + hp + factor(am), tau = c(0.25, 0.50, 0.75), data = mtcars) + anova(rq(), test = "Wald", joint=TRUE) + anova(rq(), test = "Wald", joint=FALSE)*

## Optimization links

### [Section 7.1 Bisection][Bisection] links
Expand Down Expand Up @@ -266,3 +272,9 @@
+ Convert R Markdow File to R, PDF and HTML.
+ Modify markdown pounds hierarchy.
+ **r**: *file() + writeLines() + readLines() + close() + gsub()*

### [Section 11.2 Python with R][Python with R] links

1. [Python in R with Reticulate](https://fanwangecon.github.io/R4Econ/development/python/htmlpdfr/fs_python_reticulate.html): [**rmd**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python//fs_python_reticulate.Rmd) \| [**r**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python/htmlpdfr/fs_python_reticulate.R) \| [**pdf**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python/htmlpdfr/fs_python_reticulate.pdf) \| [**html**](https://fanwangecon.github.io/R4Econ/development/python/htmlpdfr/fs_python_reticulate.html)
+ Use Python in R with Reticulate
+ **reticulate**: *py_config() + use_condaenv() + py_run_string() + Sys.which('python')*
2 changes: 1 addition & 1 deletion README_pre.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Materials gathered from various [projects](https://fanwangecon.github.io/researc

Bullet points show which [base R](https://www.rdocumentation.org/packages/base/versions/3.5.2), [tidyverse](https://www.tidyverse.org/) or other functions/commands are used to achieve various objectives. An effort is made to use only [base R](https://www.rdocumentation.org/packages/base/versions/3.5.2) and [tidyverse](https://www.tidyverse.org/) packages whenever possible to reduce dependencies. The goal of this repository is to make it easier to find/re-use codes produced for various projects.

From other repositories: For dynamic borrowing and savings problems, see [Dynamic Asset Repository](https://fanwangecon.github.io/CodeDynaAsset/); For code examples, see also [Matlab Example Code](https://fanwangecon.github.io/M4Econ/) and [Stata Example Code](https://fanwangecon.github.io/Stata4Econ/); For intro econ with Matlab, see [Intro Mathematics for Economists](https://fanwangecon.github.io/Math4Econ/), and for intro stat with R, see [Intro Statistics for Undergraduates](https://fanwangecon.github.io/Stat4Econ/). See [here](https://github.com/FanWangEcon) for all of [Fan](https://fanwangecon.github.io/)'s public repositories.
From other repositories: For dynamic borrowing and savings problems, see [MEconTools](https://fanwangecon.github.io/MEconTools/) and [Dynamic Asset Repository](https://fanwangecon.github.io/CodeDynaAsset/); For code examples, see also [Matlab Example Code](https://fanwangecon.github.io/M4Econ/), [Stata Example Code](https://fanwangecon.github.io/Stata4Econ/), [Python Example Code](https://fanwangecon.github.io/pyfan/); For intro econ with Matlab, see [Intro Mathematics for Economists](https://fanwangecon.github.io/Math4Econ/), and for intro stat with R, see [Intro Statistics for Undergraduates](https://fanwangecon.github.io/Stat4Econ/). See [here](https://github.com/FanWangEcon) for all of [Fan](https://fanwangecon.github.io/)'s public repositories.

Please contact [FanWangEcon](https://fanwangecon.github.io/) for issues or problems.

Expand Down
12 changes: 12 additions & 0 deletions README_toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@
+ Logit regression testing and prediction.
+ **stats**: *glm(as.formula(), data, family='binomial') + predict(rs, newdata, type = "response")*

## 6.2 Quantile Regression

1. [Quantile Regressions with Quantreg](https://fanwangecon.github.io/R4Econ/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.html): [**rmd**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg//fs_quantreg_intro.Rmd) \| [**r**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.R) \| [**pdf**](https://github.com/FanWangEcon/R4Econ/blob/master/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.pdf) \| [**html**](https://fanwangecon.github.io/R4Econ/regnonlin/quantreg/htmlpdfr/fs_quantreg_intro.html)
+ Quantile regression with continuous outcomes. Estimates and tests quantile coefficients.
+ **quantreg**: *rq(mpg ~ disp + hp + factor(am), tau = c(0.25, 0.50, 0.75), data = mtcars) + anova(rq(), test = "Wald", joint=TRUE) + anova(rq(), test = "Wald", joint=FALSE)*

# 7 Optimization

## 7.1 Bisection
Expand Down Expand Up @@ -262,3 +268,9 @@
+ Convert R Markdow File to R, PDF and HTML.
+ Modify markdown pounds hierarchy.
+ **r**: *file() + writeLines() + readLines() + close() + gsub()*

## 11.2 Python with R

1. [Python in R with Reticulate](https://fanwangecon.github.io/R4Econ/development/python/htmlpdfr/fs_python_reticulate.html): [**rmd**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python//fs_python_reticulate.Rmd) \| [**r**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python/htmlpdfr/fs_python_reticulate.R) \| [**pdf**](https://github.com/FanWangEcon/R4Econ/blob/master/development/python/htmlpdfr/fs_python_reticulate.pdf) \| [**html**](https://fanwangecon.github.io/R4Econ/development/python/htmlpdfr/fs_python_reticulate.html)
+ Use Python in R with Reticulate
+ **reticulate**: *py_config() + use_condaenv() + py_run_string() + Sys.which('python')*
4 changes: 4 additions & 0 deletions _bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ rmd_files:
- regnonlin/main.Rmd
- regnonlin/logit/main.Rmd
- regnonlin/logit/fs_logit_birhs.Rmd
- regnonlin/quantreg/main.Rmd
- regnonlin/quantreg/fs_quantreg_intro.Rmd

- optimization/main.Rmd
- optimization/root_bisect/main.Rmd
Expand Down Expand Up @@ -100,6 +102,8 @@ rmd_files:
- development/inout/main.Rmd
- development/inout/fs_text_save.Rmd
- development/inout/fs_rmd_pdf_html.Rmd
- development/python/main.Rmd
- development/python/fs_python_reticulate.Rmd

- README_appendix.md

Expand Down
Binary file modified _img/fs_img_io_2curve_w135h76_res300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _img/fs_img_io_2curve_w135h76_res72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _img/fs_img_io_2curve_w160h100_res300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _img/fs_img_io_2curve_w80h48_res300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified bookdown/Panel-Data-and-Optimization-with-R.pdf
Binary file not shown.
Loading

0 comments on commit a67b53f

Please sign in to comment.