Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Read CSV (132 rows)
- elodata <- read.csv(file="data.csv")
- options(contrasts = c("contr.treatment", "contr.poly"))
- # Run logit model
- m <- polr(as.factor(outcome) ~ difference, data=elodata)
- #Create probability distribution
- newdata <- seq(from = -800, to = 800, length.out = 100)
- newdata <- cbind(newdata, predict(m, newdata, type = "probs"))
- #Preview results
- head(newdata)
- #Write to CSV
- write.csv(newdata, file = "output.csv")
- newdata 0 0.5 1
- 1 -800.0000 0.9060434 0.05733837 0.03661819
- 2 -783.8384 0.9011665 0.06018767 0.03864587
- 3 -767.6768 0.8960654 0.06315355 0.04078108
- 4 -751.5152 0.8907329 0.06623810 0.04302897
- 5 -735.3535 0.8851620 0.06944313 0.04539491
- 6 -719.1919 0.8793454 0.07277014 0.04788443
- Warning messages:
- 1: 'newdata' had 1601 rows but variables found have 100 rows
- 2: In cbind(newdata, predict(m, newdata, type = "probs")) :
- number of rows of result is not a multiple of vector length (arg 1)
Add Comment
Please, Sign In to add comment