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