NNET Multinomial Regression - Error in looping through multiple independent variables and extracting coefficients/std.errors I have a scenario in which I'm using multinom (from NNET package) to perform multinomial regression over a set of 100+ genes (a given gene is an independent variable in each multinomial regression). I have the following setup for generating the models, which runs successfully.
formulas <- sapply(iv_list, function(x) as.formula(paste0("Outcome ~","`",x,"`","+ Covariate")))

models <- lapply(formulas, function(x){multinom(x, data = Data)})

My Q is how to extract the beta coefficient and standard errors for the set of 100+ genes
I tried the below...
summaries <- lapply(models,summary)

...it yields the following error:
Error in formula.character(object, env = baseenv()) :
invalid formula "CAPN9": not a call
CAPN9 being one of the gene names for which a multinomial model was fit
I'd really appreciate any help!

Try:
models <- lapply(formulas, function(x){multinom(x, data = Data, Hess = TRUE)})

When you don't ask for the Hessian matrix (to get sampling variance-covariance) it has to be produced when calling summary.  R is trying to reproduce the call and run the multinom model again to get the Hessian.  The formulas provided are not parsing right as they were passed through lapply (which records them as x if you look at each model's result object/list).  nnet is using that x formula to try to work backwards and re-run the model, but it is failing to parse right, which is causing the error.
All this is avoided by obtaining the Hessian up-front in the initial model call.
