FLXMRhyreg: M-step driver to be used in flexmix

View source: R/FLXMRhyreg.R

FLXMRhyregR Documentation

M-step driver to be used in flexmix

Description

Function used in flexmix M-Step to estimate hybrid model

Usage

FLXMRhyreg(
  formula = . ~ .,
  family = c("hyreg"),
  type = NULL,
  type_cont = NULL,
  type_dich = NULL,
  variables_both = NULL,
  variables_cont = NULL,
  variables_dich = NULL,
  stv = NULL,
  offset = NULL,
  opt_method = "BFGS",
  optimizer = "optim",
  lower = -Inf,
  upper = Inf,
  ...
)

Arguments

formula

linear model formula

family

default "hyreg", needed for flexmix::flexmix()

type

character vector containing the indicator whether that datapoint (row) contains continuous or dichotomous data, see Details of hyreg2

type_cont

value of type referring to continuous data, see Details of hyreg2

type_dich

value of type referring to dichotomous data, see Details of hyreg2

variables_both

character vector; variables to be fitted on both continuous and dichotomous data. see Details of hyreg2

variables_cont

character vector; variables to be fitted only on continous data. see Details of hyreg2

variables_dich

character vactor; variables to be fitted only on dichotomous data. see Details of hyreg2

stv

⁠named vector⁠ or list of named vectors containing start values for all coefficients from formula, including theta, see Details of hyreg2

offset

offset as in flexmix::flexmix(), default NULL

opt_method

character, optimization method to be used in optimizer, default "BFGS"

optimizer

character, optimizer to be used in bbmle::mle2(), default "optim"

lower

lower bound for censored data. If this is used, opt_method must be set to "L-BFGS-B", default -INF,

upper

upper bound for censored data. If this is used, opt_method must be set to "L-BFGS-B",default INF

...

additional arguments for flexmix::flexmix() or bbmle::mle2()

Value

a model object, that can be used in hyreg2 as input for parameter model in flexmix::flexmix()

a model object, that can be used in hyreg2 as input for parameter model in flexmix::flexmix

Author(s)

Svenja Elkenkamp and Kim Rand

Examples


formula <- y ~  -1 + x1 + x2 + x3
the$k <- 2
stv <- setNames(c(0.2,0,1,1,1),c(colnames(simulated_data_norm)[3:5],c("sigma","theta")))



x <- model.matrix(formula,simulated_data_norm)
y <- simulated_data_norm$y
w <- 1
model <- FLXMRhyreg(formula = formula,
                    family=c("hyreg"),
                    type =  simulated_data_norm$type,
                    stv = stv,
                    type_cont = "TTO",
                    type_dich = "DCE_A",
                    opt_method = "L-BFGS-B",
                    control = list(iter.max = 1000, verbose = 4),
                    offset = NULL,
                    optimizer = "optim",
                    variables_both =  names(stv)[!is.element(names(stv),c("sigma","theta"))],
                    variables_cont = NULL,
                    variables_dich = NULL,
                    lower = -Inf,
                    upper = Inf,
)

hyreg2 documentation built on Nov. 5, 2025, 7:38 p.m.

Related to FLXMRhyreg in hyreg2...