Hi sorry still learning here and slow to learning code arguments.
Just wondering could anyone explain what a certain part of a function means:
x = sum(abs(apply(embed(y, 4), 1, prod)))
It does give the following on paper:
#sum(y|{j}|*y|{j-1}|*y|{j-2}|*|y{j-3}|)
I am wondering what does the 1 do? as I think the (y, 4) means y with y plus 3 lags and prod I know is product
this specific function was wrote for be by I am trying to modify it to equal:
#sum((|y{j}|^3/2)*(|y{j-1}|^3/2)*(|y{j-2}|^3/2)*(|y{j-3}|^3/2))
So basically I am wondering should my modified function to raise the y’s to ^3/2 should I compute:
x = sum(abs(apply(embed((y^3/2), 4), 1, prod)))
or to:
x = sum(abs(apply(embed(y, 4), 3/2, prod)))
or another?
Any help?
Thank you in advance for your input
1is part of theapplyfunction of argument calledMARGIN. This is why I advocate specifying argument names. Anyway,applyfunction will “loop” through rows (1) or columns (2) of data frames, arrays, matrices… An expression or an evaluated object should be passed asXor if you prefer your functions bare, the first argument. If you want to raiseyby some amount, you will have to do it like you’ve showed in one of the lines:y^(3/2).In other words, this command will sum all elements across rows:
or across columns: