# code to create `latent_factor_example` object
set.seed(123)
N <- 40L
T_ <- 20L
D <- 10
B <- t(splines::bs(1:T_, df = D, intercept = TRUE))
a <- cumsum(rnorm(D))
psi <- numeric(T_)
lambda_i <- rnorm(N, 1, 0.2)
for (t in 1:T_) {
psi[t] <- B[, t] %*% a
}
y <- matrix(0, N, T_)
for (t in 1:T_) {
y[, t] <- rnorm(N, lambda_i * psi[t], 0.2)
}
latent_factor_example <- data.frame(
y = c(y),
id = seq_len(N),
time = rep(seq_len(T_), each = N)
)
usethis::use_data(latent_factor_example, overwrite = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.