Guest User

Untitled

a guest
Mar 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. # Read CSV (132 rows)
  2. elodata <- read.csv(file="data.csv")
  3.  
  4. options(contrasts = c("contr.treatment", "contr.poly"))
  5.  
  6. # Run logit model
  7. m <- polr(as.factor(outcome) ~ difference, data=elodata)
  8.  
  9. #Create probability distribution
  10. newdata <- seq(from = -800, to = 800, length.out = 100)
  11. newdata <- cbind(newdata, predict(m, newdata, type = "probs"))
  12.  
  13. #Preview results
  14. head(newdata)
  15.  
  16. #Write to CSV
  17. write.csv(newdata, file = "output.csv")
  18.  
  19. newdata 0 0.5 1
  20. 1 -800.0000 0.9060434 0.05733837 0.03661819
  21. 2 -783.8384 0.9011665 0.06018767 0.03864587
  22. 3 -767.6768 0.8960654 0.06315355 0.04078108
  23. 4 -751.5152 0.8907329 0.06623810 0.04302897
  24. 5 -735.3535 0.8851620 0.06944313 0.04539491
  25. 6 -719.1919 0.8793454 0.07277014 0.04788443
  26.  
  27. Warning messages:
  28. 1: 'newdata' had 1601 rows but variables found have 100 rows
  29. 2: In cbind(newdata, predict(m, newdata, type = "probs")) :
  30. number of rows of result is not a multiple of vector length (arg 1)
Add Comment
Please, Sign In to add comment