-
-
Save jeroen/a5b07a669285da699056 to your computer and use it in GitHub Desktop.
Linear regression in JavaScript using simple statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load in simple statistics | |
library(V8) | |
ct <- new_context("window") | |
ct$source("https://raw.githubusercontent.com/tmcw/simple-statistics/master/src/simple_statistics.js") | |
# Run Regression | |
ct$assign("mydata", cbind(mtcars$wt, mtcars$mpg)) | |
ct$eval("var lm = ss.linear_regression().data(mydata)") | |
ct$get("[ lm.b(), lm.m() ]") | |
# Compare to | |
coef(lm( mpg ~ wt, mtcars )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment