Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pseudoR

pseudo R^2


Description

Calculates pseudo R^2 for discrete choice part.

Usage

pseudoR(
  x,
  which = c("all", "McFadden", "adjMcFadden", "Cox&Snell", "Nagelkerke"),
  only_total = FALSE
)

Arguments

x

Fitted nmm model.

which

which pseudo R^2 to calculate, options are: "all", "McFadden", "adjMcFadden", "Cox&Snell","Nagelkerke".

only_total

If TRUE, compute R^2 only for the whole sample.

Value

matrix with goodness of fit measures

Examples

library(mlogit)
data("Fishing", package = "mlogit")
Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice = "mode")
## a pure "conditional" model
mres <- summary(mlogit(mode ~ price + catch, data = Fish))
data <- prepare_data(Fish %>% data.frame %>% dplyr::select(-idx),
choice="alt", dummy="mode", PeID="chid", mode_spec_var = c("price", "catch"),
type="long")
eq_d <- c("a1 + p1 * price_1 + p2 * catch_2", "a2 + p1 * price_2 + p2 * catch_2",
             "a3 + p1 * price_3 + p2 * catch_3", "a4 + p1 * price_4 + p2 * catch_4")
par_d <- c(paste0("a", 1:4), paste0("p", 1:2))
res <- nmm(data, eq_d=eq_d, par_d = par_d,  eq_type="disc", fixed_term=FALSE,
best_method=FALSE)
pseudoR(res, which = c("McFadden"))
ncf <- c(mres$coefficients)
names(ncf) <- par_d[-1]
mress <- in2nmm(res, new_coef =  ncf)
pseudoR(mress, which = c("McFadden"))
pseudoR(mress)

nmm

Nonlinear Multivariate Models

v0.9
GPL (>= 2)
Authors
Simona Jokubauskaite [aut, cre], Reinhard Hoessinger [aut], Friedrich Leisch [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.