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]

st: Nice Margins programming challenge


From   Stephen Kay <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Nice Margins programming challenge
Date   Fri, 3 Dec 2010 17:52:20 -0000

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

 

The mfp command creates new tranformed 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 Stata 11's 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 spark can do it for me or show how it can be done even more efficiently. To be honest I'm surprised I've not found any previous posts or web files on this as I'd have thought quite a lot of people would want to do this sort of thing.

 

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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index