Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: panel data daily data, missing days, how to fill it up to full months(1-31)


From   Roberto Ferrer <[email protected]>
To   Stata Help <[email protected]>
Subject   Re: st: panel data daily data, missing days, how to fill it up to full months(1-31)
Date   Fri, 7 Feb 2014 16:34:28 -0430

The error message is quite clear:

        timevar (day) may not contain missing values when option full
is specified

but there seems to be a confusion as to what "missing" means. Missing
for Stata means the observation takes on the value "." (a dot). The
observation is there, but it has a missing value. With -tsfill- you
can fill-in (time) gaps in your database. Don't confuse the "gaps" as
"missing".

The error states that there is at least one observation in your
database for which the time variable (in your case the variable -day-
and which you set using -tsset-) assumes a value of "missing". The
error states that -tsfill- will not fill-in gaps if there is a missing
value for the time variable and you use the -full- option.

The following code reproduces the error and illustrates (I hope) why
it comes up.

*------------ begin code ----------------------------

clear all
set more off

*---------- Prepare example data -----------

webuse grunfeld
keep if inrange(company, 1, 2)
drop in 1/5

tsset company year, yearly

drop in 7 // company 1, 1946
drop in 31/32 // company 2, 1950-1951

// COMMENT TO FIX ERROR
replace year = . in 3 // company 1, 1942

list, sepby(company)

*------------ Fill in -------------------

// one way
tsfill, full

list, sepby(company)

/*
// another way
tsfill

list, sepby(company)
*/

*------------ end code -------------------------------


Run with your database -list if missing(day)- to see the problematic
observations.

On Fri, Feb 7, 2014 at 7:37 AM, obba0001 <[email protected]> wrote:
> In my panel data, some people have recorded between 1-25 days of the month.
> some recorded from 3 to 31 days of the month. In addition to this, some of
> them are not measured for the same month, so in some months which there are
> 31 days and for some months there are 30 days. what i want is to create
> those missing days then i will do MI impute, but first i need to make the
> data ready for imputation.
> i used tsset to give you more information about my data:
>
>  panel variable:  id (unbalanced)
>         time variable:  day, 18aug2005 to 06jul2008
>                 delta:  1 day
>
> i tried tsfill with the full option but it didnt work.
> the message i got is:
> timevar (day) may not contain missing values when option full is specified
>
> i looked for that error but didnt understand how to modify the data in order
> to make this command work. I am a newbie, so i need your help.
>
> further information as requested:
>
> The desired pattern is to measure the people for a complete month. there are
> people that are measured full month such as from 1 to 31th of that month.
> but there are some people that are measured between 1 to 16 or 1-25 or 1-5th
> of the month. Another property of my data is that the experiment was done
> between 2005 to 2008. So people were not measured at the same period.  for
> example, some people recorded between 1th of september 2005 to 26th of
> september 2005 and some recorded between 5th of november 2006 to 31 december
> 2006.
>
> What I want is for example for the person who have measured between 1th to
> 25th november, I want to create rows that have  25th,27th,28th, 29th,30th
> under the date coloumn and under the id coloumn the id should be same such
> as 1 for each created day, and i want to copy the demographic variables to
> that produced rows. but the dependent variable should include na since there
> is no data for the dependent variable for those days for the given person.
>
> After completing this step I will do multiple imputation to produce those
> dependent variables.
>
> Kind regards
>
>
>
> --
> View this message in context: http://statalist.1588530.n2.nabble.com/panel-data-daily-data-missing-days-how-to-fill-it-up-to-full-months-1-31-tp7580479.html
> Sent from the Statalist mailing list archive at Nabble.com.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index