Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fo <- mpg ~ hp
- X <- model.matrix(fo, mtcars)
- microbenchmark::microbenchmark(flm=lm <-
- lm(fo, mtcars[mtcars$am == 1, ],
- weights=rep(1, 13)),
- flmw=lmw <-
- lm.wfit(X[mtcars$am == 1, ], mtcars$mpg[mtcars$am == 1],
- w=rep(1, 13)))
- # Unit: microseconds
- # expr min lq mean median uq max neval cld
- # flm 935.328 951.2735 994.7719 957.2695 1006.128 1333.339 100 b
- # flmw 56.895 60.3400 66.2028 64.2940 66.463 186.250 100 a
- stopifnot(lm$coefficients == lmw$coefficients)
- predict(lm, mtcars)
- # [...]
- predict(lmw, mtcars)
- # Error in UseMethod("predict") :
- # no applicable method for 'predict' applied to an object of class "list"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement