"fldafit" <- function(data, q = 5, h = 1, p = 1, tol = 0.001, maxit = 50, pert = 0.10000000000000001, grid = seq(0.01, 1, length = 100)) { # This is the main function to implement the FLDA procedure. initfit <- fldainit(data = data, pert = pert, grid = grid, h = h, p = p, q = q) # Initialize the parameters parameters <- initfit$parameters vars <- initfit$vars S <- initfit$S FullS <- initfit$FullS like.old <- 0 like.new <- 1 ind <- 1 # Main loop. Iterates between M and E steps and stops when the # loglikelihood has converged. while(abs(like.old - like.new)/like.new > tol & (ind <= maxit)) { parameters <- Mstep(parameters, data, vars, S, tol) vars <- Estep(parameters, data, vars, S) like.old <- like.new like.new <- calcobslike(parameters, data, S) print(paste("Iteration ", ind, ", LogLikelihood =", round( like.new, 3))) ind <- ind + 1 } # Enforce parameter constraint (7) constrainedfit <- constraints(data, parameters, vars, FullS) parameters <- constrainedfit$parameters vars <- constrainedfit$vars list(parameters = parameters, vars = vars, S = S, FullS = FullS, like = like.new) } "fldainit" <- function(data, pert = 0, grid = seq(0.01, 1, length = 100), h = 1, p = 2, q = 5 ) { # This function initializes all the parameters. # Produce spline basis matrix FullS <- cbind(1, ns(grid, df = (q - 1))) FullS <- svd(FullS)$u S <- FullS[data$timeindex, ] K <- length(table(data$class)) N <- length(table(data$curve)) points <- matrix(unlist(tapply(1:length(data$curve), data$curve, function(x, S, y, pert, q) { Sij <- S[x, ] yij <- y[x] solve(t(Sij) %*% Sij + pert * diag(q)) %*% t(Sij) %*% yij } , S, data$y, pert, q)), N, q, byrow = T) classmean <- matrix(unlist(tapply(1:N, data$class, function(x, points) { apply(points[x, ], 2, mean) } , points)), K, q, byrow = T) # Initialize lambda.zero, Lambda and alpha as defined in paper. lambda.zero <- apply(classmean, 2, mean) Lambda <- as.matrix(svd(scale(classmean, scale = F))$v[, 1:h]) alpha <- matrix(apply(scale(classmean, scale = F), 1, function(x, Lambda) { t(Lambda) %*% x } , Lambda), K, h, byrow = T) centerpoints <- t(t(points) - lambda.zero - (Lambda %*% t(alpha[data$ class, ]))) # Initialize Theta (from Section 5.1), gamma and sigma # squared. Note the parameter called sigma is actually sigma squared. Theta <- as.matrix(svd(centerpoints)$v[, 1:p]) gamma <- matrix(apply(centerpoints, 1, function(x, Theta) { t(Theta) %*% x } , Theta), N, p, byrow = T) coefs <- Lambda %*% t(alpha[data$class, ]) + Theta %*% t(gamma) + lambda.zero allcoefs <- coefs[, data$curve] sigma <- mean(unlist(tapply(1:length(data$curve), data$curve, function( x, S, allcoefs, y) { Sij <- S[x, ] coefij <- allcoefs[, x[1]] yij <- y[x] (yij - Sij %*% coefij)^2 } , S, allcoefs, data$y))) # Initialize D and gprod. gprod is the expected value of gamma %*% t(gamma). D <- apply(gamma^2, 2, mean) if(length(D) == 1) D <- as.matrix(D) gprod <- array(unlist(tapply(1:length(data$curve), data$curve, function(x, S, D, Theta, sigma, gamma, data) { Sij <- S[x, ] Cgamma <- solve(diag(1/D) + t(Theta) %*% t(Sij) %*% Sij %*% Theta/sigma) gammaij <- gamma[data$curve[x[1]], ] gammaij %*% t(gammaij) + Cgamma } , S, D, Theta, sigma, gamma, data)), c(p, p, N)) list(S = S, FullS = FullS, parameters = list(lambda.zero = lambda.zero, Lambda = Lambda, alpha = alpha, Theta = Theta, sigma = sigma, D = D), vars = list(gamma = gamma, gprod = gprod)) } "Mstep" <- function(parameters, data, vars, S, tol) { # This function implements the M step of the EM algorithm. This is # performed in two parts using step1 and step2. parameters <- step1(parameters, data, vars, S) parameters <- step2(parameters, data, vars, S, tol) parameters } "step1" <- function(parameters, data, vars, S) { # This function calculates the variance terms sigma and D. lambda.zero <- parameters$lambda.zero Lambda <- parameters$Lambda alpha <- parameters$alpha Theta <- parameters$Theta gamma <- vars$gamma gprod <- vars$gprod sigma <- parameters$sigma N <- dim(gamma)[1] p <- dim(gamma)[2] gammasq <- apply(gprod, 3, diag) # Calculate D. if(is.matrix(gammasq)) D <- as.vector(apply(gammasq, 1, mean)) else D <- as.matrix(mean(gammasq)) coefs <- Lambda %*% t(alpha[data$class, ]) + Theta %*% t(gamma) + lambda.zero allcoefs <- coefs[, data$curve] # Calculate sigma. parameters$sigma <- mean(unlist(tapply(1:length(data$curve), data$ curve, function(x, S, allcoefs, y, D, Theta, sigma) { Sij <- S[x, ] coefij <- allcoefs[, x[1]] yij <- y[x] (yij - Sij %*% coefij)^2 + diag(Sij %*% Theta %*% solve(diag( 1/D) + t(Theta) %*% t(Sij) %*% Sij %*% Theta/sigma) %*% t(Theta) %*% t(Sij)) } , S, allcoefs, data$y, D, Theta, sigma))) parameters$D <- D parameters } "step2" <- function(parameters, data, vars, S, tol) { # This function calculates lambda.zero, alpha, Lambda, and # Theta. It iterates between step2a and step2b until the # parameters have converged. Step2a calculates # Theta and lambda.zero while step2b calculates Lambda and alpha. R.old <- 2 R.new <- 1 class <- data$class curve <- data$curve q <- dim(S)[2] while(abs(R.old - R.new)/R.new > tol) { parameters <- step2a(parameters, data, vars, S, tol) parameters <- step2b(parameters, data, vars, S, tol) R.old <- R.new par <- parameters predy <- (S * t(par$lambda.zero + par$Lambda %*% t(par$alpha[ class[curve], ]) + par$Theta %*% t(vars$gamma[curve, ]))) %*% rep(1., q) R.new <- sum((data$y - predy)^2) } parameters } "step2a" <- function(parameters, data, vars, S, tol) { # This function calculates Theta and lambda.zero. y <- data$y alpha <- parameters$alpha Lambda <- parameters$Lambda Theta <- parameters$Theta gamma <- vars$gamma gprod <- vars$gprod curve <- data$curve class <- data$class q <- dim(S)[2] partial.centy <- y - (S * ((alpha %*% t(Lambda))[class[curve], ] + (gamma %*% t(Theta))[curve, ])) %*% rep(1, q) # Calculate lambda.zero lambda.zero <- solve(t(S) %*% S) %*% t(S) %*% partial.centy centy <- y - S %*% lambda.zero - (S * ((alpha %*% t(Lambda))[class[ curve], ])) %*% rep(1, q) R.old <- 2 R.new <- 1 p <- dim(gamma)[2.] # Calculate Theta. This is done by iterating through calculating each column # of Theta holding the other columns fixed. while(abs(R.old - R.new)/R.new > tol) { for(j in 1.:p) { ind <- rep(1., p) ind[j] <- 0. gammay <- gamma[curve, j] * centy - ((S %*% Theta) * t(matrix(gprod[j, , curve], p, length(curve))) ) %*% ind Sgammaj <- S * sqrt(gprod[j, j, curve]) Theta[, j] <- solve(t(Sgammaj) %*% Sgammaj) %*% t( S) %*% gammay } R.old <- R.new R.new <- sum((centy - ((S %*% Theta) * gamma[curve, ]) %*% rep( 1., p))^2.) } parameters$Theta <- Theta parameters$lambda.zero <- as.vector(lambda.zero) parameters } "step2b" <- function(parameters, data, vars, S, tol) { # This function calculates alpha and Lambda. y <- data$y alpha <- parameters$alpha Lambda <- parameters$Lambda lambda.zero <- parameters$lambda.zero Theta <- parameters$Theta gamma <- vars$gamma gprod <- vars$gprod curve <- data$curve class <- data$class alpha <- parameters$alpha K <- length(table(class)) q <- dim(S)[2] h <- dim(alpha)[2] centy <- y - S %*% lambda.zero - (S * ((gamma %*% t(Theta))[curve, ])) %*% rep(1, q) R.old <- 2 R.new <- 1 # This loop iteratively calculate alpha and then Lambda and stops # when they have converged. while(abs(R.old - R.new)/R.new > tol) { # Calculate alpha given Lambda. for(i in 1.:K) { Si.Lam <- S[class[curve] == i, ] %*% Lambda yi <- centy[class[curve] == i] alpha[i, ] <- solve(t(Si.Lam) %*% Si.Lam) %*% t(Si.Lam ) %*% yi } R.old2 <- 1 R.new2 <- 0 # Calculate Lambda given alpha. This is done by iterating # through each column of Lambda holding the other columns fixed. while(abs(R.old2 - R.new2)/R.new2 > tol) { for(j in 1.:h) { ind <- rep(1., h) ind[j] <- 0. morecenty <- centy - ((S %*% Lambda) * alpha[ class[curve], ]) %*% ind Salpha <- S * alpha[class[curve], j] Lambda[, j] <- solve(t(Salpha) %*% Salpha) %*% t(Salpha) %*% morecenty } R.old2 <- R.new2 R.new2 <- sum((centy - ((S %*% Lambda) * alpha[class[ curve], ]) %*% rep(1., h))^2) } R.old <- R.new R.new <- R.new2 } parameters$alpha <- alpha parameters$Lambda <- Lambda parameters } "Estep" <- function(parameters, data, vars, S) { # This function performs the E step of the EM algorithm by # calculating the expected values of gamma and gamma %*% t(gamma) # given the current parameter estimates. par <- parameters N <- dim(vars$gamma)[1] p <- dim(vars$gamma)[2] h <- dim(parameters$alpha)[2] # Calculate expected value of gamma. gamma <- matrix(unlist(tapply(1:length(data$curve), data$curve, function(x, sigma, D, Theta, S, y, lambda.zero, Lambda, alpha, class, curve, h) { Sij <- S[x, ] A <- Sij %*% Theta centy <- y[x] - Sij %*% lambda.zero - Sij %*% t(t(Lambda) * alpha[class[curve][x[1]], ]) %*% rep(1, h) solve(sigma * diag(1/D) + t(A) %*% A) %*% t(A) %*% centy } , par$sigma, par$D, par$Theta, S, data$y, par$lambda.zero, par$Lambda, par$alpha, data$class, data$curve, h)), N, p, byrow = T) # Calculate expected value of gamma %*% t(gamma). gprod <- array(unlist(tapply(1:length(data$curve), data$curve, function(x, S, D, Theta, sigma, gamma, curve) { Sij <- S[x, ] Cgamma <- solve(diag(1/D) + t(Theta) %*% t(Sij) %*% Sij %*% Theta/sigma) gammaij <- gamma[curve[x[1]], ] gammaij %*% t(gammaij) + Cgamma } , S, par$D, par$Theta, par$sigma, gamma, data$curve)), c(p, p, N)) vars$gamma <- gamma vars$gprod <- gprod vars } "calcobslike" <- function(parameters, data, S) { #This function calculates the observed log likelihood (up to #constants) given current parameter estimates. par <- parameters h <- dim(par$alpha)[2] like <- unlist(tapply(1:length(data$curve), data$curve, function(x, S, D, Theta, sigma, y, lambda.zero, alpha, class, curve, Lambda, h) { Sij <- S[x, ] A <- Sij %*% Theta centy <- y[x] - Sij %*% lambda.zero - Sij %*% t(t(Lambda) * alpha[class[curve][x[1]], ]) %*% rep(1, h) C <- sigma * diag(length(x)) + A %*% diag(D) %*% t(A) t(centy) %*% solve(C) %*% centy + sum(logb(eigen(C, symmetric = T)$value)) } , S, par$D, par$Theta, par$sigma, data$y, par$lambda.zero, par$alpha, data$class, data$curve, par$Lambda, h)) - sum(like)/2 } "constraints" <- function(data, parameters, vars, S) { # This function enforces the constraint (7) from the paper on the # parameters. This means that the alphas can be interpreted as the # number of standard deviations that the groups are apart etc. par <- parameters svdTheta <- svd(par$Theta) par$Theta <- svdTheta$u par$D <- par$D * svdTheta$d^2 vars$gamma <- t(t(svdTheta$d * svdTheta$v) %*% t(vars$gamma)) A <- t(S) %*% solve(par$sigma * diag(dim(S)[1]) + S %*% t(as.vector( par$D) * t(par$Theta)) %*% t(S %*% par$Theta)) %*% S svdA <- svd(A) sqrtA <- diag(sqrt(svdA$d)) %*% t(svdA$u) negsqrtA <- svdA$u %*% diag(1/sqrt(svdA$d)) finalsvd <- svd(sqrtA %*% par$Lambda) par$Lambda <- negsqrtA %*% finalsvd$u if(dim(par$Lambda)[2] > 1) par$alpha <- t(diag(finalsvd$d) %*% t(finalsvd$v) %*% t(par$ alpha)) else par$alpha <- t(t(finalsvd$d * finalsvd$v) %*% t(par$alpha)) meanalpha <- apply(par$alpha, 2, mean) par$alpha <- t(t(par$alpha) - meanalpha) par$lambda.zero <- par$lambda.zero + par$Lambda %*% meanalpha list(parameters = par, vars = vars) } "fldapred" <- function(fit, data) { # This function produces the alpha hats used to provide a low # dimensional pictorial respresentation of each curve. It also # produces a class prediction for each curve. It takes as # input the fit from fldafit and the original data (for training # error rates) or a new data set (for test predictions). par <- fit$parameters S <- fit$FullS[data$timeindex, ] N <- length(data$class) h <- dim(par$alpha)[2] alpha.hat <- matrix(0, N, h) curve <- data$curve K <- dim(fit$par$alpha)[1] distance <- matrix(0, N, K) Calpha <- array(0, c(N, h, h)) for(i in 1:N) { Sij <- S[curve == i, ] yij <- data$y[curve == i] n <- length(yij) Sigma <- par$sigma * diag(n) + Sij %*% par$Theta %*% diag( par$D) %*% t(par$Theta) %*% t(Sij) # Calculate covariance for each alpha hat. InvCalpha <- t(par$Lambda) %*% t(Sij) %*% solve(Sigma) %*% Sij %*% par$Lambda Calpha[i, , ] <- solve(InvCalpha) # Calculate each alpha hat. alpha.hat[i, ] <- Calpha[i, , ] %*% t(par$Lambda) %*% t( Sij) %*% solve(Sigma) %*% (yij - Sij %*% par$ lambda.zero) # Calculate the matrix of distances, relative to the # appropriate metric of each curve from each class centroid. distance[i, ] <- apply(t(fit$par$alpha) - as.vector(alpha.hat[ i, ]), 2, function(x, InvCalpha) { t(x) %*% InvCalpha %*% x } , InvCalpha) } # Calculate final class predictions for each curve. class.pred <- rep(1, N) m <- distance[, 1] for(i in 2:K) { test <- (distance[, i] < m) class.pred[test] <- i m[test] <- distance[test, i] } list(Calpha = Calpha, alpha.hat = alpha.hat, class.pred = class.pred, distance = distance) } "testdata" <- list("class" = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3) , "curve" = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30) , "Lambda" = matrix(c(0.24730773195061709, 0.51967921625471314, 0.38173517220668235, -0.057218897873575779, -0.72095537582904312) , nrow = 5, ncol = 1) , "Theta" = matrix(c(0.61534580440637132, -0.58285320907745175, 1.6471693108723451, -0.76056448836480961, -0.34441897588801434, 0.34604466163651526, -0.082100399319948045 , -1.062182378520208, 2.2067633452381563, 1.7770909113558511) , nrow = 5, ncol = 2) , "alpha" = matrix(c(1, 0, -1) , nrow = 3, ncol = 1) , "gamma" = matrix(c(1.0720954942669303, -0.67034488643394652, 2.2704109002018362, 0.32690661015543815, -0.73880090849605207, -0.63078230710211636, -0.49323111713439866 , 0.94615960180325809, -0.4035777883995188, 1.9405554825118283, 1.396620543010838, -0.370804162653463, -0.12306712790612784, -0.72874784832688633, -2.0554536783033117, 0.60001896859387305, -0.0047757844320472365, 1.079286319954841, -2.5057776373251377, 0.36146189986797495, 0.27441467344868081, -0.91206424637758077, -1.1312094974699498, -0.57347983105777289, -0.12084701754879573, -0.51729004392897715 , 0.76688177010598613, -0.49688220043238068, 0.92704684096345336, 0.51527697844352371, 0.34774172672221942, -0.16437535453002708, 1.6525916536696372, 0.36610485379235252, 1.2187092337197449, -0.78382738990284184, 1.1372262319201933, 0.3738434082185193, -0.64962405039274729, 0.77116666873100181, 1.2882572885412773, 0.31828261213293196, 1.732230453356389, 0.024229957136957251, 0.085853029164094652, 0.31214870664122563, -0.70527635950352519, 1.2957451015342591, -0.29208168286150721, 0.96145577514805824, -0.86285718481084739, -1.0411043047135922, -0.91743097616099711, -1.2051053487884111 , 0.19931335159537142, 0.46569923042786543, -2.4400655660013562, -0.42069585727812747 , -1.8032915443816269, -1.2648636631264898) , nrow = 30, ncol = 2) , "Y" = c(-0.28804195444736247, -0.060479806783910642, 0.090932120501865665, 0.10804255324516462, 0.060556986945978622, -0.008447092174873886, -0.025641182397478725 , -0.059409327285215995, -0.048411091069484616, -0.058277806575697831, -1.2175916550830526, -0.1545286380056124, 0.54489266536760816, 0.66669443715538268, 0.35794536517232284, -0.14213942831064486, -0.5513919358953665, -0.60730361468145155, -0.1264976247137288, 0.74366217480661678, 0.47983595542597385, 0.0947325207102169, -0.18134481662195956, -0.19681345667192401, -0.027174253885533357, 0.16559534440729887, 0.35190441524225397, 0.30471805877102548, -0.077464105137754175, -0.69999192446646541, -0.54724174630763156, 0.057809819620243383, 0.45233216058760412, 0.55891438968018148, 0.38287605185056894, 0.06425231733667798, -0.25664050936261595, -0.39553030996126315, -0.20411271009299142, 0.22226860445002158, 0.59969993343914041, -0.057028996633101764, -0.47771673930489028, -0.56700000661983374 , -0.33999721163310331, 0.065831738165180176, 0.48919324222542249, 0.58347216539797753, 0.077455209020779306, -0.83866652951360876, -0.64164527333124288 , -0.03916448458347882, 0.33925130443847706, 0.42345293332361911, 0.26600138249480471, -0.020880496837838672, -0.25820677832110039, -0.35528036910507316 , -0.15719529047204667, 0.2898045611882859, 0.67576161580527427, 0.1040556003279088, -0.26582615425783362, -0.33672523628038198, -0.13686641210966716, 0.19037982508267293, 0.4423348172185339, 0.42602225839286817, -0.065854342394325305, -0.86396402290909025, 0.15775801936403414, 0.23538808457110022, 0.30247855660176398, 0.36337874005566062, 0.38067280341568216, 0.27226315523594896, 0.090307919910905157, -0.13140525660067676, -0.276033498945573, -0.33820171135637989, -0.077674882834805448, -0.19786020173399205, -0.25805155444936506, -0.28230226910251871, -0.23550795105593939, -0.071484318649378015 , 0.14076791987608966, 0.23488218755303886, 0.098594707660815961, -0.26764684765886265 , 1.3737062468643351, 0.073055860565725939, -0.74709835828169358, -0.89144147591532796 , -0.47639504764077384, 0.26514550609971999, 0.89239559238466304, 0.95424109237284904, 0.082872144578398296, -1.4825080050052606, 1.4529619461211396, 0.67027357140674759, 0.16915969449119891, 0.19667407269890405, 0.4386244484300858, 0.57113855473991271, 0.42232099620633484, 0.081757342032516056, -0.33675748815739337, -0.80425214352155838 , 1.0341754057761543, 0.27503775302304356, -0.21009915754340447, -0.28124597944350149 , -0.039090497227656854, 0.22994506725296521, 0.40551315952005734, 0.335616823693827, -0.016160859273111013, -0.56614778729231396, -0.33952803807605314, -0.03082363499879591, 0.17590232475227119, 0.19830530102732299, 0.066246079666667027, -0.12226014196180993, -0.28700621286270067 , -0.27356639640792568, 0.044900214178738573, 0.56829190708063582, 0.61150735074898954, 0.1608878637531716, -0.13909152952271636, -0.18339239568718563, -0.066049916704820133, 0.10094275411460854, 0.18583291716777584, 0.18659360404863282, 0.023367360911933071, -0.20241076129840332, -0.46734139765037597, -0.012636332455127823, 0.27492409100278392, 0.34314180345626827, 0.19600288724453199, -0.1080285992139961, -0.38816190053234911, -0.39185370407070746, 0.0014881204768875636, 0.68426113522518428, 0.30458744955600225, 0.22722571642904074, 0.22001567928033205, 0.25202313709140506, 0.24571098469363731, 0.13023677237223377, -0.065925249115616993, -0.18536760914388759 , -0.12103877125890583, 0.096052175339961909, -0.42659055832771364, -0.066822627727351605, 0.15621081678915674, 0.20998951540778737, 0.069821342249895182, -0.1557509426919701, -0.3409072481579758, -0.30089712925772638, 0.078164460774070216, 0.64909737037547244, -0.20692483850596538 , 0.025515802527145956, 0.15273874543677401, 0.1613402530507784, 0.10334515782771893, -0.065745538795494385, -0.22510180802292618, -0.23741918271107568 , 0.027802649169326142, 0.46411757265364367, -0.50598615987997941, -0.0057411325848806824, 0.33505666368166936, 0.39213534155877394, 0.21198901375210147, -0.11905473901164206, -0.42513342116862662, -0.44098082084856666 , -0.0060120557956665818, 0.74987965890020014, 0.8400272696168477, 0.29152188037165838, -0.087419111459703228, -0.11966340876215434, 0.063234054670475187, 0.20838050601709684, 0.2561215345483831, 0.17584784916038806, -0.060527409623750195, -0.38751821005449955) , "timeindex" = c(18, 14, 46, 49, 20, 72, 65, 56, 86, 94, 38, 32, 27, 6, 42, 88, 56, 66, 61, 52, 40, 25, 5, 4, 6, 98, 58, 74, 82, 84, 12, 40, 38, 50, 28, 57, 91, 97, 72, 55, 33, 48, 8, 19, 7, 58, 65, 71, 85, 78, 37, 20, 25, 14, 10, 95, 77, 96, 98, 85, 38, 27, 1, 14, 3, 73, 63, 89, 98, 62, 5, 33, 13, 3, 10, 76, 97, 98, 65, 77, 17, 8, 41, 5, 11, 64, 53, 90, 67, 75, 34, 3, 13, 42, 17, 69, 86, 70, 93, 73, 20, 31, 39, 29, 32, 92, 70, 100, 68, 57, 35, 3, 9, 7, 13, 58, 97, 90, 71, 61, 50, 44, 28, 34, 24, 79, 74, 100, 76, 53, 3, 22, 1, 29, 18, 74, 51, 68, 52, 72, 44, 47, 8, 6, 22, 89, 66, 60, 75, 69, 11, 16, 32, 3, 2, 53, 51, 81, 55, 60, 25, 5, 26, 30, 43, 88, 95, 57, 78, 67, 38, 24, 22, 32, 45, 93, 90, 56, 97, 98, 23, 28, 26, 35, 5, 86, 70, 83, 75, 84, 42, 28, 37, 24, 4, 73, 81, 78, 64, 58, 11, 40, 1, 47, 15, 60, 75, 65, 91, 92, 21, 17, 50, 38, 49, 98, 55, 60, 65, 81, 44, 34, 19, 12, 14, 86, 72, 90, 88, 97, 22, 3, 10, 21, 33, 76, 89, 96, 95, 92, 12, 37, 47, 41, 1, 57, 94, 71, 100, 70, 3, 40, 9, 43, 50, 60, 76, 51, 94, 55, 49, 15, 26, 4, 48, 76, 85, 83, 64, 87, 30, 28, 14, 38, 48, 66, 97, 73, 55, 75, 18, 6, 47, 46, 27, 81, 91, 55, 74, 59, 35, 18, 1, 40, 17, 96, 55, 65, 88, 81) , "lambda.zero" = c(0.13921491993651269, -0.63252944608520179, 0.44143124675286904, 0.0038389318649342018, 0.43625030449487034) , "S" = matrix(c(-0.10000000000000009, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001, -0.10000000000000001 , -0.10000000000000001, -0.10000000000000001, -0.10331656151779521, -0.10331197251961949, -0.10327984953239083, -0.10319265856705567, -0.1030228656345609 , -0.10274293674585327, -0.10232533791187962, -0.10174253514358669, -0.10096699445192134, -0.099971181847830298, -0.098727563342260405, -0.097208604946158433, -0.095386772670471159, -0.093234532526145386, -0.090724350524127889, -0.0878286926753655, -0.084520024990804993, -0.080770813481393144, -0.076553524158076758, -0.071840623031802622, -0.066604576113517555, -0.060817849414168304, -0.054452908944701679, -0.047482220716064477, -0.039878250739203494, -0.031613751837451479, -0.022696181132843676, -0.013200396658118509, -0.0032090003804355772, 0.007195405733045411, 0.017930219715164963, 0.028912839598763361, 0.04006066341668104, 0.051291089201758323, 0.062521514986835586, 0.073669338804753293, 0.084651958688351653, 0.095386772670471187, 0.10579117878395222, 0.11578257506163514, 0.12527835953636035, 0.13419593024096813, 0.14245268520829885, 0.14996602247119303, 0.15665334006249096, 0.16243203601503309, 0.16721950836165964, 0.17093315513521115, 0.17349037436852777, 0.17480856409445011, 0.17480856409445011, 0.17349037436852777, 0.1709331551352111, 0.16721950836165961, 0.16243203601503303, 0.15665334006249096, 0.14996602247119298, 0.14245268520829879, 0.13419593024096813, 0.1252783595363603, 0.11578257506163511, 0.10579117878395222, 0.095386772670471159, 0.084651958688351625, 0.073669338804753182, 0.062521514986835502, 0.051291089201758226, 0.040060663416680922, 0.028912839598763264, 0.017930219715164872, 0.0071954057330453174, -0.0032090003804355885, -0.013200396658118532, -0.022696181132843676, -0.031613751837451493, -0.039878250739203508, -0.047482220716064512, -0.054452908944701714, -0.060817849414168339, -0.066604576113517569, -0.071840623031802664, -0.076553524158076813, -0.080770813481393172, -0.084520024990805021, -0.0878286926753655, -0.090724350524127889, -0.093234532526145386, -0.095386772670471159, -0.097208604946158433, -0.098727563342260405, -0.099971181847830298, -0.10096699445192134, -0.10174253514358672, -0.10232533791187962, -0.10274293674585327, -0.1030228656345609 , -0.10319265856705567, -0.10327984953239083, -0.10331197251961957, -0.10331656151779511, -0.039389563032013117, -0.043194402041092067, -0.046989364971729168, -0.050764575745482744, -0.054510158283911078, -0.058216236508572446, -0.06187293434102506, -0.065470375702827197, -0.06899868451553709, -0.072447984700713008, -0.075808400179913193, -0.079070054874695914, -0.082223072706619382, -0.08525757759724191, -0.088163693468121682, -0.090931544240817008, -0.093551253836886103, -0.096012946177887235, -0.098306745185378644, -0.10042277478091863, -0.10235115888606539, -0.10408202142237719, -0.10560548631141224, -0.10691167747472892 , -0.10799071883388532, -0.108832729373794, -0.1094272307452194, -0.10976258448715148 , -0.10982701884914217, -0.10960876208074331, -0.10909604243150695, -0.10827708815098495, -0.10714012748872925, -0.10567338869429178, -0.1038651000172245 , -0.10170348970707931, -0.099176786013408166, -0.096273217185762969, -0.092981011473695668, -0.089288397126758179, -0.085183602394502442, -0.080654855526480371, -0.075690384772243949, -0.070278418381345062, -0.064407184603335638, -0.058064911687767617, -0.051239827884192922, -0.043920161442163493, -0.036094140611231292, -0.027749993640948201, -0.018877719375519447, -0.009508040336176176, 0.00028759727882462583, 0.010435976676572631, 0.020863881064157513, 0.031498093648669005, 0.042265397637196785, 0.053092576236830516, 0.063906412654659808, 0.074633690097774569, 0.08520119177326442, 0.095535700888218958, 0.10556400064972796, 0.11521287426488108, 0.12440910494076796, 0.13307947588447838, 0.141150770303102, 0.14854977140372855, 0.15520326239344764, 0.16103802647934909, 0.16598084686852238, 0.16995850676805738, 0.17289778938504372, 0.17472547792657112, 0.17536835559972921, 0.17476197961014198, 0.17291827344697155, 0.16988848111132987, 0.1657241715672374, 0.16047691377871467, 0.15419827670978206, 0.14693982932446012, 0.13875314058676938, 0.12968977946073026, 0.11980131491036339, 0.10913931589968906, 0.097755351392727841, 0.085700990353500248, 0.073027801746026744, 0.059787354534327854, 0.046031217682424068, 0.031810960154335856, 0.017178150914083694, 0.0021843589256881177, -0.013118846846830417, -0.028679897439451409, -0.044447223888154176, -0.060369257228918588, -0.076394428497723973, -0.092471168730549863, -0.36020683849765756, -0.33230447248823169, -0.30448242460617264, -0.27682101297884598, -0.24940055573361763 , -0.2223013709978543, -0.195603776898922, -0.16938809156418688, -0.14373463312101531 , -0.11872371969677334, -0.094435669418827237, -0.070950800414543269, -0.048349430811287536, -0.026711878736426255, -0.0061184623173258061, 0.013350500318647825, 0.031614691044128326, 0.048593791731749519, 0.0642074842541452, 0.078375450483949061, 0.091017372293795182, 0.10205293155631687, 0.11140181014414824, 0.11898368992992325, 0.1247182527862753, 0.12852574047659177, 0.13039414154542581, 0.13044301886438775, 0.12880705235543141, 0.12562092194050978, 0.12101930754157625, 0.11513688908058411, 0.10810834647948697, 0.10006835966023817, 0.091151608544790624, 0.08149277305509843, 0.071226533113114512, 0.060487568640792161, 0.049410559560084874, 0.038130185792945998, 0.026781127261328933, 0.01549806388718699, 0.0044156755924735919, -0.0063313577008579543, -0.016608356070854275, -0.026280639595561983, -0.035213528353027754, -0.043272342421298161, -0.050322401878419958, -0.056229026802439679, -0.060861983569613844, -0.064193303415025299, -0.066297282432583288, -0.067252663014406966, -0.067138187552615469, -0.066032598439327878, -0.064014638066663201, -0.06116304882674068, -0.057556573111679388, -0.053273953313598403, -0.048393931824616813, -0.042995251036853754, -0.037156653342428334, -0.030956881133459565, -0.024474676802066827, -0.017788782740368974, -0.010977941340485159, -0.0041208949945344513, 0.0027036139053639302, 0.0094168429670909853, 0.01594004979852745, 0.02219449200755437, 0.028101427202052526, 0.03358211298990299, 0.038557806978986475, 0.042957017612393816, 0.046771362454486404, 0.050024953553344187, 0.052742171506499111, 0.054947396911483065, 0.056665010365827967, 0.057919392467065761, 0.058734923812728518, 0.059135985000347946, 0.059146956627456226, 0.05879221929158529, 0.058096153590266972, 0.057083140121033271, 0.055777559481416161, 0.054203792268947656, 0.052386219081159591, 0.050349220515583867, 0.048117177169752764, 0.045714469641197755, 0.043165478527451284, 0.040494584426044894, 0.037726167934510751, 0.034884609650380774, 0.031994290171186809, 0.029079590094460921, -0.0099097790975979511, -0.017374539871380327, -0.024800998807560724, -0.032150854068535344, -0.039385803816701634, -0.046467546214456867, -0.053357779424198219, -0.060018201608322962, -0.066410510929228297, -0.072496405549311457, -0.078237583630969679, -0.083595743336600192, -0.088532582828600243, -0.09300980026936706, -0.096989093821297792, -0.10043216164678981, -0.10330070190824021, -0.10555641276804631, -0.10716099238860534, -0.10807613893231442, -0.10826355056157098 , -0.10768492543877198, -0.10630196172631487, -0.10407635758659677, -0.10096981118201498, -0.096944365258461895, -0.09200375716475287, -0.086232701371082382, -0.079725216102016175, -0.072575319582119949, -0.064877030035959279, -0.056724365688099937, -0.048211344763107622, -0.039431985485548049, -0.030480306079986856, -0.021450324770989793, -0.01243605978312259, -0.0035315293409508139, 0.0051692483309597453, 0.013572255008043387, 0.021583472465734489, 0.029108882479467288, 0.036054466824676022, 0.042326207276795147, 0.047830085611258913, 0.052472083603501633, 0.056158183028957545, 0.058794365663061031, 0.060286613281246293, 0.060540907658947749, 0.05946778766309184, 0.05708260526492491, 0.05350552554001322, 0.048861270655415186, 0.043274562778189321, 0.036870124075393952, 0.029772676714087547, 0.022106942861328575, 0.013997644684175546, 0.0055695043496866515, -0.0030527559750795435, -0.011744414123064591, -0.020380747927210095, -0.028837035220457614, -0.036988553835748714, -0.044710581606024966, -0.051878396364227912, -0.058367275943299206, -0.064052498176180334, -0.068809340895812893, -0.072513081935138418, -0.075038999127098535, -0.076262370304634786, -0.076058473300688753, -0.074302585948202021, -0.070883607576400359, -0.065808994982168925, -0.059147249445740908, -0.050967376747211753, -0.04133838266667697, -0.030329272984232117, -0.018009053479972597, -0.0044467299339940349, 0.010288691873608116, 0.026128206162738223, 0.043002807153301043, 0.060843489065200963, 0.079581246118342427, 0.099147072532629957, 0.11947196252796809, 0.1404869103242613, 0.16212291014141397, 0.1843109561993308, 0.20698204271791604, 0.23006716391707438, 0.25349731401671033, 0.27720348723672794, 0.30111667779703238, 0.32516787991752771, 0.3492880878181186) , nrow = 100, ncol = 5) , "D" = c(1, 1) , "y" = c(-0.27189213601968804, -0.22971164766006127, -0.36780906047370576, -0.3282318157381563, -0.30783160151383826, 0.25906598719239871, 0.11354486489955319, -0.15846784579906967, 0.19056677740675054, -0.050799566964271875, 0.045053518750248919, 0.053029752054790318, 0.05322600063225072, -0.0092256328789964964, 0.06132339998876328, -0.054605797806803108 , 0.030774340383624664, 0.023280824735707063, 0.013988948606180237, 0.030283157701451305, -0.58855719287257491, -0.43502997116602815, -0.7677629018832054 , -0.79739992239256763, -0.73823889092808248, 0.39148816696427169, -0.38319288244460059, 0.22140140397582433, 0.3820678150956055, 0.39330564525070971, -0.17055052283489475, -0.18157990112033742, -0.14972994769096185 , -0.1833449511658814, -0.11229774283498205, -0.10956730783173931, 0.076326289055192675, 0.0043161306031165763, 0.094281621981974678, -0.12600613985549813, 0.39890802061409819, 0.065448252414105484, -0.61501131372997786 , 0.10322108476248365, -0.67622459438940841, -0.24881243154084967, -0.37302428314721137, -0.41973252486119467, -0.024796463440000326, -0.30127363645247146, -0.086923325915163677, -0.010335197116241646, -0.066601566128683481, 0.12327592094588927, 0.20630336662600252, -0.40101431958252909 , 0.150158001782213, -0.43636552338290957, -0.53112794020794973, -0.039002867705315539 , 0.24000186554385278, 0.27472587442054874, -1.051779204053187, -0.20734901104959394, -0.92175004076456535, -0.31789863307595578, -0.30546669033099905 , 0.20984351877878821, 0.69067383533804372, -0.30786374465544025, -0.15225942436823867 , -0.353449142978708, -0.19863090005315398, -0.15850621589667721, -0.19554690895947366 , 0.26036981040925022, -0.10044275486896032, -0.14446655643641007, 0.079608628707615814, 0.27000644829600795, 0.0025807628707868215, 0.21145593477179944, -0.10758864544171219, 0.29729526553568819, 0.12892675877196447, 0.20909283396337483, 0.049666666147038074, -0.17058848962553039, 0.21152248056354253, 0.18550563327205496, -0.59049908772542681, -0.26518350363783705, -0.3657958011216994, -0.60900339053485697 , -0.40754973148534834, 0.246966024103078, 0.31117112754418147, 0.27799876396822992, 0.098367874404173258, 0.35623047406582059, -0.28095493248961206, -0.24780386712123442, -0.3325045547911073, -0.24808233046287614 , -0.26561150736440459, 0.5122334009728513, -0.090904167379581485, 0.72843837429696612, -0.12878511467622583, -0.36731141848197085, 0.082937675775897002, -0.25564612348526183, -0.14254667324753184, -0.17761011500627552 , -0.070150298115448803, -0.11938839049304407, 0.40917856885935278, 0.1964492829576476, -0.15125807207725625, -0.16776592646591343, -0.14087742549750257, 0.083563755050502855, 0.31916499602541426, 0.30550147221354973, 0.22934847970554176, -0.25998835833312445, -0.47684802881313965, 1.496874967917069, -0.39884475865169655, -0.2475358058732601, -0.12323118990221099, 0.087574957133490061, -0.16903589453762383 , 0.14584038629209195, 0.066196593088850161, -0.12879385186681752, 0.026487990720913603, -0.13363850387186529, 0.0037045794083660562, -0.14645832602955977, 0.44798350111114693, 0.3570668165168378, -0.13588763561838899, -0.22234291661771113, 0.42957552945100724, 0.070892606393938545, -0.35511387572964476, -0.14356062429753672, -0.46996541897820948 , -0.42341762204134742, -0.11352963724623669, -0.1416437692537999, -0.22935632445287621, -0.10287708372201665, -0.096246916705729754, -0.22263689159482622, -0.24789317245353518, 0.16650166040892159, -0.16173548021423564 , -0.11490526628223749, -0.19350836215507711, 0.41705052666491671, -0.21301717380892271, -0.24028876335619298, -0.20198393589839064, -0.0063811157034814291 , -0.18997836564885104, 0.037869902982695755, 0.21078625309815363, 0.22647664641571649, -0.22457762204954912, -0.16012706413227826, -0.17256487845787419 , -0.15284349395976191, -0.30969539512040889, 0.55986293142290389, 0.44461357207944718, -0.36461900147114262, 0.72355239893562273, 0.74404860006744611, 0.51336235539920771, 0.60321294565715755, 0.56830674175425855, 0.64394707375707738, -0.096322955343505254, -0.17712451670342394 , -0.42545117003023747, -0.3196793312075954, -0.47603501447146712, -0.27093783885623218, -0.10761788881364476, 0.011951875648458683, -0.030941392585267027 , -0.014431769507213204, -0.55825353468299066, -0.16423070215229701, 0.052349135190623695, -0.049548549624835042, -0.25300668727465975, -0.26762143790065845, 0.25625199783574309, -0.3349554206868004, 0.82111092770378791, -0.20907487089403579, 0.059707050926682437, 0.093263926388287718, 0.27493961801796529, 0.18419954120636434, 0.038105934785156191, 0.0025070686363769558, 0.065107857844668521, 0.16655888567426619, 0.080027832720076159, -0.010529909927891459, 0.076409602996413167, -0.010063524414833366, 0.081956323811767609, 0.083658284307602485, 0.074762795803494667, 0.0081165383907242303, 0.095986903490446848, 0.065507574263402701, 0.15849472753810148, 0.2880666084329993, 0.25222849223556482, -0.010478827564956612, -0.030786692618799766, 0.050560450663285038, 0.028524630169001704, 0.11424553776939196, -0.036136192591184738, 0.81222223224852175, 0.45082214078678384, -0.0039915691391789292, -0.17228685653015494, 0.1422373031640598, -0.0073442625522221958, -0.13024576697477774, -0.10517841834930654 , -0.067673191841051292, -0.023692504934433749, -0.024445706982623619, -0.11132265708359422, -0.059045957945331864, -0.094781612886897598, -0.14276586837573921, 0.45051812072168579, -0.17652693734170322, 0.71005586254293984, -0.17170595546025474, -0.32599229248233175, 0.13178686434925901, -0.15465744260317263, 0.078523373247389658, -0.065059744376152612 , -0.27004339460879995, -0.245235635389183, -0.056102767443089896, 0.62967447761641238, -0.13637654528126128, -0.25132106432667178, 0.19442823299538681, -0.76546548501637124, 1.7353912282205217, -0.32251034280120267, 0.77024114672142607, 0.20885959673439392, 0.3661893117428377, 0.66113041311643705, 0.0087475940132484987, -0.034447964553696364, -0.014409247408075374, 0.12068678385215152, -0.030133091058323791, -0.021281700358457674, -0.057188613662564496, 0.28716155318388753, -0.054450830318995745, -0.01897746346138493, -0.019162019723155569 , -0.16439637096862045, 1.1148761965955534, -0.41256208584423981, -0.4515777755345457 , -0.7255027688533906, 0.48058700012752026, -0.25283370223924057, 0.061514387975298353, 0.68737620058185434, 0.27294416082783546, -0.55621387153707957, -0.088413235737012957, 1.2099157579845481, -0.46973792916967749 , -0.045828064932837295, -0.35471449017905804, 0.013039222659609145, 0.31667332200063719, 0.063915740076761485, 0.33023483517191271) , "sigma" = 0.0001 )