Learn R Programming

nmm (version 0.9)

Nonlinear Multivariate Models

Description

Estimates a subset of nonlinear multivariate models (NMM): system of nonlinear regressions (SNR), logit, and a joint model of SNR and logit. 'nmm' uniquely accounts for correlations between the error terms from nonlinear regressions and the probabilities from logit models. It also enables a very flexible design of logit: alternative-specific indirect utilities, individual-specific choice set and number of actual choices.

Copy Link

Version

Install

install.packages('nmm')

Monthly Downloads

34

Version

0.9

License

GPL (>= 2)

Maintainer

Simona Jokubauskaite

Last Published

January 7th, 2021

Functions in nmm (0.9)

addInter

Add interactions
calc_sigma_rho

Returns function for sigma and rho calculation
AICc

Adjusted Akaike's Information Criterion.
add_variable

add_variable adds columns to the data matrix
MNlogitf

MNlogitf or MNdogitf returns log-likelihood(LL) expression for discrete equations of "logit" or "dogit" model.
MAEDtravel

Trip dataset
LL_joint_no_corr

LL_joint_no_corr Function for log-likelihood without correlation between continuous and discrete equations
LL_joint

LL_joint Function for joint log-likelihood with correlation between continuous and discrete equations
bread.nmm

Bread for Sandwiches.
collapse_space

Collapses lines ending with " "
check_names_start

Checks if starting values have names
check_par_av

check_par_av Checks if all elements of par are available in object.
combine_attr_deriv

combine_attr_deriv combines attributes of two deriv() results.
dataM

Example dataset
get_start_disc

get_start_disc get starting values for discrete choice model.
ff_generate4maxle_p_v2

Help function
ff_generate4mlsem

help function
datmaxle

Log-likelihood expressions for cont. equations
MAEDtimeExpenditure

Time-use and expenditure dataset
grad_hess_eval

grad_hess_eval forms function of gradient and Hessian of log-likelihood produced by f_create.
formula2string

formula2string removes square brackets from the supplied expressions. Convert par[2] -> par2, sigma[2] -> sigma_2_, sigma[2,3] -> sigma_2x2
cont_stats

Goodness of fit measures
convert_attr2exp

convert_attr2exp converts symbolic attribute of derivative into expression object.
generate_disc_coefs

Function for finding starting values for nls equations with errors
corstarsl

Significance of correlation matrix
get_npar

get_npar Get number of parameters or vector of parameters in supplied equations. Extracts the number of parameters used in equations. Parameters are given as par[1], ..., par[n].
diagnostics

Goodness of fit measures for both parts
deriv_disc_expr_corr

Hessian and Gradient expressions
dat4cond_mean_cov_expr

Log-likelihood expressions for cont. equations plus 1 discrete
in2nmm

in2nmm convert some estimation results into nmm object.
get_par

get_par replaces names of parameters with par[i].
gradient.nmm

Gradient with supplied coefficients
f_create

f_create creates functions for log-likelihood of different models.
deriv_disc_expr

Get expression of Hessian and Gradient for discrete choice model with quantile transformation
datmlsem

Log-likelihood expressions for cont. equations sem
get_start_cont

get_start_cont get starting values for continuous equations.
f_help

Internal helper function
get_start

get_start get starting values for discrete or continuous choice model.
mlsem

mlsem returns expression of log-likelihood for joint normal distribution, for maximum likelihood (ML), Simultaneous Equations Models (SEM) variant.
meat.nmm

Meat for Sandwiches
nmm

Maximum likelihood estimation of nonlinear multivariate models (NMM).
mod_function

Modifies function to optimize sigma and rho
nrParam

nrParam return number of parameters used in the estimation.
par2sigma

Converts vector of variances and correlations values into a matrix
expr_ll_norm

Log-likelihood expressions for cont. equations
expr_ll_norm_v2

Another Log-likelihood expressions for cont. equations version 2
ff_generate4maxle_p

Help function
help_MNdogitf

Internal helper function for MNdogitf
nmm_1good

searches for 1st good optimization method between possible maxLik algorithms
hessian.nmm

Hessian with supplied coefficients
ff_generate4maxle

help function
nmm_DEoptim

searches for 1st good optimization method between possible maxLik algorithms and then applies DEoptim
replace_expression

Replaces expressions ".exprXX" with strings
replace_par

replace_par replaces text with other text.
hitRate

Calculate Heat rate
wxMaxima

wxMaxima does symbolic computation in 'Maxima' Requires installation of Maxima software.
help_diagnostics

Generates objects needed for diagnostics functions
cond_expr

cond_expr returns moments of conditional multivariate normal distribution X|Y (last variable is dependent). Only expression for X|Y. Requires installation of Maxima software.
extract_attr_deriv

extract_attr_deriv converts attributes(hessian/gradient) of deriv() into a matrix of character strings.
maxle

maxle returns expression of log-likelihood (LL) of joint normal distribution.
cond_mean_cov_expr

cond_mean_cov_expr returns conditional mean and variance X|Y of conditional multivariate normal distribution . X is discrete variable, Y are continuous variables. No correlation between discrete eq.
extract_cont_data

Takes out only data used in continuous estimation
replace_par_wrap

replace_par_wrap replace text with other text, wrapper of replace_par.
logLik.nmm

Log-likelihood(LL) with supplied coefficients.
sigma2par

Converts sigma matrix into parameter vector
help_MNlogitf

Internal helper function for MNlogitf
maxle_p

maxle_p returns expression of partitioned log-likelihood. f(y1,y2,..,yn)=f(y1)f(y2|y1)f(y3|y2y1)...f(yn|y1..y(n-1))
prepare_data

prepare_data prepare data for the estimation.
nmm_lastDEoptim

last time try out DEoptim if no functions before produced "good" results
stats_function

Helper functions
nmm_best

searches for best optimization method between possible maxLik algorithms
try_alg

Test if maxLik produces an error
pseudoR

pseudo R^2
try_if

Checks if nmm object has an error
string2formula

string2formula add square brackets to expressions. Reverse of formula2string. Convert par[2] <- par2, sigma[2] <- sigma_2_, sigma[2,3] <- sigma_2x2