Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(MASS)
- beta_1 <- data.frame(ls=rep(0,1000), bisq=rep(0,1000))
- for (i in 1:nrow(beta_1)) {
- x <- rnorm(100)
- y <- x + rt(100,3)
- beta_1$ls[i] <- lm(y~x)$coefficients["x"]
- beta_1$bisq[i] <- rlm(y~x, psi=psi.bisquare)$coefficients["x"]
- }
- apply(beta_1, 2, sd)
- > apply(beta_1, 2, sd)
- ls bisq
- 0.1809239 0.1296139
- beta_1 <- data.frame(ls=rep(0,1000), bisq=rep(0,1000))
- for (i in 1:nrow(beta_1)) {
- x <- rnorm(100)
- y <- x + rnorm(100)
- z <- rbinom(100,1,0.05)
- y <- y + z*rnorm(100,0,5)
- beta_1$ls[i] <- lm(y~x)$coefficients["x"]
- beta_1$bisq[i] <- rlm(y~x, psi=psi.bisquare)$coefficients["x"]
- }
- > apply(beta_1, 2, sd)
- ls bisq
- 0.1518029 0.1147156
Add Comment
Please, Sign In to add comment