First create a file like this:


#$ -N Splustest
#$ -l Splus=1,h_cpu=10:00:00
set
cd $TMPDIR

# need to make a unique Splus chapter for the run
# use $TMPDIR provided by SGE, guaranteed to be unique.

Splus CHAPTER -d $TMPDIR
Splus < /homedir/is/fac/nwhite/splustest.ssc
cat $TMPDIR/result.ps >>/homedir/is/fac/nwhite/result.ps

Here is the input file

set.seed(100)
#set initial seed for random number generator

n<-10000
x<-(1:n)/n    
#we will use 100 equally spaced design point from 0 to 1

true<-((exp(x/3)-2*exp(-7*x)+sin(9*x))+1)/3
#true function in this simulation

noise<-rnorm(n,0,0.1)
#generate n independent normal random number with 0 mean and variance 0.1

y<-true+noise
#y is observed values (true value + noise)

#or you can read data from a file:
#dat<-read.table("hw1.dat",header=T)
#attach(dat)

fit <- smooth.spline(x,y,cv=F,all.knots=T)
#fit smooth spline on noisy data
#use GCV score and all basis functions

postscript("/homedir/is/fac/nwhite/result.ps",height=8,width=10,horizo=F)
#initialize graphic output 
#(PS file for print, you can use Ghostview to preview it)
#alternatively, you can use motif() to view it on screen

plot(x,y,xlab="x",ylab="y",cex=0.5)
#plot data point
lines(x,true,lty=2)
#plot true function
lines(fit$x,fit$y)
#plot smooth spline fit

graphics.off()
#output to PS file
#if you use motif(), you can shut down motif window by using dev.off()