# falls noch nicht installiert: install.packages("EffectStars2") library(EffectStars2) # für Daten library(VGAM) # Schätzung I library(nnet) # Schätzung II data(election) # Data from 2009 levels(election$Partychoice) table(election$Partychoice) round(100*table(election$Partychoice) / nrow(election),2) barplot(100*table(election$Partychoice)/nrow(election), col = c("black", "red", "yellow", "green", "pink"), las = 1, ylab = "Percentage [%]") # Geschlecht mit Referenz CDU m1 <- vglm(Partychoice ~ Gender, data = election, family = multinomial(refLevel = "CDU")) # Geschlecht mit Referenz SPD m2 <- vglm(Partychoice ~ Gender, data = election, family = multinomial(refLevel = "SPD")) # anderes Paket m3 <- multinom(Partychoice ~ Gender, data = election) # get probabilities predict(m1, newdata = data.frame(Gender = "female"), type = "response") predict(m1, newdata = data.frame(Gender = "male"), type = "response") predict(m3, newdata = data.frame(Gender = "female"), type ="probs") m_elect <- vglm(Partychoice ~ Gender + West + Age + Union + Highschool, family = multinomial(refLevel = "CDU"), data = election) n_elect <- multinom(Partychoice ~ Gender + West + Age + Union + Highschool, data = election) summary(m_elect) summary(n_elect) effectstars(m_elect, symmetric = FALSE) effectstars(m_elect) m_elect2 <- vglm(Partychoice ~ Gender + West + Age + Union + Highschool + Unemployment + Pol.Interest + Democracy + Religion, family = multinomial(refLevel = "Greens"), data = election) summary(m_elect2) effectstars(m_elect2) effectstars(m_elect2, symmetric = FALSE)