trnnick / nnfor

31 stars 15 forks source link

Specification of lag parameter in mlp function #1

Closed shanu0406 closed 5 years ago

shanu0406 commented 6 years ago

I want to specify both number of nodes in hidden layers and number of lags in the mlp model. When I specify number of lags as 3 then why does it take the value of 1 as you can see in summary(fit) below. fit <- mlp(AirPassengers,hd=c(5,2,1),lags=3)

summary(fit) Length Class Mode
net 13 nn list
hd 3 -none- numeric
lags 1 -none- numeric
xreg.lags 0 -none- NULL
difforder 1 -none- numeric
sdummy 1 -none- logical
ff.det 1 -none- numeric
det.type 1 -none- character y 144 ts numeric
minmax 4 -none- list
xreg.minmax 0 -none- NULL
comb 1 -none- character fitted 140 ts numeric
MSE 1 -none- numeric
MSEH 0 -none- NULL

Also, I tried in the another dataset. When I specify both number of lags and hidden layer size then it gives following error. Warning message: In preprocess(y, m, lags, keep, difforder, sel.lag, allow.det.season, : No inputs left in the network after pre-selection, forcing AR(1). Can you please help me in this issue

trnnick commented 6 years ago

By default the algorithm is choosing inputs automatically. You can turn that off by using the argument: sel.lag=FALSE. See the doucmentation ?mlp

shanu0406 commented 6 years ago

Okay. Now I tried with following as well: mlp.fit <- mlp(AirPassengers,sel.lag=FALSE,lags=3)

But lag value still remain equal to 1.

summary(mlp.fit) Length Class Mode
net 13 nn list
hd 1 -none- numeric
lags 1 -none- numeric
xreg.lags 0 -none- NULL
difforder 1 -none- numeric
sdummy 1 -none- logical
ff.det 1 -none- numeric
det.type 1 -none- character y 144 ts numeric
minmax 4 -none- list
xreg.minmax 0 -none- NULL
comb 1 -none- character fitted 140 ts numeric
MSE 1 -none- numeric
MSEH 0 -none- NULL

trnnick commented 6 years ago

You have mispecified the lags, it should be lags=1:3 The default for example is 1:frequency(y). Try the following:

fit <- mlp(AirPassengers,sel.lag=FALSE,lags=1:3)
plot(fit)
shanu0406 commented 6 years ago

Oh I missed it out in the help section. Thanks a lot.