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: Regressing a specific number of observations containing values

From   Tirthankar Chakravarty <>
Subject   Re: st: Regressing a specific number of observations containing values
Date   Tue, 6 Sep 2011 07:06:57 -0700

As Nick says, not directly. Depending on whether you would like to use
the same 250 every time, or a different 250 from among the
non-missing, you can exclude the lines relating to the variable
"randsort" in the code below:

// generate some data
set obs 1000
foreach x of newlist x y z {
g `x' = cond(runiform()<.1, ., runiform())

// tag non-missing
g notmiss = !missing(x, y, z)

// random sort order
tempvar randsort
g `randsort' = runiform()
gsort -notmiss `randsort'

reg y x z in 1/250

On Tue, Sep 6, 2011 at 5:35 AM, Robin Schmidt <> wrote:
> Dear all,
> I am working on a finance-related event study where in a first step I have to
> get coefficients (alpha and beta) from a linear regression of two variables.
> The regression has to comprise of 250 observations (in this case 250 stock
> returns of 250 trading days). The problem is that one of the variables is
> missing some observations while the other one is not. However I need exactly
> 250 observations containing values. Working with "range" is not satisfactory
> as it ignores whether a certain observation is missing a value or not. Is
> there a way of regressing an exact number of obsverations which contain a
> value (i.e. which are "nonmissing")?
> Many thanks in advance.
> Best regards,
> Robin Schmidt
> *
> *   For searches and help try:
> *
> *
> *

Tirthankar Chakravarty

*   For searches and help try:

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