2
$\begingroup$

Suppose we are want to consider the asset price $P_t$ (business daily) of some stock. The log return is defined as

$$X_t:=\log{\frac{P_t}{P_{t-1}}}$$

suppose we are considering the prices between some interval, eg. June 1986 and March 1990). Log returns can be modelled by $X_t=\sigma_t\epsilon_t$, with $E[\epsilon_t]=0,Var(\epsilon_t)=1$. We assume Markov-property, thus $\sigma^2_t=v(X_{t-1})$. The model can be fitted by nonparametric regression of the function $v$ in

$$Z_t:=X^2_t=v(X_{t-1})+\phi_t$$ where $\phi_t=\sigma^2_t(\epsilon^2_t-1)$ can be seen as error. We want to use ksmooth, smooth.spline and loess. In my notes they say: "First we sort the values, in order not to get problems with ksmooth, which orders the values internally and gives back results corresponding to the ordered values."

I do not understand why we have to do that. Basically we have a function $v$, with values on the $y$-axis and the $x$-axis is our time interval between June 1986 and March 1990. So why do we have to order the data?

$\endgroup$

1 Answer 1

1
$\begingroup$

It is an implementation detail. ksmooth is documented to return the points at which the smooth was evaluated in increasing order of x, the input data.

Value:

     A list with components

       x: values at which the smoothed fit is evaluated. Guaranteed to
          be in increasing order.

       y: fitted values corresponding to ‘x’.

Note also that what ksmooth() returns is a vector of n.points points, evenly spread across the range of x (unless argument x.points is supplied during fitting), not the evaluation of the smoother at the input location x.

Read ?ksmooth for more details.

$\endgroup$
1
  • $\begingroup$ Thank you Gavin Simpson for your comment. Two questions: if I do not use the argument x.points, how exactly are the points chosen? If I add x.points then the returned y values correspond to the x.points. After all, why is it necessary to order my input x. In my notes there are other examples about ksmooth where we do not order x. Should it be done generally using ksmooth? Again, thanks for your help $\endgroup$
    – math
    Jul 23, 2013 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.