Reputation: 28012
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?
Upvotes: 1
Views: 3664
Reputation: 3694
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?
Upvotes: 2