# Ex. 1 Normal model
# Quantile function of a linear model.
Qlinmod <- function(theta, tau, data){
sigma <- exp(theta[1])
beta <- theta[-1]
X <- model.matrix( ~ x1 + x2, data = data)
qnorm(tau, X %*% beta, sigma)
}
n <- 100
x1 <- rnorm(n)
x2 <- runif(n,0,3)
theta <- c(1,4,1,2)
# generate the data
U <- runif(n)
y <- Qlinmod(theta, U, data.frame(x1,x2))
# Given y and theta, evaluate U = F(y)
invQ(Qlinmod, theta, y, data.frame(x1,x2))
Run the code above in your browser using DataLab