The Beta Rectangular family

BER2(mu.link = "logit", sigma.link = "log", nu.link = "logit")

Arguments

defines the mu.link, with "logit" link as the default for the mu parameter.

defines the sigma.link, with "log" link as the default for the sigma parameter.

defines the nu.link, with "logit" link as the default for the nu parameter.

Value

Returns a gamlss.family object which can be used to fit a BER2 distribution in the gamlss() function.

Details

The Beta Rectangular distribution with parameters mu, sigma and nu has density given by

\(f(x| \mu, \sigma, \nu) = \nu + (1 - \nu) b(x| \mu, \sigma)\)

for \(0 < x < 1\), \(0 < \mu < 1\), \(\sigma > 0\) and \(0 < \nu < 1\). The function \(b(.)\) corresponds to the traditional beta distribution that can be computed by dbeta(x, shape1=mu*sigma, shape2=(1-mu)*sigma).

References

Bayes, C. L., Bazán, J. L., & García, C. (2012). A new robust regression model for proportions. Bayesian Analysis, 7(4), 841-866.

See also

Examples

# Example 1
# Generating some random values with
# known mu and sigma
y <- rBER2(n=500, mu=0.3, sigma=7, nu=0.4)

# Fitting the model
library(gamlss)
mod1 <- gamlss(y~1, family=BER2,
               control=gamlss.control(n.cyc=500, trace=FALSE))

# Extracting the fitted values for mu, sigma and nu
# using the inverse link function
inv_logit <- function(x) 1/(1 + exp(-x))

inv_logit(coef(mod1, what="mu"))
#> (Intercept) 
#>    0.308236 
exp(coef(mod1, what="sigma"))
#> (Intercept) 
#>    7.615987 
inv_logit(coef(mod1, what="nu"))
#> (Intercept) 
#>   0.4306585 

# Example 2
# Generating random values under some model

# A function to simulate a data set with Y ~ BER2
gendat <- function(n) {
  x1 <- runif(n, min=0.4, max=0.6)
  x2 <- runif(n, min=0.4, max=0.6)
  x3 <- runif(n, min=0.4, max=0.6)
  mu    <- inv_logit(-0.5 + 1*x1)
  sigma <- exp(-1 + 4.8*x2)
  nu    <- inv_logit(-1 + 0.5*x3)
  y <- rBER2(n=n, mu=mu, sigma=sigma, nu=nu)
  data.frame(y=y, x1=x1, x2=x2, x3=x3)
}

set.seed(1234)
datos <- gendat(n=500)

mod2 <- gamlss(y~x1, sigma.fo=~x2, nu.fo=~x3,
               family=BER2, data=datos,
               control=gamlss.control(n.cyc=500, trace=TRUE))
#> GAMLSS-RS iteration 1: Global Deviance = -90.418 
#> GAMLSS-RS iteration 2: Global Deviance = -96.1237 
#> GAMLSS-RS iteration 3: Global Deviance = -97.1965 
#> GAMLSS-RS iteration 4: Global Deviance = -97.6005 
#> GAMLSS-RS iteration 5: Global Deviance = -97.7652 
#> GAMLSS-RS iteration 6: Global Deviance = -97.8373 
#> GAMLSS-RS iteration 7: Global Deviance = -97.8705 
#> GAMLSS-RS iteration 8: Global Deviance = -97.8863 
#> GAMLSS-RS iteration 9: Global Deviance = -97.894 
#> GAMLSS-RS iteration 10: Global Deviance = -97.8978 
#> GAMLSS-RS iteration 11: Global Deviance = -97.8997 
#> GAMLSS-RS iteration 12: Global Deviance = -97.9006 

summary(mod2)
#> Warning: summary: vcov has failed, option qr is used instead
#> ******************************************************************
#> Family:  c("BER2", "Beta Rectangular") 
#> 
#> Call:  gamlss(formula = y ~ x1, sigma.formula = ~x2, nu.formula = ~x3,  
#>     family = BER2, data = datos, control = gamlss.control(n.cyc = 500,  
#>         trace = TRUE)) 
#> 
#> Fitting method: RS() 
#> 
#> ------------------------------------------------------------------
#> Mu link function:  logit
#> Mu Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  -1.2736     0.3702  -3.441 0.000629 ***
#> x1            2.4459     0.7282   3.359 0.000842 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> ------------------------------------------------------------------
#> Sigma link function:  log
#> Sigma Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  -1.1771     0.6874  -1.713 0.087413 .  
#> x2            5.2434     1.3788   3.803 0.000161 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> ------------------------------------------------------------------
#> Nu link function:  logit 
#> Nu Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)
#> (Intercept)    3.069      3.216   0.954    0.340
#> x3            -8.918      6.676  -1.336    0.182
#> 
#> ------------------------------------------------------------------
#> No. of observations in the fit:  500 
#> Degrees of Freedom for the fit:  6
#>       Residual Deg. of Freedom:  494 
#>                       at cycle:  12 
#>  
#> Global Deviance:     -97.90057 
#>             AIC:     -85.90057 
#>             SBC:     -60.61292 
#> ******************************************************************