简体   繁体   English

R中multinom()函数中有大量变量

[英]Strange big number of variables in multinom() function in R

When I run the multinom() function in R, the number of variables in the result is very big while I only have a few predictor variables in the formula. 当我在R中运行multinom()函数时,结果中的变量数量非常大,而我在公式中只有一些预测变量。 Can anyone explain to me why this is happening and how can I resolve it? 任何人都可以向我解释为什么会发生这种情况,我该如何解决? ( mv_daily only takes 0 and 1, icu_loc takes 0,1,2 in the data.) mv_daily只取0和1, icu_loc在数据中取0,1,2。)

I tried 3 predictor variables and the number of variables in the result increased to 1230! 我尝试了3个预测变量,结果中的变量数增加到1230! The program takes each distinct value of a predictor variable as a different variable in the results and gives it a different coefficient. 程序将预测变量的每个不同值作为结果中的不同变量,并给出不同的系数。

newdata2 <- read.csv("~/Desktop/input_multinom_reg_March9_csv.csv")
library(nnet)
test <- multinom(state_tomorrow ~ mv_daily + icu_loc, newdata2,maxit=400,MaxNWts=2000)

Results: 结果:

 Call:
 multinom(formula = state_tomorrow ~ mv_day2 + icu_loc, data = newdata2, 
 maxit = 400, MaxNWts = 2000)

Coefficients:
(Intercept)    mv_daily    icu_loc
F     3.6303751 -1.1223394 -0.3681095
H     1.2178084 -1.3153864  0.3721295
IND   0.4628305 -2.1366738 -1.2530020
PR    2.2952981 -1.3085620 -0.4032178
RRT   0.1000952 -0.6432881  0.7659957

# weights:  24 (15 variable)
initial  value 18682.675986 
iter  10 value 12929.391832
iter  20 value 12341.441938
final  value 12284.346914

Data look like this: 数据看起来像这样:

id  state_tomorrow  day  mv_daily  icu_loc
1     F              1      0         1
1     RRT            2      1         1
2     PR             4      1         0
2     PR             5      1         2

在估计多项式模型时,应该期望对每个因子级别进行单独的参数估计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM