library(ordinal) # nur für die Daten # # wine_ord <- wine library(VGAM) # kennt auch ein wine, aber anders # propodds verwendet >= m1 <- vglm(rating ~ contact + temp, data = wine_ord, family = propodds()) coef(m1) # cumulative mit reverse = FALSE das klassische <= m2 <- vglm(rating ~ contact + temp, data = wine_ord, family = cumulative(reverse = FALSE, parallel = TRUE)) coef(m2) # kummulative log Chancen predict(m2, newdata = data.frame(contact = "no", temp ="cold"), untransform = FALSE) # kummulative Wkeiten predict(m2, newdata = data.frame(contact = "no", temp ="cold"), untransform = TRUE) # hier wird kummuliert exp(coef(m2)[1])/(1 + exp(coef(m2)[1])) exp(coef(m2)[2])/(1 + exp(coef(m2)[2])) exp(coef(m2)[3])/(1 + exp(coef(m2)[3])) exp(coef(m2)[4])/(1 + exp(coef(m2)[4])) # Zurückrechnen auf einzelne Wkeiten # z.b. für Klasse 3 # Wkeit <= 3 - Wkeit <= 4 exp(coef(m2)[3])/(1 + exp(coef(m2)[3])) - exp(coef(m2)[2])/(1 + exp(coef(m2)[2])) predict(m2, newdata = data.frame(contact = "no", temp ="cold"), type = "response") # Wkeit <= 1 bei contact yes exp(coef(m2)[1] + coef(m2)[5])/(1 + exp(coef(m2)[1] + coef(m2)[5])) # kummulative Wkeiten predict(m2, newdata = data.frame(contact = "yes", temp ="cold"), untransform = TRUE) exp(coef(m2)[2] + coef(m2)[5])/(1 + exp(coef(m2)[2] + coef(m2)[5])) # Einzel-Wkeiten predict(m2, newdata = data.frame(contact = "yes", temp ="cold"), type = "response") #------ Sequentielles Modell m3 <- vglm(rating ~ contact + temp, data = wine_ord, family = sratio(link = "logit", parallel = TRUE)) predict(m3, newdata = data.frame(contact = "no", temp ="cold"), untransform = TRUE) # hier wird kummuliert exp(coef(m3)[1])/(1 + exp(coef(m3)[1])) exp(coef(m3)[2])/(1 + exp(coef(m3)[2])) exp(coef(m3)[3])/(1 + exp(coef(m3)[3])) exp(coef(m3)[4])/(1 + exp(coef(m3)[4])) # vergleiche zu kumulativen Modell predict(m2, newdata = data.frame(contact = "no", temp ="cold"), untransform = TRUE) # vergleiche wiederum zu multinomialen Modell m4 <- vglm(rating ~ contact + temp, data = wine_ord, family = multinomial()) # multinomial (am flexibelsten, Berücksichtigt nicht ordinale struktur) predict(m4, newdata = data.frame(contact = "no", temp ="cold"), type = "response") # sequential ordinale struktur) predict(m3, newdata = data.frame(contact = "no", temp ="cold"), type = "response") # multinomial (am flexibelsten, Berücksichtigt nicht ordinale struktur) predict(m2, newdata = data.frame(contact = "no", temp ="cold"), type = "response")