|
1 | 1 | --- |
2 | | -title: "Using RcppEnsmallen" |
| 2 | +title: "Solving Linear Regression using Numeric Optimization" |
3 | 3 | author: James Joseph Balamuta and Dirk Eddelbuettel |
4 | 4 | abstract: | |
5 | | - Contained within are examples related to using RcppEnsmallen in everyday |
6 | | - work alongside of creating an _R_ package with it. |
| 5 | + In this vignette, we describe how to use RcppEnsmallen in a standalone |
| 6 | + C++ file. |
7 | 7 | output: rmarkdown::html_vignette |
8 | 8 | vignette: > |
9 | | - %\VignetteIndexEntry{Using RcppEnsmallen} |
| 9 | + %\VignetteIndexEntry{Solving Linear Regression using Numeric Optimization} |
10 | 10 | %\VignetteEngine{knitr::rmarkdown} |
11 | 11 | %\VignetteEncoding{UTF-8} |
12 | 12 | --- |
@@ -45,7 +45,7 @@ $$RSS\left( \beta \right) = \left( { \mathbf{y} - \mathbf{X} \beta } \right)^{\t |
45 | 45 |
|
46 | 46 | The objective function we wish to minimize would be defined as: |
47 | 47 |
|
48 | | -$$f(\beta) = \rVert y - X\beta\lVert_2$$ |
| 48 | +$$f(\beta) = \rVert \mathbf{y} - \mathbf{X}\beta\lVert_2$$ |
49 | 49 |
|
50 | 50 | The gradient is defined as: |
51 | 51 |
|
@@ -185,25 +185,3 @@ rownames(compare_coefs) = paste0("Beta", seq_len(nrow(compare_coefs))) |
185 | 185 | knitr::kable(compare_coefs, longtable = FALSE, caption = "Comparison of Estimated Coefficients") |
186 | 186 | ``` |
187 | 187 |
|
188 | | -# Package Usage |
189 | | - |
190 | | -RcppEnsmallen is best used within an _R_ package. The setup for `RcppEnsmallen`'s |
191 | | -use mirrors that of other `Rcpp`-based projects. In particular, the |
192 | | -`DESCRIPTION` file requires the `LinkingTo` field to contain: |
193 | | - |
194 | | -```bash |
195 | | -LinkingTo: Rcpp, RcppArmadillo (>= 0.9.800.0.0), RcppEnsmallen (>= 0.2.18.0.1) |
196 | | -``` |
197 | | - |
198 | | -Next, the `src/` directory must contain both a `Makevars` and `Makevars.win` |
199 | | -file with: |
200 | | - |
201 | | -```bash |
202 | | -CXX_STD = CXX11 |
203 | | -PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) |
204 | | -PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) |
205 | | -``` |
206 | | - |
207 | | -The `Makevars.win` file provides the appropriate configuration for Windows |
208 | | -while `Makevars` acts on Unix-alike systems like macOS, Linux, and Solaris. |
209 | | - |
0 commit comments