ST3454 with R

Notes for Stochastic processes in space and time
Kriging with GSTAT package

  1. The meuse data set: a brief tutorial for the gstat R package, Edzer Pebesma, 2015 with corresponding R code for convenience. Read the tutorial proposed by E. Pebesma (doc 2) up to section 7.
  2. A Practical Guide to Geostatistical Mapping by Tomislav Hengl 2009. Read overviews of R and Google Earth in Hengl's book (e.g. section 3.2 pages 72 to 77, and section 3.3 pages 78 to 87)
  3. meuse_lead.kml: Meuse dataset locations data in KML format to visualise with Google earth
  4. Other: QGIS: A Free and Open Source Geographic Information System

Nadaraya-Watson

Run and understand the following code (i.e. copy the code in a R script and insert comment lines) :


with(cars, {

plot(speed, dist)

lines(ksmooth(speed, dist, "normal", bandwidth = 2), col = 2)

lines(ksmooth(speed, dist, "normal", bandwidth = 5), col = 3)

})

Comment on the effect of changing the bandwidth. Change the kernel and comment.

Regression on basis of functions Install and load in memory the fda package (and its dependencies). Run and understand the following code (i.e. copy the code in a R script and insert comment lines):

gaitbasis3 <- create.fourier.basis(nbasis=5)

gaitfd3 <- Data2fd(gait[,1,1], basisobj=gaitbasis3,nderiv=0)

plotfit.fd(gait[,1,1], seq(0,1,len=20), gaitfd3)

Plot the basis of functions used for regression. Increase the number of functions used for regression. Change the Fourier basis (e.g. to bspline).
Finding period(s) in noisy time series In R we create a time series as follow:

N<-1000

t<-seq(1,N)

Noise <- rnorm(N)

PureSine <- 3*sin(2*pi*t/5)

NoisySine <- PureSine+Noise

freq<- t/N
	
Look at the help file associated with any function you are not familiar with.
  1. Visualise the time plot of these time series (Noise, PureSine, NoisySine ) e.g.
    
    windows(5,5)
    
    plot(t, Noise,type="l",main="time plot : Noise ")
    
    
    Do you notice any obvious seasonal behaviour in these time series?
  2. Visualise the Power Spectrum of these of these time series (Noise, PureSine, NoisySine ) e.g.
    
    windows(5,5)
    
    plot(freq,Mod(fft(NoisySine)),type="l",main="DFT: NoisySine")
    
    
    Can you see any seasonal pattern now in the Fourier domain? At what frequencies? Does it make sense (considering the definition of PureSine)? Comment on the Power Spectrum of the Noise.
  3. Create a Noise with higher standard deviation (see rnorm help file). What is the impact on the power Spectrum?

ST3452 with R

Notes for Generalized Linear models