knitr::opts_chunk$set(echo = TRUE)
statr
is a personal R package that I have created for organizational/convenience purposes. This project is purely experimental! A (possibly incomplete) list of functions contained in the package can be found below:
tidy()
tidy's R package code and updates documentationCVsplit()
splits data objects into training and testing setsdata_gen()
generates data for linear regression settingsdense()
generates dense matricesdenseQR()
generates dense matrices via spectral decompositiontridiag()
generates tri-diagonal matricesderivative()
approximates the derivative for a given functiondiagnostic()
creates diagnostic plots using ggplot (residual and QQ)dsearch()
is a dichotomous search algorithm for minimizing a univariate functionbsearch()
is a bi-section search algorithm for minimizing a univariate functionLASSO()
calculates lasso regression coefficient with optimal tuningRIDGE()
calculates ridge regression coefficient with optimal tuningscatter()
creates a scatterplot using ggplotThe easiest way to install is from the development version from Github:
# install.packages("devtools") devtools::install_github("MGallow/statr")
If there are any issues/bugs, please let me know: github. You can also contact me via my website. Contributions are welcome!
library(statr) library(magrittr) # we will use the iris data set X = dplyr::select(iris, -c(Species, Sepal.Length)) %>% as.matrix y = dplyr::select(iris, Sepal.Length) %>% as.matrix y_class = ifelse(dplyr::select(iris, Species) == "setosa", 1, 0) # let us split the data for testing and training CV = CVsplit(X, y) # we can do some exploratory analysis # plot Sepal.Length v Sepal.Width iris %>% scatter(Sepal.Length, Sepal.Width) # plot diagnostic plots iris %>% diagnostic(Sepal.Length, Sepal.Width) # use the training data to fit ridge regression RIDGE(CV$X.train, CV$Y.train) # or lasso regression statr::LASSO(CV$X.train, CV$Y.train) # we can also generate our own data data = data_gen(p = 10, r = 5, n = 100) CV = CVsplit(data$X, data$Y) # and again fit a ridge regression statr::RIDGE(CV$X.train, CV$Y.train) # we can also generate random matrices with may be useful # for other applications # tridiagonal matrices tridiag(p = 5)$Omega %>% round(5) # dense matrices dense(p = 5)$Omega %>% round(5) # compound symmetric matrices compound(p = 5)$Omega %>% round(5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.