cub: cub

Description Usage Arguments Examples

View source: R/cub.R

Description

function to fit a cub model. The user could use covariates or not to model the parameters pi and xi.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cub(
  pi.fo,
  xi.fo,
  m,
  data = NULL,
  subset = NULL,
  optimizer = "nlminb",
  pi.link = "probit",
  xi.link = "probit",
  initial.values = NULL,
  ...
)

Arguments

pi.fo

an object of class formula, a symbolic description of the model to fit pi parameter.

xi.fo

an object of class formula, a symbolic description of the model to fit xi parameter without left side.

m

the maximum value of the response variable.

data

an optional data frame.

subset

an optional vector specifying a subset of observations to be used. For example, subset = "sex =='male'" means that we want to use only the male data set.

optimizer

two options are available: nlminb (default), optim or DEoptim.

pi.link

link function to use for model pi parameter, two options are available, logit or probit, by default is probit.

xi.link

link function to use for model xi parameter, two options are available, logit or probit, by default is probit.

initial.values

vector with the initial values to the searching procedure to nlminb and optim optimizers.

...

Further arguments to be passed to DEoptim.control.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Example 1 ---------------------------------------------------------------
# Generating a random sample given the values of pi and xi
set.seed(2019)
y <- rcub(n=100, pi=0.15, xi=0.60, m=5)
mod1 <- cub(pi.fo=y ~ 1, xi.fo=~ 1, m=5,
            pi.link='probit', xi.link='probit', 
            optimizer='nlminb')
summary(mod1)

# estimations for pi and xi
pnorm(mod1$par[1])
pnorm(mod1$par[2])

# Example 2 ---------------------------------------------------------------
# Generating a random sample given the values of pi and xi 
# estimation using logit link function
set.seed(2019)
y <- rcub(n=100, pi=0.15, xi=0.60, m=5)
mod2 <- cub(pi.fo=y ~ 1, xi.fo=~ 1, m=5, 
            pi.link='logit', xi.link='logit', 
            optimizer='nlminb')
summary(mod2)

# estimations for pi and xi
boot::inv.logit(mod2$par[1])
boot::inv.logit(mod2$par[2])

# Example 3 ---------------------------------------------------------------
# Generating a random sample given the values of pi and xi 
# estimation using logit and probit as link function
set.seed(2019)
y <- rcub(n=100, pi=0.15, xi=0.60, m=5)
mod3 <- cub(pi.fo=y ~ 1, xi.fo=~ 1, m=5, 
            pi.link='logit', xi.link='probit',
            optimizer='nlminb')
summary(mod3)
# estimations for pi and xi
boot::inv.logit(mod3$par[1])
pnorm(mod3$par[2])

fhernanb/cubm documentation built on Dec. 10, 2020, 1:24 p.m.