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: Using random-effects coefficients to predict performance over time


From   Michael Housman <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Using random-effects coefficients to predict performance over time
Date   Thu, 28 Jun 2012 22:45:08 +0000

Thanks so much!  This is exactly what I was looking for.  I've been playing with this functionality for a couple hours and have figured out how to plot the marginal effects.

That said, I can't seem to figure out how to plot anything other than the linear prediction.  Here's my code:

xtreg adh controls c.day_of_service##c.day_of_service##i.Group1 c.day_of_service##c.day_of_service##i.Group2 , re
margins , at(day_of_service = (30(10)90)) over(i.Group1 i.Group2)

And here's what I see at the top of the marginal effects table:

Expression   : Linear prediction, predict()

The lines in the marginal plot look straight.  You'd mentioned "polynomial term interactions" in your response and I'm wondering if there's anything specific I need to specify in order to produce those.

Thanks again!

Best,
Michael



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of William Buchanan
Sent: Thursday, June 28, 2012 1:32 PM
To: [email protected]
Subject: Re: st: Using random-effects coefficients to predict performance over time

Hi Michael,

If you simplify your syntax:

xtreg performance c.day_of_service##c.day_of_service##i.group other_covariates, re

You should be able to use the -margins- command, and subsequently -marginsplot-, to plot the relationship for each of the groups for the time variable and the polynomial term interactions.  

With regards to storing the coefficients, that is already done for you.  Type -ereturn list- after fitting your model to find out what matrices your results are stored in (coefficients generally are stored in e(b)).  With regards to the scaling of -x- you can estimate that with -margins- if you use the -at()- option with appropriate values for the variables you are interested in.

HTH,
Billy




On Jun 28, 2012, at 1:21 PM, Michael Housman wrote:

> Hi,
> 
> Apologies if this is a novice question but I'm struggling with something and was wondering if the group can help out.
> 
> I have data on employee performance over time and I'm trying to depict visually the relationship between employee performance and days of tenure on the job.  My hypothesis is that there are 3 groups of employees and that these three groups vary in terms of: (1) where their performance starts off, (2) how quickly they learn, (3) how quickly their learning flattens out.  In other words, I believe (and the data seems to indicate) that the first derivative of the learning curve is positive and the second derivative is negative.
> 
> How I'd planned on approaching this problem was running a random-effects regression (because I have time-invariant explanatory variables) and interacting the group dummy variables with the linear and squared term representing days of service.  For example, here's some of the code that I've set up (simplified slightly):
> 
> * Generate the linear and squared terms
> 
> gen day_of_service = metric_date - hire_date gen day_of_service2 = 
> days_of_service ^ 2
> 
> * Interact those terms with the group dummy variables
> * I know this code can be simplified but I'm just using it here as an 
> example
> 
> gen Group1_dos = Group1 * day_of_service gen Group1_dos2 = Group1 * 
> day_of_service2
> 
> gen Group2_dos = Group2 * day_of_service gen Group2_dos2 = Group2 * 
> day_of_service2
> 
> gen Group3_dos = Group3 * day_of_service gen Group3_dos2 = Group3 * 
> day_of_service2
> 
> * Run random-effects regression (Group 3 is my omitted group)
> 
> xtreg performance day_of_service day_of_service2 Group1 Group1_dos 
> Group1_dos2 Group2 Group2_dos Group2_dos2 other_covariates, re
> 
> So this run a random-effects regression where I model the: (1) intercept, (2) slope, and (3) squared term for these groups (relatively to the one omitted group - Group3) and generate a coefficient representing each.  That part I understand.
> 
> What I don't understand is how I can depict this visually.  In other words, I'd like to ask STATA to generate 3 separate curves from these coefficient estimates and then plot the lines on a graph.  Here's how I imagine that equation would like for each of the 3 groups:
> 
> Group1: f(t) = day_of_service*t + day_of_service2*t2 + Group1 + 
> Group1_dos*t + Group1_dos*t2
> Group2: f(t) = day_of_service*t + day_of_service2*t2 + Group2 + 
> Group2_dos*t + Group2_dos*t2
> Group3: f(t) = day_of_service*t + day_of_service2*t2
> 
> So the performance on any given day would be indicated by f(x) where x represents the agent's days of tenure on the job.  I understand this much.  Here's what I don't understand:
> 
> 1) How can I get STATA to save the coefficients in a data matrix that it keeps in memory?
> 2) How can I get STATA to then generate a dataset where x runs from, say, 0 to 180 days and then calculates f(t) for these three groups?
> 3) How can I get STATA to depict this visually (most likely as a line graph)?
> 
> Truth be told, piece (3) is something I understand but pieces (1) and (2) are the ones I don't get.  Thanks in advance for any help!
> 
> Best,
> Mike Housman
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index