set.seed(22)
rows <- 300
x1 <- rbinom(rows, 1, 0.5)
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)
data.example <- data.frame(y1)
fit <- glg(y1 ~ x1 + x2 - 1, data=data.example)
logLik(fit) # -449.47 # Time: 14 milliseconds
summary(fit)
deviance_residuals(fit)
#############################
# #
# Normal case: A limit case #
# #
#############################
# When the parameter lambda goes to zero the GLG tends to a standard normal distribution.
set.seed(8142031)
y1 <- X %*%t_beta + t_sigma * rnorm(rows)
data.example <- data.frame(y1, X)
fit0 <- glg(y1 ~ x1 + x2 - 1,data=data.example)
logLik(fit0)
fit0$AIC
fit0$mu
############################################
# #
# A comparison with a normal linear model #
# #
############################################
fit2 <- lm(y1 ~ x1 + x2 - 1,data=data.example)
logLik(fit2)
AIC(fit2)
coefficients(fit2)
Run the code above in your browser using DataLab