Created
September 30, 2015 15:37
-
-
Save krenz444/bc50afe2ff6fb3f2b9a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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(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) | |
daytemppcaVarmx <- varmx.pca.fd(daytemppcaobj) | |
# plot harmonics | |
op <- par(mfrow=c(2,2)) | |
plot.pca.fd(daytemppcaobj, cex.main=0.9) | |
plot.pca.fd(daytemppcaVarmx, cex.main=0.9) | |
par(op) | |
plot(daytemppcaobj$harmonics) | |
plot(daytemppcaVarmx$harmonics) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment