Skip to contents

This function checks the input form.

Usage

check_form(form, re = NULL, ordered = FALSE)

Arguments

form

A formula object that is used to specify the model equation. The structure is choice ~ A | B | C, where

  • choice is the name of the dependent variable (the choices),

  • A are names of alternative and choice situation specific covariates with a coefficient that is constant across alternatives,

  • B are names of choice situation specific covariates with alternative specific coefficients,

  • and C are names of alternative and choice situation specific covariates with alternative specific coefficients.

Multiple covariates (of one type) are separated by a + sign. By default, alternative specific constants (ASCs) are added to the model. They can be removed by adding +0 in the second spot.

In the ordered probit model (ordered = TRUE), the formula object has the simple structure choice ~ A. ASCs are not estimated.

re

A character (vector) of covariates of form with random effects. If re = NULL (the default), there are no random effects. To have random effects for the ASCs, include "ASC" in re.

ordered

A boolean, FALSE per default. If TRUE, the choice set alternatives is assumed to be ordered from worst to best.

Value

A list that contains the following elements:

  • The input form.

  • The name choice of the dependent variable in form.

  • The input re.

  • A list vars of three character vectors of covariate names of the three covariate types.

  • A boolean ASC, determining whether the model has ASCs.

See also

overview_effects() for an overview of the model effects

Examples

form <- choice ~ price + time + comfort + change
re <- c("price", "time")
RprobitB:::check_form(form = form, re = re)
#> $form
#> choice ~ price + time + comfort + change
#> <environment: 0x7fa7401b96d0>
#> 
#> $choice
#> [1] "choice"
#> 
#> $re
#> [1] "price" "time" 
#> 
#> $vars
#> $vars[[1]]
#> [1] "price"   "time"    "comfort" "change" 
#> 
#> $vars[[2]]
#> character(0)
#> 
#> $vars[[3]]
#> character(0)
#> 
#> 
#> $ASC
#> [1] TRUE
#>