knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(bis557)

Name: Brian Deng (BIS557 HW1)

The R package {bis557} was built to store all the functions and data used for this class, which focuses on creating statistical models and algorithms.

Dataset

Below is an example dataset, lm_patho from the {bis557} package, that can be used for linear regression.

library(bis557)
data(lm_patho)
head(lm_patho)

Example: Linear Model

This is a basic example which shows you to create a linear model, for example, doing regression analysis.

$$ y \sim \beta_1 x_1 + \beta_2 x_2 $$



library(bis557)
data(lm_patho)
fit_linear_model <- linear_model(y ~., lm_patho)

Example: Gradient Descent

This is a basic example which shows you how to solve a common problem: Use an optimization algorithm, such as gradient descent, to find the coefficients of simple linear regression.



library(bis557)
data(lm_patho)
gd_patho <- grad_descent(X = lm_patho[,-1], y = lm_patho[,1],
                         b_0 = rep(1e-16, ncol(lm_patho)), learn_rate = 1.3e-16,
                         max_iter = 1e5)
gd_patho


brian-d1018/bis557 documentation built on Dec. 17, 2020, 6:21 p.m.