Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: RE: st: SAS Stata equivalent command


From   "b. water" <[email protected]>
To   [email protected]
Subject   RE: RE: st: SAS Stata equivalent command
Date   Thu, 08 Dec 2005 20:34:13 +0000

dan, thank you for your advice. the website reference no doubt would be useful. although your suggestion did perhaps elucidate the particular portion of the SAS codes, overall it adds to my confusion. i am not sure how much of the paper i can copy in here without running foul of copyright to help me with the discussion but i am going out on a limb anyway:

before the juncture that i am stuck, i have created a bi_meta.dta data set based on the following command. the previous file 'meta' (set meta) was merely an infile of the data coupled with generate logit and variance of the logit of the sensitivity and specificity.

============================================

/*
In the next step we rebuild the original dataset so that each study will now have two records: one record holding (logit) sensitivity and the other (logit) specificity. Define two indicator variables: dis and non_dis. When a record holds logit sensitivity the value for dis=1 and for non_dis=0, when a record holds specificity dis=0 and non_dis=1
*/

data bi_meta;
set meta;

/* creating the record for logit sensitivity */
dis = 1; non_dis = 0;
logit = log_sens; var_logit = var_log_sens;
rec=1;
output;

/* variable rec uniquely identifies each record */
/* writes the record holding sensitivity to the new dataset */

/* creating the record for logit sprecificity */
dis = 0; non_dis = 1;
logit = log_spec; var_logit = var_log_spec;
rec=1; output;
run;

============================================

my understanding is this is akin to -reshape long- i.e. from having variables log_sens var_log_sens log_spec and var_log_spec, i have obtained a 'longer' dataset with variables logit var_logit dis non_dis (where the combination of dis and non_dis would code for sensitivity and specificity) in preparation for the PROC Mixed.

it is following this step that your suggestion confused me. it does not make sense to simply concatenate three zero's onto var_logit in bi_meta.dta dataset and without SAS i cannot try to emulate the codes to visualise the SAS routines and adapt it for Stata.

following creation of the three zero's the codes called for SAS Proc Mixed module and proceeded as follows:

============================================

/*
Use the Proc Mixed module in SAS is used to set up the bivariate model. We apply the approach of Van Houwelingen et al to incorporate both the within and between study variance, more details and explanations can be found there.{van Houwelingen, 2002 #2} Use the restricted maximum likelihood estimation (REML) method in estimating the model
*/

proc mixed data=bi_meta method=reml cl ; /* option cl will give confidence intervals */
/* study_id and modality are categorical variables */
class study_id modality;

/* model statement: asking for different estimates of mean sensitivity and specificity for each modality, provide large value for degrees of freedom to obtain p-values based on normal distribution rather than the t-distribution (=default in SAS) */

model logit = dis*modality non_dis*modality / noint cl df=1000, 1000, 1000, 1000, 1000, 1000;

/* random effects for logit sensitivity and specificity with possible correlation (UN=unstructured covariance structure) */
random dis non_dis / subject=study_id type=un ;

/* use the repeat statement to define different within-study variances for sens and spec in each study */
repeated / group=rec;

/* name the file holding the all the (co)variances parameters, keep the within-study variance constant */
parms / parmsdata=cov hold=4 to 91;

/* use contrast statement for testing specific hypotheses */
/* testing for differences in sensitivities */
contrast �CT_sens vs LAG_sens� dis*modality 1 -1 0 / df=1000 ;
contrast �CT_sens vs MRI_sens� dis*modality 1 0 -1/ df=1000 ;
contrast �LAG_sens vs MRI_sens� dis*modality 0 1 -1/ df=1000 ;

/* testing for differences in specificities */
contrast �CT_spec vs LAG_spec� non_dis*modality 1 -1 0 / df=1000 ;
contrast �CT_spec vs MRI_spec� non_dis*modality 1 0 -1/ df=1000 ;
contrast �LAG_spec vs MRI_spec� non_dis*modality 0 1 -1/ df=1000 ;

/* testing for differences in DOR */
contrast �CT_odds vs LAG_odds � dis*modality 1 -1 0 non_dis* modality 1 -1 0 / df=1000 ;
contrast �CT_odds vs MRI_odds � dis* modality 1 0 -1 non_dis* modality 1 0 -1 / df=1000 ;
contrast �LAG_odds vs MRI_odds � dis* modality 0 1 -1 non_dis* modality 0 1 -1 / df=1000 ;
run;

============================================

as nick (cox) said in earlier posting, PROC Mixed equivalent could be either gllamm or xtmixed (Stata 9), but without being able to prepare the data for gllamm (since my Stata is version 8.2) i think i am effectively stuck for the time being.

once again though, thank you for your input dan, and the pointer to the website.

kind regards,
bw



From: Dan Blanchette <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: RE: RE: st: SAS Stata equivalent command
Date: Thu, 8 Dec 2005 13:00:54 -0500 (EST)

Please check out "A SAS User's Guide to Stata" www.cpc.unc.edu/services/computer/presentations/sas_to_stata
where you can find some SAS code matched to the equivalent Stata code.

In your circumstance, you have fallen into some obscure SAS coding.
The code: *************************************************************************
if _n_ eq 1 then do;
est = 0; output; est = 0; output; est = 0; output;
end;
*************************************************************************

creates a variable called "est" and sets it to 0 and then creates 3 observations
in the dataset. Why this is important is beyond me, but perhaps it is.
Next the code brings in an existing data set "bi_meta" and concatenates that
onto these 3 observations. Then it sets the variable "est" to be the same value
as the variable "var_logit." And finally it only keeps this new variable "est."

So the eqivalent Stata code would be:

*************************************************************************

clear
set obs 3
gen est = 0
append using "bi_meta.dta"
replace est = var_logit
keep est

*************************************************************************

I hope this helps,

Dan Blanchette

ITS Research Computing Group
University of North Carolina Chapel Hill
[email protected]

_________________________________________________________________
Don�t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index