Thank you - this solves part of the problem. However, I am still
left with the consequence of the way in which gretl handles panel
data. I am trying to ensure that my panel functions can handle
unbalanced panels, but this seems to be very difficult.
When gretl reads an unbalanced panel it automatically creates a
balanced panel by creating new cases with missing data. After that,
smpl refuses to omit cases that would produce an unbalanced
panel. But, this may be perfectly acceptable in some circumstances -
eg suppose I want to estimate a stochastic frontier using data for
Company A for 1995-2004, Company B for 1992-2006, Company C for 1990-2001, etc.
At the moment, the only option seems to be: within the function (a)
create my own internal panel time and unit variables, (b) tell gretl
to treat the data as a cross-section, not a panel, (c) now drop
missing data and estimate the model without using any of gretl's
panel facilities.
So far, so good but I have found that the command "setobs 1 1
--cross-section" within a function is not purely local to that
function and its dependents. It changes the way that the dataset is
handled on exit from the function and I am not clear what will happen
in all circumstances if I try to restore the panel data structure at
the end of the function. Is there any other way round this problem?
Gordon
> A. Is this the right thing to do? Deleting cases with missing
values in
> calculating the log-likelihood, etc is not difficult, but there may be
> models when missing values cause problems if not dealt with properly - eg
> any lag structure. Would it be possible to provide an option (--delmiss)
> for case-wise deletion of missing values?
In many cases, a very handy technique is using the ok() function with a
list argument, as in
<script>
list X = y x1 x2
smpl ok(X) --restrict
</script>
whose meaning should be obvious.
You also have another way to achieve the same result, which is arguably
more byzantine but perhaps more transparent in cases when what you really
need is a linear combination of some variables for the valid observations
only:
<script>
nulldata 20
x = (uniform()>0.8) ? NA : normal()
list X = const x
b = {1;1}
y = (uniform()>0.8) ? NA : normal()
e = y - lincomb(X, b)
print y x e -o
smpl ok(e) --restrict
print y x e -o
</script>