I was playing with the method of multinom for simulation of household size
and had this error:
Error in nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = TRUE, :
too many (1404) weights
Then another error appeared in lapply where we draw from original sample for each stratum
Error in sample.int(length(x), size, replace, prob) :
incorrect number of probabilities
This was just caused by my data because
n <- households[grid[i, 1], grid[i, 2]] (= 0)
w <- wH[split[[i]]] (= numeric (empty))
p <- w / sum(w) (= numeric (empty))
And sample function doesn't seem to cooperate with numeric (empty) input so I added a condition that if the p is empty then just add 0 otherwise calculate spSample(n,p)
Hello,
I was playing with the method of multinom for simulation of household size and had this error: Error in nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = TRUE, : too many (1404) weights
So according to the answer in https://stackoverflow.com/questions/36303404/too-many-weights-in-multinomial-logistic-regression-and-the-code-is-running-for I added argument MaxNWts which in the nnet package is in general for controlling the maximum number of weights.
Then another error appeared in lapply where we draw from original sample for each stratum Error in sample.int(length(x), size, replace, prob) : incorrect number of probabilities
This was just caused by my data because
n <- households[grid[i, 1], grid[i, 2]] (= 0) w <- wH[split[[i]]] (= numeric (empty)) p <- w / sum(w) (= numeric (empty)) And sample function doesn't seem to cooperate with numeric (empty) input so I added a condition that if the p is empty then just add 0 otherwise calculate spSample(n,p)
After that the code run
Do you agree with the changes?