function to fit a cub model. The user could use covariates or not to model the parameters pi and xi.
cub(pi.fo, xi.fo, m, data = NULL, subset = NULL, optimizer = "nlminb", pi.link = "probit", xi.link = "probit", initial.values = NULL, ...)
pi.fo | an object of class |
---|---|
xi.fo | an object of class |
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, |
optimizer | two options are available: |
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 |
# 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])