R语言 将调和函数作为平均值的扰动来绘制

50few1ms  于 2023-11-14  发布在  其他
关注(0)|答案(1)|浏览(125)

我目前正在尝试绘制第一和第二谐波(如Ramsay - FDA中使用R和MATLAB所描述的)。理想情况下,它应该看起来像下面的图像-x1c 0d1x到目前为止,这是我的设置-

handpartx <- handwrit[,,1]
handparty <- handwrit[,,2]
curv.Lfd <- int2Lfd(2)
lambda <- 1e-2
breaks <- seq(min(handwritTime), max(handwritTime), length.out = 100)
xbasis <- create.bspline.basis(range(handwritTime), norder = 6,
                               breaks = breaks)
ybasis <- create.bspline.basis(range(handwritTime), norder = 6,
                               breaks = breaks)

curvx.fdPar <- fdPar(xbasis, curv.Lfd, lambda)
curvy.fdPar <- fdPar(ybasis, curv.Lfd, lambda)

handxsmooth <- smooth.basis(handwritTime, handpartx, curvx.fdPar)
handysmooth <- smooth.basis(handwritTime, handparty, curvy.fdPar)
mean_x <- eval.fd(fdobj = mean.fd(handxsmooth$fd), evalarg = handwritTime)
mean_y <- eval.fd(fdobj = mean.fd(handysmooth$fd), evalarg = handwritTime)

字符串
对于平均FDA脚本和联合PCA -

zbasis <- smooth.basis(handwritTime, handwrit, curvx.fdPar)$fd
zbasis$fdnames[[1]] <- "Time"
zbasis$fdnames[[2]] <- "Replications"
zbasis$fdnames[[3]] <- list("X", "Y")

nharm <- 10
handPCA <- pca.fd(zbasis, nharm)


有人能指出我是如何把谐波的变化加到平均值上的吗?或者更好的方法来重写我现在的代码。提前感谢!

yqlxgs2m

yqlxgs2m1#

显然,有一个预定义的命令已经完成了这项工作-

plot.pca.fd(handPCA, harm = 1, pointplot = FALSE, cycle = TRUE)

字符串
尽管从文档中看,并不清楚cycle参数是否会实现此结果。

相关问题