Perform the following steps to implement a linear regression in MapReduce:
- First, load the cats dataset from the MASS package:
> library(MASS) > data(cats) > X = matrix(cats$Bwt) > y = matrix(cats$Hwt)
- You can then generate a linear regression model by calling the lm function:
> model = lm(y~X) > summary(model) Call: lm(formula = y ~ X) Residuals: Min 1Q Median 3Q Max -3.5694 -0.9634 -0.0921 1.0426 5.1238 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.3567 0.6923 -0.515 0.607 X 4.0341 0.2503 16.119 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.452 on 142 degrees of freedom Multiple R-squared: 0.6466, Adjusted R-squared: 0.6441 F-statistic: ...