Skip to content
Snippets Groups Projects

Dummy Regression

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Jan Garbuszus
    DummyRegression.R 279 B
    dd <- mtcars
    
    names(dd)
    table(dd$cyl)
    
    dd$c1 <- 0
    dd$c1[dd$cyl==4] <- 1
    
    dd$c2 <- 0
    dd$c2[dd$cyl==6] <- 1
    
    dd$c3 <- 0
    dd$c3[dd$cyl==8] <- 1
    
    res <- lm(mpg ~ wt + cyl, data = dd)
    res
    
    res2 <- lm(mpg ~ wt + c1 + c2, data = dd)
    res2
    
    res3 <- lm(mpg ~ wt + c2 + c3, data = dd)
    res3
    
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment