## Load data
data(SimulatedData)
attach(SimulatedData)
y = SimulatedData$y
t = SimulatedData$t
id = SimulatedData$id
X = SimulatedData[,4:103]
## Fit frequentist penalized NVC model with the SCAD penalty.
## Can set penalty as "gLASSO", "gSCAD", or "gMCP".
## No need to specify an 'id' argument when using NVC_frequentist() function
NVC_gSCAD_mod = NVC_frequentist(y, t, X, penalty="gSCAD")
## Classifications. First varying coefficients are selected as nonzero
NVC_gSCAD_mod$classifications
## Optimal lambda chosen from BIC
NVC_gSCAD_mod$lambda_min
## Plot first estimated varying coefficient function
t_ordered = NVC_gSCAD_mod$t_ordered
beta_hat= NVC_gSCAD_mod$beta_hat
plot(t_ordered, beta_hat[,1], lwd=3, type='l', col='blue',
xlab="Time", ylim = c(-12,12), ylab=expression(beta[1]))
## Plot third estimated varying coefficient function
plot(t_ordered, beta_hat[,3], lwd=3, type='l', col='blue',
xlab="Time", ylim = c(-4,2), ylab=expression(beta[3]))
## Plot fifth estimated varying coefficient function
plot(t_ordered, beta_hat[,5], lwd=3, type='l', col='blue',
xlab="Time", ylim = c(0,15), ylab=expression(beta[5]))
Run the code above in your browser using DataLab