Closed dustinvtran closed 9 years ago
library(sgd) # Dimensions N <- 1e4 d <- 1e2 # Generate data. set.seed(42) X <- matrix(rnorm(N*d), ncol=d) theta <- rep(5, d+1) eps <- rnorm(N) y <- cbind(1, X) %*% theta + eps dat <- data.frame(y=y, x=X) sgd.theta <- sgd(y ~ ., data=dat, model="lm") mean((sgd.theta$coefficients - theta)^2) # MSE