Evaluating a function for given vectors with different lengths in R -



Evaluating a function for given vectors with different lengths in R -

i have written predictor function on r , tried several combinations of inputs in function see how output change.

the problem function takes 4 numeric parameters , want test function plugging possible combinations of elements obtained specified vectors ( vectors have different lengths)

i've tried using replicate, apply , sapply functions couldn't output wanted see. can loops each parameter when comes several parameters need several loops , don't know how store values after many loops.

so function looks this;

predictvar(dataset, columnnumber, correlation, lags, fcasthorizon)

and while keeping dataset constant ( or can remove parameter list , assign default info frame in function)

columnnumber takes values between 1 , 20 ( each of these corresponding variables dataset) correlation take values in seq(0.15,0.9,by=0.15) lags take values in c(10, 20, 30, 50, 80, 100) and fcasthorizon take values list c(20,252)

so if started doing manually , evaluate each combination these specified vectors, like

predictvar(1, 0.1, 10, 20) => predictvar(1, 0.1, 10, 252) => predictvar(1, 0.1, 20, 20) => predictvar(1, 0.1, 20, 252) . . . . , finally;=> predictvar(20, 0.9,100 ,252)

by end of process, should obtain 20*6*6*2=1440 different outputs , corresponding input specifications.

could help me function help me obtain results? have read topics family of apply functions need evaluate model cross combinations , couldn't find solution far.

regards

r vector apply sapply replicate

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -