N=500; # sample size for LHS # Create vector of sample values for each parameter # Here, all 3 params are taken as Uniform(-1,1) x=seq(from=-1,to=1,length=N+1); p=(x[-1]+x[-(N+1)])/2; ## create P matrix ## create P matrix P=rbind(p,p,p); ## shuffle each of the rows P=t(apply(P,1,sample)); # Compute Y values for each column of P # In real applications, you would run your model N times f=function(p) {exp(p[1])+exp(2*p[2])+exp(3*p[3])} Y=apply(P,2,f); require(mgcv); par1=P[1,]; par2=P[2,]; par3=P[3,]; fit1=gam(Y~s(par1)+s(par2)+s(par3)); out1=predict(fit1,type="terms"); apply(out1,2,var)^0.5; # Compute different Y values for each column of P f=function(p) {exp(p[1])+exp(2*p[2])+exp(3*p[1]*p[3])} Y=apply(P,2,f); require(mgcv); par1=P[1,]; par2=P[2,]; par3=P[3,]; fit2=gam(Y~s(par1)+s(par2)+s(par3)); out2=predict(fit2,type="terms"); apply(out2,2,var)^0.5;