Ashish Dalal
13th April, 2016
#installing the package
if(!require(fda.usc)){
install.packages("fda.usc", repos = "http://cran.us.r-project.org")
}
#loading the package
library(fda.usc)
data("tecator")
names(tecator)
[1] "absorp.fdata" "y"
absorp <- tecator$absorp.fdata
Fat20 <- ifelse(tecator$y$Fat < 20, 0, 1) * 2 + 2
plot(tecator$absorp.fdata, col = Fat20)
absorp.d1 <- fdata.deriv(absorp, nderiv = 1)
plot(absorp.d1, col = Fat20)
class(absorp.fd <- fdata2fd(absorp, type.basis= "fourier", nbasis= 15))
[1] "fd"
class(absorp.fdata <- fdata(absorp.fd))
[1] "fdata"
data("phoneme")
learn <- phoneme$learn
l <- c(0, 2^seq(-2, 9, length.out = 30))
nb <- seq(7, 31, by = 2)
out0 <- min.basis(learn, lambda = l, numbasis = nb)
out1 <- min.np(learn, type.S = S.NW, par.CV = list(criteria = "GCV"))
out2 <- min.np(learn, type.S = S.LLR, par.CV = list(criteria = "GCV"))
out3 <- min.np(learn, type.S = S.KNN, h = 3:25, Ker = Ker.unif)
data("poblenou")
nox <- poblenou$nox
dd <- as.integer(poblenou$df$day.week)
working <- poblenou$nox[poblenou$df$day.festive == 0 & dd < 6]
nonworking <- poblenou$nox[poblenou$df$day.festive == 1 | dd > 5]
plot(func.mean(working), ylim = c(10, 170),main = "Centrality measures in working days")
legend(x = 11,y = 185, cex = 1, box.col = "white", lty = 1:5, col = 1:5,legend = c("mean", "trim.mode", "trim.RP", "median.mode", "median.RP"))
lines(func.trim.mode(working, trim = 0.15), col = 2, lty =2)
lines(func.trim.RP(working, trim = 0.15),col = 3,lty = 3)
lines(func.med.mode(working, trim = 0.15),col = 4,lty = 4)
lines(func.med.RP(working, trim = 0.15),col = 5, lty = 5)