有人可以给我一些如何解决此问题的建议吗?因此,我有200 x 100的矩阵(X_i),我应该得到具有200个元素的向量Y_i。 epsilon_i也是具有200个元素的向量。因此,我需要将beta与矩阵X_i相乘,然后将其从0积分到1。如何用R做到这一点?如前所述,我已经有了X_i(在代码中为polynom.X和fourier.X)。
library(fda)
library(fda.usc)
t <- seq(0, 1, length = 100)
beta.1t <- matrix(rep(0, 100), nrow = 100)
plot(t, beta.1t, type = "l")
beta.2t <- matrix((t >= 0 & t < 0.342) * ((t - 0.5)^2 - 0.025) +
(t >= 0.342 & t <= 0.658) * 0 +
(t > 0.658 & t <= 1) * (-(t - 0.5)^2 + 0.025), ncol = 100)
plot(t, beta.2t, type = "l")
# beta2 <- matrix(rep(beta.2t, 200), ncol = 200)
# matplot(beta2)
beta.3t <- matrix(t^3 - 1.6 * t^2 + 0.76 * t + 1, nrow = 100)
plot(t, beta.3t, type = "l")
N <- 200
n.fourier <- 5
n.polynom <- 3
mju <- 0
sigma <- 1
fourier.sim <- t(fourier(t, n.fourier, period = 1))
fourier.coeffs <- matrix(rnorm(N * n.fourier, mju, sigma), ncol = n.fourier)
fourier.X <- fourier.coeffs %*% fourier.sim
polynom.sim <- poly(t, n.polynom)
polynom.sim <- t(cbind(rep(1, 100), polynom.sim))
polynom.coeffs <- matrix(rnorm(N * (n.polynom + 1), mju, sigma), ncol = n.polynom + 1)
polynom.X <- polynom.coeffs %*% polynom.sim