Forward difference: Difference between revisions
Content added Content deleted
(→{{header|AppleScript}}: Updated primitives) |
(+Stata) |
||
Line 2,491: | Line 2,491: | ||
val it = [~2921] : int list |
val it = [~2921] : int list |
||
</pre> |
</pre> |
||
=={{header|Stata}}== |
|||
It's possible to implement differences using row indices. For instance, first forward differences of a variable x can be defined by: |
|||
<lang stata>gen y=x[_n+1]-x[_n]</lang> |
|||
However, it's much more natural to use [http://www.stata.com/help.cgi?tsvarlist time-series varlists]. In order to use them, it's necessary to first set a ''time'' variable, which may be simply an index variable. |
|||
<lang stata>* First create a dataset |
|||
clear all |
|||
set obs 100 |
|||
gen i=_n |
|||
tsset i |
|||
gen x=rnormal() |
|||
* Differences |
|||
display "Difference order?" _request(k) |
|||
gen y=D${k}F${k}.x</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |