I have tried to use the glm w/ log link to estimate a model of earnings.
I am using stata8.2. I get an r(198) "invalid 'glm'" error. My code
follows:
> glm adj04p1
> bm wm bf wf yrsed age age2,
> link(log) family(gaussian)
> noconstant cluster(statefip) ;
invalid 'glm'
r(198);
Although I believe binomial is the canonical family for log link, I
thought one could specify other families, including gaussian, instead.
(FYI Age was centered and then age-squared was calculated, so those
variables are not collinear). But, it does not seem to work. As far as I
can tell, my variables are fine, they work in other models without a
problem (e.g., regress, estimated just before the glm).
Assistance appreciated.
Thanks.
Sam
On Fri, 26 Aug 2005, Nick Cox wrote:
> An excellent solution to this has been
> available for 33 years, namely generalised
> linear models with log link. So, switch to -glm-.
>
> glm y ln_x1 ln_x2, link(log)
>
> That way, you can also think about other error
> families that might be better for your problem.
>
> Alternatively, Duan's technique of smearing
> often works well. Rich Goldstein published
> a program some while back, and I have
> a more modern variant somewhere.
>
> W. Manning, who I think is a Stata user but
> possibly not a member of Statalist, has
> published lots in this territory, especially
> I think in (health) economics.
>
> Nick
> [email protected]
>
> [email protected]
>
> > I want to estimate a simple log-linear OLS regression in
> > Stata and then
> > use the model to generate predictions. Say the model looks like this:
> >
> > regress ln_y ln_x1 ln_x2
> >
> > where all the variables are in logs. After running the model, I'd like
> > to predict values of y over different values of x1, holding
> > x2 fixed at
> > the mean. The problem is that my predicted y is in log form, which I
> > want to transform to y. One solution is to simply take
> > exp(prediction of
> > ln_y), but this has been shown to result in a biased predictor. The
> > following article discusses various techniques for dealing with this,
> > focusing specifically on a Laplace conversion:
> >
> > van Garderen, Kees Jan, 2001.
> > "Optimal prediction in loglinear models," Journal of Econometrics,
> > Elsevier, vol. 104(1), pages 119-140
> >
> > Does anyone know if any such techniques have been implemented
> > in Stata?
> > Would predictnl do the trick, as in:
> >
> > predictnl yhat = exp(_b[cons] + _b[ln_x1]*ln_x1 + _b[ln_x2]*ln_x2],
> > se(yhat_se)
> >
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/