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]

st: Nice Margins programming challenge


From   Stephen Kay <stephen.kay@adelphigroup.com>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: Nice Margins programming challenge
Date   Fri, 3 Dec 2010 18:09:25 -0000

Title: Nice Margins programming challenge

I'm using MFP command combined with xtgee to model a fractional logistic model (dependent variable is a percent varying from 0 to 100% inclusive; patients are clustered within a doctor). Command is

   mfp,select(0.05): xtgee actimpair  age  bmi comorbidities female,
   family(binomial) link(logit)

The mfp command creates new transformed age variables (lets call them age1 and age2) based on the fractional polynomial terms it thinks best (and very kindly gives the formula so they are easy to reproduce).

I want to run the margins command to give predictions on the dependent variable with 95% CI's across a large range of age values.

It looks (to me at least) that I need to program a routine that for every age value needing a prediction:
(1)     Generate the appropriate age1 and age2  values
(2)     Input these into the margins command using the "at" option
(3)     Store/append the resultant prediction plus SE, plus relevant age value into a matrix holding all such results. 

(4)     Compute the 95% CI's for the predictions and store them in the relevant place in the matrix mentioned in (3).

Final tasks after looping through all such ages populating the matrix holding relevant results is to convert the matrix into data and graph from it (this task at least I can do).

I don't program often enough to accomplish the steps above quickly. Hopefully some bright public spirited person can do it for me or show how it can be done even more efficiently. Hopefully it might be of use to others as well. I really like this margins command.

Any help much appreciated.

Thanks,

Steve
DISCLAIMER: The information in this message is confidential and may be legally privileged. It is intended solely for the addressee.  Access to this message by anyone else is unauthorised.  If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful.  Please immediately contact the sender if you have received this message in error. Thank you.



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