# Example 1
# Generating some random values with
# known mu and sigma
y <- rCJ2(n=500, mu=1, sigma=1.5)
# Fitting the model
require(gamlss)
mod1 <- gamlss(y~1, sigma.fo=~1, family=CJ2,
control=gamlss.control(n.cyc=5000, trace=TRUE))
# Extracting the fitted values for mu, sigma
# using the inverse link function
exp(coef(mod1, what="mu"))
exp(coef(mod1, what="sigma"))
# Example 2
# Generating random values under some model
gendat <- function(n) {
x1 <- runif(n, min=0, max=5)
x2 <- runif(n, min=0, max=5)
mu <- exp(-0.2 + 1.5 * x1)
sigma <- exp(1 - 0.7 * x2)
y <- rCJ2(n=n, mu, sigma)
data.frame(y=y, x1=x1, x2=x2)
}
set.seed(123)
datos <- gendat(n=500)
mod2 <- gamlss(y~x1, sigma.fo=~x2, family=CJ2, data=datos,
control=gamlss.control(n.cyc=5000, trace=TRUE))
summary(mod2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.