On Sat, 19 Dec 2020, Sven Schreiber wrote:
Hi,
inside a function I tried to do something like
series mybundle.myseries = mybundle.myvector
where the active sample length matches rows(mybundle.myvector), but I
got an error ("got null", or something).
If I workaround like this:
series myseries = mybundle.myvector
series mybundle.myseries = myseries
then it worked.
Same thing outside of a function. If you're subsampled and want to
store a matrix as a series inside a bundle you have to make it into
a proper series first. That's the only way gretl can know where it's
supposed to start; there's no notion of a dataset inside a bundle.
However, if the matrix (column vector) in question is produced by a
gretl function that sets t1 and t2 on it, best practice would be to
store it in the bundle as a matrix, then pull it out as a series
when it's needed.
Here's a sketch of how one might get matrix -> series alignnment
right when the matrix in question doesn't have t1 and t2 set
automatically.
<hansl>
function series extract_series (const bundle bx)
smpl bx.t1 bx.t2
return bx.mat
end function
open data3-6
bundle b # will contain more stuff?
smpl 1965 1990
matrix x = mnormal($nobs, 1)
bundle b.bx = _(mat=x, t1=$t1, t2=$t2)
smpl full
# do stuff...
series s = extract_series(b.bx)
print s -o
</hansl>
Allin