I am running the example of MRF in R developed here. The following blocs work perfect:
set.seed(0)
data=matrix(rnorm(15*200),200,15)
#DGP
library(pracma)
X=data[,1:3]
y=crossprod(t(X),rep(1,3))*(1-0.5*I(c(1:200)>75))+rnorm(200)/2
trend=1:200
data.in=cbind(y,data,trend)
Let’s say we want to predict the last 50 observations. We can set up our oos_pos as follows:
oos_position = nrow(data.in)-50: nrow(data.in)
However, I find the following error
Error in commitee[b, ] <- rt.output$pred : number of items to replace
is not a multiple of replacement length
when running the code below.
Is someone able to replicate the following code chunk?
mrf.output = MRF(data = data.in,
y.pos = 1,
x.pos = 2:4,
S.pos = 2:ncol(data.in),
oos.pos = oos_position,
mtry.frac = 0.25,
trend.push = 4,
quantile.rate = 0.3,
B = 100)
Any tip?
I don't think oos_position
is specified incorrectly - it seems to be specifying the first 150 rows, rather than the last 50. Try this instead:
mrf.output = MRF(data = data.in,
y.pos = 1,
x.pos = 2:4,
S.pos = 2:ncol(data.in),
oos.pos = 151:200,
mtry.frac = 0.25,
trend.push = 4,
quantile.rate = 0.3,
B = 100)