在做這個(gè)模型的時(shí)候,我們會(huì)把一般喜歡逞刷,特別喜歡這種程度變量化為數(shù)字的模式嘉涌,所以這些數(shù)字僅僅代表1類,并不能加減夸浅,沒有意義仑最。
ordered logit model 也被稱為proportional-odds model,模型內(nèi)每個(gè)事件的odds ratio均為獨(dú)立帆喇,每個(gè)種類的odds假定不變警医,因此各種類間的斜率并不會(huì)改變,種類間的區(qū)別主要體現(xiàn)在截距β上坯钦。
-
ordered logit model 與MNL的區(qū)別體現(xiàn)在下圖
聚個(gè)例子
預(yù)測一個(gè)人撿到錢包會(huì)不會(huì)歸還
- dependent variable:
- Least ethical (拿走了錢包和錢)
- Ethical (歸還了錢包)
- Most ethical (歸還了錢包和錢)
- Independent variables
- Gender (1=male or 0=female)
- Business School (1=yes or 0=no)
- Punish (disciplinary measures by parent)
(1) punished in elementary
(2) punished in elementary and middle school
(3) punished in elementary, middle and high - Explanation by parents regarding disciplinary measures (1=yes or 0=no)
- male與female為二分類變量,即male與female僅會(huì)出現(xiàn)一個(gè)葫笼。同理深啤,如果有一個(gè)變量有三個(gè)種類,結(jié)果中也僅會(huì)出現(xiàn)兩個(gè)路星。
- 那么上面的結(jié)果就說明了males are more likely to be less ethical. 因?yàn)閘east ethical的截距最高為1.21溯街,ethical的截距為1.18诱桂,most ethical 的截距作為baseline為0
- Residual Deviance = ?2LL = (?2)x(?151.8837) = 303.7675
AIC = ?2LL+2k = 303.765+2(10) = 323.768
最后放代碼
#Ordered logit model
#Hess=TRUE: This will generate a model with the observed information matrix from optimization (called the Hessian) which is used to get standard errors
library(MASS)
ordlog<-polr(honestfac~male+business+punish_el+explain,data=wallet, Hess=TRUE)
summary(ordlog)
c(deviance(ordlog),ordlog$edf) #Deviance and number of parameters (includes intercepts)
ci<-round(confint(ordlog),3) #confidence intervals
round(exp(coef(ordlog)),3) #odds ratios
round(exp(cbind(OR=coef(ordlog),ci)),3) #confidence intervals with respective odds ratios
#show the cutoffs on a plot
#Example using ord data for gender
x<-seq(-4,4,by=0.5)
plot(x,dlogis(x),type="l") #prob density function for a logistic distribution
abline(v=c(-1.6315,0.1229),col="red",lwd=2) #female
abline(v=c(-1.6315,0.1229)-1.0729,lty=2,col="blue",lwd=2) #males
text(-3.6,0.10,"P(Less \nEthical)")
text(2.8,0.10,"P(More \nEthical)")
legend ("topright",lty=1:2,lwd=2,legend=c("Males","Females"),col=c("red","blue"),bty="n")