set.seed(2026)
rows <- 200
x1 <- rnorm(rows, mean=2.5, sd=1)
x2 <- runif(rows, 0, 1)
X <- cbind(x1,x2)
t_beta <- c(0.5, 2)
t_sigma <- 1
######################
# #
# Extreme value case #
# #
######################
t_lambda <- -1
error <- rglg(rows, 0, 1, t_lambda)
y1 <- error
y1 <- X %*%t_beta + t_sigma*error
data.example <- data.frame(y1,X)
fit <- glg(y1 ~ x1 + x2 - 1, data=data.example)
fit$condition
logLik(fit)
summary(fit)
deviance_residuals(fit)
#############################
# #
# Normal case: A limit case #
# #
#############################
# When the parameter lambda goes to zero the GLG tends to a normal distribution.
set.seed(2026)
y1 <- X %*%t_beta + rnorm(rows, mean=0, sd=0.5)
data.example <- data.frame(y1, X)
fit0 <- glg(y1 ~ x1 + x2 - 1,data=data.example)
fit0$mu
fit0$sigma
fit0$lambda
fit0$llglg
fit0$AIC
############################################
# #
# A comparison with a normal linear model #
# #
############################################
fit2 <- lm(y1 ~ x1 + x2 - 1,data=data.example)
coefficients(fit2)
logLik(fit2)
AIC(fit2)
Run the code above in your browser using DataLab