Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Is there a way to use or emulate the behaviour of --predict-- with --by-- groups?

From   Maarten Buis <>
Subject   Re: st: Is there a way to use or emulate the behaviour of --predict-- with --by-- groups?
Date   Wed, 31 Oct 2012 09:19:50 +0100

On Wed, Oct 31, 2012 at 1:40 AM, Aaron Kirkman wrote:
> I have data grouped by a variable called --group--, in this example,
> and I'm trying to use logarithmic interpolation on another variable.
> Linear interpolation using the --ipolate-- command works perfectly in
> --by-- group <snip> Unfortunately, this does not work with logarithmic
> interpolation and --regress--/--predict--.

You can avoid the -by:- prefix by adding interactions to your linear
regression model:

*---------- begin example ----------
quietly input str1 group x y
A 1 1000
A 2 .
A 3 3000
A 4 .
B 5 45
B 6 .
B 9 20

encode group, gen(groupnum)
gen lx = ln(x)

reg y i.groupnum##c.lx

predict y_loginterp, xb
*----------- end example -----------

Notice that the observation A 4 is not strictly speaking an
interpolation but an extrapolation. You'll want to be more careful in
those situations.

Hope this helps,

Maarten L. Buis
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index