knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(bis557)
This package includes one dataset lm_patho
, and two functions my_linear_model()
and my_grad_descent()
. The purpose of these two functions are solving linear regression problem with different methods.
lm_patho
is a dataset with one dependent variabl, and two correlated independent variables.
data("lm_patho") lm_patho
The estimated coefficients are calculated in linear algebra way:
$\hat{\beta} = (X^TX)^{-1}X^TY$
The estimated coefficients are obtained by iterating optimization algorithm, and the precision can be regulated by the algorithm finishing criteria.
fit_lm <- lm(Sepal.Length ~ ., iris) fit_lm$coefficients
fit_linear_model <- my_linear_model(Sepal.Length ~ ., iris) fit_linear_model$coefficients
fit_gd <- my_grad_descent(Sepal.Length ~ ., iris) fit_gd$coefficients
fit_lm <- lm(y ~ ., lm_patho) fit_lm$coefficients
fit_linear_model <- my_linear_model(y ~ ., lm_patho) fit_linear_model$coefficients
fit_gd <- my_grad_descent(y ~ ., lm_patho) fit_gd$coefficients
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.