Dear R users, I am trying to use the dlm package, and in particular the dlmBSample function. For some reason that I am not able to understand, this function does not work properly and the plot of the result does not make sense, while dlmFilter works perfectly. I think that my_mod is correct, because the output of my_dlmFilter$mod is fine. Where is my mistake or my misunderstanding? This is the code: function (orig_ts){ library(dlm) dV_T <- 20000 dW_T <- c(100,10) m0_T <- rep(0,2) C0_T <- 10000*diag(nrow=2) my_dlmModPoly <- dlmModPoly(order=2, dV_T, dW_T, m0_T, C0_T) dV_S <- 20000 dW_S <- c(500,0,0) m0_S <- rep(0,3) C0_S <- 10000*diag(nrow=3) my_dlmModSeas <- dlmModSeas(frequency=4, dV_S, dW_S, m0_S, C0_S) my_mod <- my_dlmModPoly + my_dlmModSeas my_dlmFilter <- dlmFilter(orig_ts, my_mod) my_dlmBSample <- dlmBSample(my_dlmFilter[-1]) plot(orig_ts, type = 'o', ylim=c(-200, 550)) lines(my_dlmFilter$f[-1], col=2) lines(my_dlmFilter$m[-1], col=3) lines(my_dlmBSample, col=4) result <- list(my_dlmFilter, my_dlmBSample) result } Thank you for your attention Stefano AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell?art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.