Skip to content

Instantly share code, notes, and snippets.

@conormm
Last active November 27, 2017 21:38
Show Gist options
  • Save conormm/c1cb44db0e44fd8a8c9f4dd88d2edd79 to your computer and use it in GitHub Desktop.
Save conormm/c1cb44db0e44fd8a8c9f4dd88d2edd79 to your computer and use it in GitHub Desktop.
library(dplyr)
library(ggplot2)
n <- 200 # number of observations
bias <- 4
slope <- 3.5
dot <- `%*%` # defined for personal preference
x <- rnorm(n) * 2
x_b <- cbind(x, rep(1, n))
y <- bias + slope * x + rnorm(n)
df <- data_frame(x = x, y = y)
learning_rate <- 0.05
n_iterations <- 100
theta <- matrix(c(20, 20))
b0 <- vector("numeric", length = n_iterations)
b1 <- vector("numeric", length = n_iterations)
sse_i <- vector("numeric", length = n_iterations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment