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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: age: factor variables may not contain noninteger values


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: age: factor variables may not contain noninteger values
Date   Tue, 8 Nov 2011 19:57:38 +0000

I agree, naturally; it's perhaps a question of whether other studies
in your field would use the same recipe.

Nick

On Tue, Nov 8, 2011 at 7:47 PM, Lars Folkestad <lfolkestad@health.sdu.dk> wrote:
> Thats true but biologically when i'm 39years and 10 months i'm closer to
> 40 than 39.
> Im not sure it makes a difference but it might - floor may potentially
> underestimate the effect of age.
>
> lars
>
> Den 08/11/11 20.39 skrev "Nick Cox" <njcoxstata@gmail.com>:
>
>>All that said, as age as an integer usually means "age last birthday",
>>I am surprised that -round()- is regarded as the answer. I would put
>>my foot down for -floor()-.
>>
>>For example, I am 19 and will not be 20 until next birthday.
>>
>>Nick
>>
>>On Tue, Nov 8, 2011 at 7:29 PM, Lars Folkestad <lfolkestad@health.sdu.dk>
>>wrote:
>>> Thank you for that jesper. It sure did the trick.
>>> lars
>>>
>>> Den 08/11/11 13.17 skrev "Jesper Lindhardsen" <JESLIN01@geh.regionh.dk>:
>>>
>>>>Hi Lars,
>>>>
>>>>Try
>>>>
>>>>
>>>>g new_age= round(age_var,1)
>>>>
>>>>
>>>>HTH,
>>>>
>>>>Jesper
>>>>
>>>>-----Original Message-----
>>>>From: owner-statalist@hsphsun2.harvard.edu
>>>>[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lars
>>>>Folkestad
>>>>Sent: 08 November 2011 12:14
>>>>To: statalist@hsphsun2.harvard.edu
>>>>Subject: Re: st: age: factor variables may not contain noninteger values
>>>>
>>>>This helps a lot.
>>>>Thank you.
>>>>
>>>>But i have a question about the second point.
>>>>Is there a quick and easy way to round the age to the nearest integer
>>>>value? I could use the floor / ceil functions, but some of the ages
>>>>Should be rounded up and some should be rounded down.
>>>>
>>>>lars
>>>>
>>>>Den 08/11/11 11.40 skrev "Maarten Buis" <maartenlbuis@gmail.com>:
>>>>
>>>>>On Tue, Nov 8, 2011 at 11:13 AM, Lars Folkestad wrote:
>>>>>> I am trying to investigate the interactions between age and a
>>>>grouping
>>>>>>variable in a regression model, using this code:
>>>>>>
>>>>>> xi: regress Var1 age##i.group
>>>>>>
>>>>>> Var1: is a continuous variable
>>>>>> Age: is a continous variable / float
>>>>>>
>>>>>> When i run the code i get the following error message:
>>>>>> age:  factor variables may not contain noninteger values
>>>>>
>>>>>First, you are mixing -xi- and factor variable notation. You should
>>>>>just leave the -xi:- prefix away.
>>>>>
>>>>>Second, in most surveys I am aware of age will be measured in whole
>>>>>years. In those cases age should only contain integer values and this
>>>>>error message means I made an error while preparing the data. This is
>>>>>true regardless of how the data is stored. However, this is not
>>>>>necessarily an error, you could have fractional age if you had for
>>>>>instance exact birth dates and exact dates at which events of interest
>>>>>happen. Alternatively, I may have standardized age or rescaled it so
>>>>>it is measured in decades rather than years. However, in the latter
>>>>>two cases I would have created new with different variable names
>>>>>(probably z_age and age_d). So I would check whether non-integer age
>>>>>would make sense given the way your data was collected.
>>>>>
>>>>>Third, whether there is an error or not you probably want -regress
>>>>>var1 c.age##i.group- i.e. tread age as a continuous variable and not
>>>>>as a set of dummies.
>>>>>
>>>>>Hope this helps,
>>>>>Maarten
>>>>>
>>>>>--------------------------
>>>>>Maarten L. Buis
>>>>>Institut fuer Soziologie
>>>>>Universitaet Tuebingen
>>>>>Wilhelmstrasse 36
>>>>>72074 Tuebingen
>>>>>Germany
>>>>>
>>>>>
>>>>>http://www.maartenbuis.nl
>>>>>--------------------------
>>>>>
>>>>>*
>>>>>*   For searches and help try:
>>>>>*   http://www.stata.com/help.cgi?search
>>>>>*   http://www.stata.com/support/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/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/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/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/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/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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