oldpar <- par(no.readonly=TRUE)
# carry out a PCA of temperature
# penalize harmonic acceleration, use varimax rotation
daybasis65 <- create.fourier.basis(c(0, 365), nbasis=65, period=365)
harmaccelLfd <- vec2Lfd(c(0,(2*pi/365)^2,0), c(0, 365))
harmfdPar <- fdPar(fd(matrix(0,65,1), daybasis65), harmaccelLfd, lambda=1e5)
daytempfd <- smooth.basis(day.5, CanadianWeather$dailyAv[,,"Temperature.C"],
daybasis65, fdnames=list("Day", "Station", "Deg C"))$fd
daytemppcaobj <- pca.fd(daytempfd, nharm=4, harmfdPar)
# plot harmonics, asking before each new page after the first:
plot.pca.fd(daytemppcaobj)
# plot 4 on 1 page
par(mfrow=c(2,2))
plot.pca.fd(daytemppcaobj, cex.main=0.9)
par(oldpar)
Run the code above in your browser using DataLab