set.seed(1)
rows<- 300
t_beta <- c(0.5,2)
t_sigma <- 0.5
t_lambda <- 1
x1 <- runif(rows,-3,3)
x2 <- rnorm(rows,mean=2.5,sd=0.5)
X <- cbind(x1,x2)
t <- as.matrix(seq(0.01,0.99,length=rows))
colnames(t) <- "t"
f_t <- cos(4*pi*t)
plot(t,f_t,type='l')
error <- rglg(rows,0,1,t_lambda)
y <- X %*%t_beta + f_t + t_sigma*error
colnames(y) <- "y"
data <- data.frame(y,X,t)
fit1 <- sglg(y ~ x1 + x2 - 1, npc=t, data=data, basis = "Gu", alpha0=0.001)
# The adjusted (black) non-linear component
plotnpc(fit1,conf_lev=0.02)
Run the code above in your browser using DataLab