# \donttest{
#Set seed, sample size and type of copula
set.seed(1337)
N=500 #Sample size
cop="gumbel" #copula
rot=180 #rotation
#Generate covariates
x1<-runif(N,-1,1); x2<-runif(N,-1,1)
#Set parameters of the copula
eta<-matrix(1+2.5*x1+1.75*sin(pi*x2),nrow=N)
delta<-transform(x=eta, type="glogitinv", par=as.numeric(delta_bounds(cop)), deriv_order = 0)
#Simulate pseudo observations W and create dataset
dat<-as.data.frame(rcop(n=N, delta=delta, distr=cop, rot=rot))
dat$y<-1 #Add dummy response variable
#Write formulae for parameters
delta_formula<-y~x1+s(x2,bs="ps")
#Fit model
model<-mgcv::gam(delta_formula, data=dat,
family=cop(W=dat[,1:2],
distr=cop, rot=rot),
optimizer="efs")
#Smooth effects
#Effect of x2 on the predictor of delta
plot(model, select=1) #Estimated function
lines(x2[order(x2)], 1.75*sin(pi*x2[order(x2)])-
mean(1.75*sin(pi*x2)), col=2) #True effect
# }
Run the code above in your browser using DataLab