multinomial

How to use predict with multinom() with intercept in R?

早过忘川 提交于 2019-12-06 13:22:46
I have run the multinom() function in R, but when I try to predict on a new sample, it keeps giving an error. this is the code: library(nnet) dta=data.frame(replicate(10,runif(10))) names(dta)=c('y',paste0('x',1:9)) res4 <- multinom(y ~ as.matrix(dta[2:10]) , data=dta) #make new data to predict nd<-0.1*dta[1,2:10] pred<-predict(res4, newdata=nd) and this is the error: Error in predict.multinom(res4, newdata = nd) : NAs are not allowed in subscripted assignments I think it has to do with the intercept being included in the analysis, but not in the new prediction input. I tried to set it

How to interpret the output of choicemodelr (rhierMnlRwMixture) in R

我怕爱的太早我们不能终老 提交于 2019-12-06 13:21:45
My Problem I just started using the R library 'choicemodelr' and succeded in getting some beta values as a solution. But I wonder how do I assign these values to the specific attribute-levels. As a result I only get values for A1B1, A1B2, A1B3,... etc. How does this generic output generally connect to my Design? Didn't find a hint in the documentation. Neither for the choicemodelr libraray, nor the bayesm library (rhierMnlRwMixture) to which it is connected to. I hope you can help me with this one. Thanks in advance, Phil to illustrate this, some code and output: my code in R # loading

Efficient multinomial sampling when sample size and probability vary

穿精又带淫゛_ 提交于 2019-12-06 02:26:08
问题 This question pertains to efficient sampling from multinomial distributions with varying sample sizes and probabilities. Below I describe the approach I have used, but wonder whether it can be improved with some intelligent vectorisation. I'm simulating dispersal of organisms amongst multiple populations. Individuals from population j disperse to population i with probability p[i, j] . Given an initial abundance of 10 in population 1, and probabilities of dispersal c(0.1, 0.3, 0.6) to

something similar to permutation accuracy importance in h2o package

假如想象 提交于 2019-12-05 20:26:02
I fitted a random forest for my multinomial target with the randomForest package in R. Looking for the variable importance I found out permutation accuracy importance which is what I was looking for my analysis. I fitted a random forest with the h2o package too, but the only measures it shows me are relative_importance, scaled_importance, percentage . My question is: can I extract a measure that shows me the level of the target which better classify the variable i want to take in exam? Permutation accuracy importance is the best measure I can use in this case? For example: I have a 3 levels

Multinom with Matrix of Counts as Response

落爺英雄遲暮 提交于 2019-12-05 18:41:42
According to the help of multinom , package nnet , "The response should be a factor or a matrix with K columns, which will be interpreted as counts for each of K classes." I tried to use this function in the second case, obtaining an error. Here is a sample code of what I do: response <- matrix(round(runif(200,0,1)*100),ncol=20) # 10x20 matrix of counts predictor <- runif(10,0,1) fit1 <- multinom(response ~ predictor) weights1 <- predict(fit1, newdata = 0.5, "probs") Here what I obtain: 'newdata' had 1 row but variables found have 10 rows How can I solve this problem? Bonus question: I also

multinomial mixed logit model mlogit r-package

北城余情 提交于 2019-12-04 23:52:52
问题 I discovered the mlogit -package for multinomial logit models in search of estimating a multinomial mixed logit model. After reading the excellent vignette I discovered that I could not apply my data on any of the described examples. I now write in hope of help with my problem and created a minimal example to illustrate my situation. The Problem is as follows: There are words with the consonant 'Q' somewhere. Now an experiment was conducted with people who were tasked to listen to these words

Fitted values for multinom in R: Coefficients for Reference Category?

笑着哭i 提交于 2019-12-04 15:13:26
I'm using the function multinom from the nnet package to run a multinomial logistic regression. In multinomial logistic regression, as I understand it, the coefficients are the changes in the log of the ratio of the probability of a response over the probability of the reference response (i.e., ln(P( i )/P( r ))=B 1 +B 2 *X... where i is one response category, r is the reference category, and X is some predictor). However, fitted(multinom(...)) produces estimates for each category, even the reference category r . EDIT Example: set.seed(1) library(nnet) DF <- data.frame(X = as.numeric(rnorm(30)

Efficient multinomial sampling when sample size and probability vary

江枫思渺然 提交于 2019-12-04 07:53:25
This question pertains to efficient sampling from multinomial distributions with varying sample sizes and probabilities. Below I describe the approach I have used, but wonder whether it can be improved with some intelligent vectorisation. I'm simulating dispersal of organisms amongst multiple populations. Individuals from population j disperse to population i with probability p[i, j] . Given an initial abundance of 10 in population 1, and probabilities of dispersal c(0.1, 0.3, 0.6) to populations 1, 2, and 3, respectively, we can simulate the dispersal process with rmultinom : set.seed(1)

Dealing with negative values in sklearn MultinomialNB

与世无争的帅哥 提交于 2019-12-04 04:22:46
I am normalizing my text input before running MultinomialNB in sklearn like this: vectorizer = TfidfVectorizer(max_df=0.5, stop_words='english', use_idf=True) lsa = TruncatedSVD(n_components=100) mnb = MultinomialNB(alpha=0.01) train_text = vectorizer.fit_transform(raw_text_train) train_text = lsa.fit_transform(train_text) train_text = Normalizer(copy=False).fit_transform(train_text) mnb.fit(train_text, train_labels) Unfortunately, MultinomialNB does not accept the non-negative values created during the LSA stage. Any ideas for getting around this? I recommend you that don't use Naive Bayes

multinomial mixed logit model mlogit r-package

那年仲夏 提交于 2019-12-03 15:31:03
I discovered the mlogit - package for multinomial logit models in search of estimating a multinomial mixed logit model. After reading the excellent vignette I discovered that I could not apply my data on any of the described examples. I now write in hope of help with my problem and created a minimal example to illustrate my situation. The Problem is as follows: There are words with the consonant 'Q' somewhere. Now an experiment was conducted with people who were tasked to listen to these words and say if they heard a Q, an U or some OTHER consonant. This has to modeled in dependence of some