Multinomial logistic regression
mnl( dataset, rvar, evar, lev = "", int = "", wts = "None", check = "", data_filter = "", envir = parent.frame() )
dataset | Dataset |
---|---|
rvar | The response variable in the model |
evar | Explanatory variables in the model |
lev | The level in the response variable to use as the baseline |
int | Interaction term to include in the model |
wts | Weights to use in estimation |
check | Use "standardize" to see standardized coefficient estimates. Use "stepwise-backward" (or "stepwise-forward", or "stepwise-both") to apply step-wise selection of variables in estimation. |
data_filter | Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000") |
envir | Environment to extract data from |
A list with all variables defined in mnl as an object of class mnl
See https://radiant-rstats.github.io/docs/model/mnl.html for an example in Radiant
summary.mnl
to summarize the results
plot.mnl
to plot the results
predict.mnl
to generate predictions
plot.model.predict
to plot prediction output
result <- mnl( ketchup, rvar = "choice", evar = c("price.heinz28", "price.heinz32", "price.heinz41", "price.hunts32"), lev = "heinz28" )#> Warning: NaNs producedstr(result)#> List of 16 #> $ umod :List of 26 #> ..$ n : num [1:3] 1 0 4 #> ..$ nunits : int 6 #> ..$ nconn : num [1:7] 0 0 0 2 4 6 8 #> ..$ conn : num [1:8] 0 1 0 1 0 1 0 1 #> ..$ nsunits : num 2 #> ..$ decay : num 0 #> ..$ entropy : logi FALSE #> ..$ softmax : logi TRUE #> ..$ censored : logi FALSE #> ..$ value : num 3139 #> ..$ wts : num [1:8] 0 0 0 0.538 0 ... #> ..$ convergence : int 0 #> ..$ fitted.values: num [1:2798, 1:4] 0.304 0.304 0.304 0.304 0.304 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2798] "1" "2" "3" "4" ... #> .. .. ..$ : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ residuals : num [1:2798, 1:4] 0.696 0.696 0.696 0.696 0.696 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2798] "1" "2" "3" "4" ... #> .. .. ..$ : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ lev : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ call : language (function (formula, data, weights, subset, na.action, contrasts = NULL, Hess = FALSE, summ = 0, censored = F| __truncated__ ... #> ..$ terms :Classes 'terms', 'formula' language choice ~ 1 #> .. .. ..- attr(*, "variables")= language list(choice) #> .. .. ..- attr(*, "factors")= int(0) #> .. .. ..- attr(*, "term.labels")= chr(0) #> .. .. ..- attr(*, "order")= int(0) #> .. .. ..- attr(*, "intercept")= int 1 #> .. .. ..- attr(*, "response")= int 1 #> .. .. ..- attr(*, ".Environment")=<environment: 0x12f31388> #> .. .. ..- attr(*, "predvars")= language list(choice) #> .. .. ..- attr(*, "dataClasses")= Named chr "factor" #> .. .. .. ..- attr(*, "names")= chr "choice" #> ..$ weights : num [1:2798, 1] 1 1 1 1 1 1 1 1 1 1 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2798] "1" "2" "3" "4" ... #> .. .. ..$ : NULL #> ..$ deviance : num 6278 #> ..$ rank : int 1 #> ..$ lab : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ coefnames : chr "(Intercept)" #> ..$ vcoefnames : chr "(Intercept)" #> ..$ edf : num 3 #> ..$ AIC : num 6284 #> ..$ model :'data.frame': 2798 obs. of 1 variable: #> .. ..$ choice: Factor w/ 4 levels "heinz28","heinz32",..: 1 1 1 1 1 1 1 3 1 1 ... #> .. ..- attr(*, "terms")=Classes 'terms', 'formula' language choice ~ 1 #> .. .. .. ..- attr(*, "variables")= language list(choice) #> .. .. .. ..- attr(*, "factors")= int(0) #> .. .. .. ..- attr(*, "term.labels")= chr(0) #> .. .. .. ..- attr(*, "order")= int(0) #> .. .. .. ..- attr(*, "intercept")= int 1 #> .. .. .. ..- attr(*, "response")= int 1 #> .. .. .. ..- attr(*, ".Environment")=<environment: 0x12f31388> #> .. .. .. ..- attr(*, "predvars")= language list(choice) #> .. .. .. ..- attr(*, "dataClasses")= Named chr "factor" #> .. .. .. .. ..- attr(*, "names")= chr "choice" #> ..- attr(*, "class")= chr [1:2] "multinom" "nnet" #> $ coeff :'data.frame': 15 obs. of 8 variables: #> ..$ level : chr [1:15] "heinz32" "heinz32" "heinz32" "heinz32" ... #> ..$ label : chr [1:15] "(Intercept)" "price.heinz28" "price.heinz32" "price.heinz41" ... #> ..$ RRR : num [1:15] 4.7762 1.0987 NaN NaN 0.0532 ... #> ..$ coefficient: num [1:15] 1.5636 0.0941 NaN NaN -2.9336 ... #> ..$ std.error : num [1:15] 0.7403 0.0761 0.1348 0.1185 0.1031 ... #> ..$ z.value : num [1:15] 6.452 14.439 -17.033 -3.182 0.516 ... #> ..$ p.value : num [1:15] 0.0000000001106116796162242107301839029508214867769666511776449624449 0.00000000000000000000000000000000000000000| __truncated__ ... #> ..$ sig_star : chr [1:15] "***" "***" "***" "** " ... #> $ model :List of 30 #> ..$ n : num [1:3] 5 0 4 #> ..$ nunits : int 10 #> ..$ nconn : num [1:11] 0 0 0 0 0 0 0 6 12 18 ... #> ..$ conn : num [1:24] 0 1 2 3 4 5 0 1 2 3 ... #> ..$ nsunits : num 6 #> ..$ decay : num 0 #> ..$ entropy : logi FALSE #> ..$ softmax : logi TRUE #> ..$ censored : logi FALSE #> ..$ value : num 2511 #> ..$ wts : num [1:24] 0 0 0 0 0 ... #> ..$ convergence : int 0 #> ..$ fitted.values: num [1:2798, 1:4] 0.2725 0.5914 0.0675 0.2725 0.1817 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2798] "1" "2" "3" "4" ... #> .. .. ..$ : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ residuals : num [1:2798, 1:4] 0.728 0.409 0.933 0.728 0.818 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2798] "1" "2" "3" "4" ... #> .. .. ..$ : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ lev : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ call : language (function (formula, data, weights, subset, na.action, contrasts = NULL, Hess = FALSE, summ = 0, censored = F| __truncated__ ... #> ..$ terms :Classes 'terms', 'formula' language choice ~ price.heinz28 + price.heinz32 + price.heinz41 + price.hunts32 #> .. .. ..- attr(*, "variables")= language list(choice, price.heinz28, price.heinz32, price.heinz41, price.hunts32) #> .. .. ..- attr(*, "factors")= int [1:5, 1:4] 0 1 0 0 0 0 0 1 0 0 ... #> .. .. .. ..- attr(*, "dimnames")=List of 2 #> .. .. .. .. ..$ : chr [1:5] "choice" "price.heinz28" "price.heinz32" "price.heinz41" ... #> .. .. .. .. ..$ : chr [1:4] "price.heinz28" "price.heinz32" "price.heinz41" "price.hunts32" #> .. .. ..- attr(*, "term.labels")= chr [1:4] "price.heinz28" "price.heinz32" "price.heinz41" "price.hunts32" #> .. .. ..- attr(*, "order")= int [1:4] 1 1 1 1 #> .. .. ..- attr(*, "intercept")= int 1 #> .. .. ..- attr(*, "response")= int 1 #> .. .. ..- attr(*, ".Environment")=<environment: 0x12f31388> #> .. .. ..- attr(*, "predvars")= language list(choice, price.heinz28, price.heinz32, price.heinz41, price.hunts32) #> .. .. ..- attr(*, "dataClasses")= Named chr [1:5] "factor" "numeric" "numeric" "numeric" ... #> .. .. .. ..- attr(*, "names")= chr [1:5] "choice" "price.heinz28" "price.heinz32" "price.heinz41" ... #> ..$ weights : num [1:2798, 1] 1 1 1 1 1 1 1 1 1 1 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2798] "1" "2" "3" "4" ... #> .. .. ..$ : NULL #> ..$ deviance : num 5022 #> ..$ rank : int 5 #> ..$ lab : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> ..$ coefnames : chr [1:5] "(Intercept)" "price.heinz28" "price.heinz32" "price.heinz41" ... #> ..$ vcoefnames : chr [1:5] "(Intercept)" "price.heinz28" "price.heinz32" "price.heinz41" ... #> ..$ xlevels : Named list() #> ..$ edf : num 15 #> ..$ AIC : num 5052 #> ..$ model :'data.frame': 2798 obs. of 5 variables: #> .. ..$ choice : Factor w/ 4 levels "heinz28","heinz32",..: 1 1 1 1 1 1 1 3 1 1 ... #> .. ..$ price.heinz28: num [1:2798] 5.2 5.2 4.6 5.2 4.6 ... #> .. ..$ price.heinz32: num [1:2798] 3.7 4.3 2.5 3.7 3 ... #> .. ..$ price.heinz41: num [1:2798] 4.6 4.6 4.6 4.6 4.6 ... #> .. ..$ price.hunts32: num [1:2798] 3.4 4.4 4.8 3.4 4.8 ... #> .. ..- attr(*, "terms")=Classes 'terms', 'formula' language choice ~ price.heinz28 + price.heinz32 + price.heinz41 + price.hunts32 #> .. .. .. ..- attr(*, "variables")= language list(choice, price.heinz28, price.heinz32, price.heinz41, price.hunts32) #> .. .. .. ..- attr(*, "factors")= int [1:5, 1:4] 0 1 0 0 0 0 0 1 0 0 ... #> .. .. .. .. ..- attr(*, "dimnames")=List of 2 #> .. .. .. .. .. ..$ : chr [1:5] "choice" "price.heinz28" "price.heinz32" "price.heinz41" ... #> .. .. .. .. .. ..$ : chr [1:4] "price.heinz28" "price.heinz32" "price.heinz41" "price.hunts32" #> .. .. .. ..- attr(*, "term.labels")= chr [1:4] "price.heinz28" "price.heinz32" "price.heinz41" "price.hunts32" #> .. .. .. ..- attr(*, "order")= int [1:4] 1 1 1 1 #> .. .. .. ..- attr(*, "intercept")= int 1 #> .. .. .. ..- attr(*, "response")= int 1 #> .. .. .. ..- attr(*, ".Environment")=<environment: 0x12f31388> #> .. .. .. ..- attr(*, "predvars")= language list(choice, price.heinz28, price.heinz32, price.heinz41, price.hunts32) #> .. .. .. ..- attr(*, "dataClasses")= Named chr [1:5] "factor" "numeric" "numeric" "numeric" ... #> .. .. .. .. ..- attr(*, "names")= chr [1:5] "choice" "price.heinz28" "price.heinz32" "price.heinz41" ... #> ..$ null.deviance:Class 'logLik' : 6278 (df=3) #> ..$ logLik :Class 'logLik' : -2511 (df=15) #> ..$ nobs : int 2798 #> ..- attr(*, "class")= chr [1:2] "multinom" "nnet" #> $ mnl_input :List of 5 #> ..$ formula:Class 'formula' language choice ~ price.heinz28 + price.heinz32 + price.heinz41 + price.hunts32 #> .. .. ..- attr(*, ".Environment")=<environment: 0x12f31388> #> ..$ weights: NULL #> ..$ data :'data.frame': 2798 obs. of 5 variables: #> .. ..$ choice : Factor w/ 4 levels "heinz28","heinz32",..: 1 1 1 1 1 1 1 3 1 1 ... #> .. ..$ price.heinz28: num [1:2798] 5.2 5.2 4.6 5.2 4.6 ... #> .. ..$ price.heinz32: num [1:2798] 3.7 4.3 2.5 3.7 3 ... #> .. ..$ price.heinz41: num [1:2798] 4.6 4.6 4.6 4.6 4.6 ... #> .. ..$ price.hunts32: num [1:2798] 3.4 4.4 4.8 3.4 4.8 ... #> ..$ model : logi TRUE #> ..$ trace : logi FALSE #> $ mmx :List of 2 #> ..$ min:'data.frame': 1 obs. of 4 variables: #> .. ..$ price.heinz28: num 0.1 #> .. ..$ price.heinz32: num 0.3 #> .. ..$ price.heinz41: num 2 #> .. ..$ price.hunts32: num 0.3 #> ..$ max:'data.frame': 1 obs. of 4 variables: #> .. ..$ price.heinz28: num 12 #> .. ..$ price.heinz32: num 4.3 #> .. ..$ price.heinz41: num 7.2 #> .. ..$ price.hunts32: num 8.7 #> $ rv : Factor w/ 4 levels "heinz28","heinz32",..: 1 1 1 1 1 1 1 3 1 1 ... #> $ not_vary : chr(0) #> $ df_name : chr "ketchup" #> $ vars : chr [1:4] "price.heinz28" "price.heinz32" "price.heinz41" "price.hunts32" #> $ rvar : chr "choice" #> $ evar : chr [1:4] "price.heinz28" "price.heinz32" "price.heinz41" "price.hunts32" #> $ lev : chr [1:4] "heinz28" "heinz32" "heinz41" "hunts32" #> $ int : chr "" #> $ wts : NULL #> $ check : chr "" #> $ data_filter: chr "" #> - attr(*, "class")= chr [1:3] "mnl" "model" "list"