简体   繁体   中英

How to specify the weights parameter in nnet package for multinom method

I am using multinom method in the nnet package I need to weight the classes differently according to their proportions. I even have the proportions with me.

The question is how do I specify the weights parameter to the multinom method? If I just specify a list, how does it map the actual class to the weights?

You should not weight your classes according to their proportions; the sample sizes are part of the model and should not be adjusted via weights.

On the topic of specifying weights, you simply provide a list for multinom 's weights argument that will then map each value to a specified weight. It does this, if I'm not not mistaken (in which case I'd gladly corrected), by multiplying the log-likelihood of each case with the weight specified.

Here's an example.

library(nnet)

set.seed(1)

x <- rnor_lenm(100)
y <- rep_len(c("A", "B", "C"), 100)
wts <- runif(100)

multinom(y ~ x, weights = wts)

Output:

# weights:  9 (4 variable)
initial  value 56.891315 
final  value 56.637716 
converged
Call:
multinom(formula = y ~ x, weights = wts)

Coefficients:
  (Intercept)          x
B -0.09823625 -0.1779220
C -0.06923607 -0.1951617

Residual Deviance: 113.2754 
AIC: 121.2754    

Is that what you were looking for?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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