我正在为iris
数据集做多项逻辑回归模型,
library(VGAM)
mlog1 <- vglm(Species ~ ., data=iris, family=multinomial())
coef(mlog1)
系数为:
(Intercept):1 (Intercept):2 Sepal.Length:1 Sepal.Length:2 Sepal.Width:1
34.243397 42.637804 10.746723 2.465220 12.815353
Sepal.Width:2 Petal.Length:1 Petal.Length:2 Petal.Width:1 Petal.Width:2
6.680887 -25.042636 -9.429385 -36.060294 -18.286137
然后我使用multinom()
函数并做同样的事情:
library(nnet)
mlog2 <- multinom(Species ~ ., data=iris)
系数:
Coefficients:
(Intercept) Sepal.Length Sepal.Width Petal.Length Petal.Width
versicolor 18.69037 -5.458424 -8.707401 14.24477 -3.097684
virginica -23.83628 -7.923634 -15.370769 23.65978 15.135301
这两个结果之间似乎差距很大?我哪里做错了?我怎样才能修复它们并获得类似的结果?