yesterday
Haris
Lapis Lazuli | Level 10
Member since
06-23-2011
- 239 Posts
- 39 Likes Given
- 13 Solutions
- 54 Likes Received
-
Latest posts by Haris
Subject Views Posted 765 02-04-2025 03:52 PM 783 02-04-2025 03:22 PM 832 02-04-2025 01:07 PM 968 02-03-2025 06:24 PM 983 02-03-2025 06:14 PM 1015 02-02-2025 02:35 PM 1035 02-02-2025 01:05 PM 1177 02-01-2025 04:35 PM 676 01-28-2025 04:29 PM 2965 02-05-2024 11:00 AM -
Activity Feed for Haris
- Posted Re: Conditional %IF %THEN processing as a macro parameter on SAS Programming. 02-04-2025 03:52 PM
- Posted Re: Conditional %IF %THEN processing as a macro parameter on SAS Programming. 02-04-2025 03:22 PM
- Posted Re: Conditional %IF %THEN processing as a macro parameter on SAS Programming. 02-04-2025 01:07 PM
- Posted Re: Conditional %IF %THEN processing as a macro parameter on SAS Programming. 02-03-2025 06:24 PM
- Posted Conditional %IF %THEN processing as a macro parameter on SAS Programming. 02-03-2025 06:14 PM
- Posted Re: Scoring Mixed Bayesian Model on Statistical Procedures. 02-02-2025 02:35 PM
- Posted Re: Scoring Mixed Bayesian Model on Statistical Procedures. 02-02-2025 01:05 PM
- Liked Re: Scoring Mixed Bayesian Model for webart999ARM. 02-02-2025 12:44 PM
- Posted Scoring Mixed Bayesian Model on Statistical Procedures. 02-01-2025 04:35 PM
- Posted Re: Bayesian Analysis and PROC IML: What's the Score? on SAS Communities Library. 01-28-2025 04:29 PM
- Liked Re: Increase variable name length from 32 to 128 characters for alecwh22. 05-24-2024 12:24 PM
- Posted Re: Read data from MS-SQL into SAS via SAS/ACCESS ODBC on SAS Programming. 02-05-2024 11:00 AM
- Posted Re: Read data from MS-SQL into SAS via SAS/ACCESS ODBC on SAS Programming. 02-04-2024 01:31 PM
- Posted Re: Read data from MS-SQL into SAS via SAS/ACCESS ODBC on SAS Programming. 02-03-2024 06:13 PM
- Posted Re: Read data from MS-SQL into SAS via SAS/ACCESS ODBC on SAS Programming. 02-03-2024 06:11 PM
- Posted Read data from MS-SQL into SAS via SAS/ACCESS ODBC on SAS Programming. 02-03-2024 05:32 PM
- Posted Re: Integrating over a non-normal distribution on SAS/IML Software and Matrix Computations. 10-21-2023 08:56 AM
- Got a Like for Re: Integrating over a non-normal distribution. 09-15-2023 05:01 AM
- Posted Re: Integrating over a non-normal distribution on SAS/IML Software and Matrix Computations. 09-14-2023 05:21 PM
- Liked Re: Integrating over a non-normal distribution for Rick_SAS. 09-14-2023 05:21 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 13 1 3 1 -
My Liked Posts
Subject Likes Posted 2 09-14-2023 05:21 PM 2 09-14-2023 01:38 PM 1 02-09-2022 01:25 PM 1 05-06-2015 12:53 PM 9 04-07-2020 12:13 PM
09-14-2023
05:21 PM
2 Likes
Thanks. Even better: I bought YOUR book 🙂
... View more
09-14-2023
02:15 PM
You are too kind. Much obliged! Thanks!
It's a challenge to transition from decades of just columns, rows and cells to vectors and arrays.
... View more
09-14-2023
01:55 PM
And I am a total IML idiot. Why is this code not working?
proc iml;
use SAShelp.class;
read all var {Age};
PP = Age/100;
Eta = log(PP / (1-PP));
start Integrand(u) global(eta);
L = logistic(u + eta);
fu = pdf("Normal", u, 0, 0.2);
return( L * fu );
finish;
call quad(iPP, "Integrand", {.M,.P}) scale=.0001;
print iPP;
... View more
09-14-2023
01:38 PM
2 Likes
Oh, and one more thing, I think the notation in the formula is what's throwing you off. "RE" subscripts for alpha and beta signify that it's a Random Effects model rather than that alpha and beta are random effects coefficients. Alpha and Beta are fixed. U is the random intercept.
... View more
09-14-2023
01:35 PM
Thanks so much, Rick.
Extra background detail. There is a problem with marginal observation-level Predicted Probabilities from logistic regression when random effects are involved. Straight up linear predictor expressed as probability is systematically different from the 'correct' value. See this for more detail (https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-015-0046-6).
The correct way to calculated marginal probabilities according to the reference and the formula I pasted, is to integrate Predicted Probability for each row over the distribution of all random intervals in the model. I wish SAS had this correction built in into all PROCs that do multi-level regression. I requested that feature. In the absence of it, my starting point is a marginal NOBLUP Predicted Probability value for each row in the model from GLIMMIX, for example. From there, I back-transform it to linear predictor so that the LP could be integrated over the distribution of random effects or Random Intervals (the u term). For each row in the model (patients), the Predicted Probability needs to be corrected using the distribution of random intercepts (hospitals). Normal integral QUAD() gives me AUC for the transformation without any density weights. What you shared seems to do the trick. I tested a couple of values and it seems to correctly increase the input for values below 0.5 and decreases them for values above .5. I modified the code slightly and now just need to figure out how to apply it to an entire column of Predicted Probability values. I think I can simplify this a little bit by outputing Linear Predictors from the model rather than Predicted Probabilities -- skip the `iLink` option.
proc IML;
PredProb = .73; /* Marginal Predicted Probability from RE GLMM */
Eta = log(PP / (1-PP)); /* Eta = linear predictor */
start Integrand(u) global(eta);
L = logistic(u + eta);
fu = pdf("Normal", u, 0, 0.2); /* specify f(u) here. eg, PDF for N(0,0.20) */
return( L * fu );
finish;
call quad(iPP, "Integrand", {.M,.P});
print PP Eta iPP;
quit;
Thanks again. Happy to discuss further. Hope you can put in a good word with SAS development teams to add this correction to the SAS/STAT core PROCS. Would love to hear if you disagree with the diagnosis for marginal PPs.
... View more
09-14-2023
10:12 AM
I am trying to program correct marginal Predicted Probabilities (PP) from a multi-level logistic regression output. Pavlou (2015) has a formula attributed to Skrondal (2009) where row-level PPs need to be integrated over the distribution of random effects:
Expression in the square brackets -- except for 'u' -- is marginal linear predictor. Random effect (RI) gets added to that expression and the whole thing gets translated into PP. That entity, then, is integrated over the distribution of random effects with the mean of zero and standard deviation being the variance of the random effecs from the model inquestion. I am a novice IML programmer and, for the life of me, can't figure out how to program this in SAS. My variances of RIs range from 0.1 to 0.5 and I don't even know where to put that in the QUAD() funcion. The best shot is below. Any advice is appreciated.
Would averaging PP over all sample RIs be close enough to the integration approach? I am working with anywhere from 150 to over 1,000 random units.
proc IML;
start IntRI(RI);
PP = 0.1;
lgt = log(PP/(1-PP));
return( (1 + exp(-(lgt+RI)))**-1 );
finish;
call quad(iPP, "IntRI", {.M,.P});
print iPP;
quit;
... View more
09-07-2023
11:31 AM
Thank you Steve. I was not looking to deliberate between PL and Quadrature approaches but this is certainly a relevant topic. Thanks for sharing!
... View more
09-01-2023
04:35 PM
I think it is relatively well known that simply scoring a mixed effects model over fixed effects produces biased marginal prediction when the outcome is binary. See Pavlou (2015) for an excellent summary of the problem and solutions: https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-015-0046-6
SAS does not currently have a way to remove the bias outside of settling for GEE in place of random effects model. GEE has drawbacks. Feature request is in with SAS.
Can anyone direct me to existing SAS code or give pointers on what to use and how to develop an efficient integration solution. I am working with large datasets and thousands of random effects levels. I've written the code to apply Zeger approximation (sharing below) but want to be exact. To whom it may concern, in a sample with event rate in low single digits, as expected, Observed/Expected ratios based on native SAS PredProbs for full sample were substantially biased upwards (OE>1.00) due to under-predicted risk. Bias was in excess of 10%. After applying Zeger correction, the O/E ratios were much closer to 1.00 but the correction slightly over-estimates risk (OE<1.00 with bias around ~2%) . I am hoping that integration approch proposed in Pavlou (2015) will get me closer to ideal OE = 1.00.
%macro ZegerC(mPredProb, S2);
* &mPredProb = variable with biased marginal predicted probabilities from mixed model with binary outcome * * &S2 = variance of random intercepts ;
data Zeger;
set DataHave;
CAF = sqrt(.345843*&S2 + 1);
XB = log( &mPredProb./(1-&mPredProb.) );
XBc = XB / CAF ;
&mPredProb.C = ( exp(-XBc) + 1 )**-1;
drop CAF XB XBc; run;
%mend ZegerC;
... View more
08-31-2023
01:14 PM
Perfect! Thanks. Found the same solution. Any idea why one needs to request partitioning to get these basic model fit statistics to output? Does not make sense to me that they won't show up without typing extra code for the PARTITION option and specifying this contrived (TEST=0) scenario to, basically, negate the PARTITION request.
... View more
08-31-2023
12:57 PM
The equivalent in the PROC LOGISTIC is SCORE FITSTAT option. That does not work in the HP version.
... View more
08-31-2023
12:48 PM
SAS documentation for PROC HPLOGISTIC references 'Average Squared Error' and 'Mean Difference'. However, for the life of me, I can't figure out how to get these two to output to the RESULTS window. HELP!!!
... View more
06-15-2023
10:27 AM
Thanks for the recommendation regardgin WORK. I am looking at Windows Resource Monitor and don't see anything of note on CPU, RAM, or Disk I/O. Maybe up to 10-15% utilization. Anything else you can recommend?
... View more
06-15-2023
10:25 AM
Sorry, should have been more specific: I am running SAS on Windows 11 desktop. The ten programms running GLIMMIX models are submitted by right-clicking and "Batch Submit with SAS 9.4". The code of GLIMMIX is probably not relevant but here it is just in case: proc glimmix data=BootData Method=Quad; where SampleID LE 50; by SampleID; freq NumberHits; class Stratum; * pre-sorted ; class ageGrp / reference = last ; model OpMort (event="1 = Yes") = &ModelVars / dist=binary link=logit cl; random intercept / subject= Stratum; output out=out.B0 pred(iLink BLUP)=PredProb_boot pred( noBLUP)=PredProb_boot_noBLUP_xBeta ; run;
... View more
06-13-2023
04:25 PM
Many SAS procedures have NTHREADS option that allows one to fine-tune computer resource allocation and can have dramatic impact on processing times. As far as I know GLIMMIX is not one of them.
In running bootstrap simulations, I am running the same GLIMMIX model 500 times and, with approximately 4 minutes per bootstrap Replication, processing time ends up 2,000 minutes or well over one day.
Given that computer resource utilization is minimal during the whole run, I tried to split the 500 bootstrap samples into 10 parallel runs with 50 Replications in each. To my surprise, when running exactly the same GLIMMIX model with 10 parallel processes, the per-replication processing times increased from 4 minutes to about 18 minutes. Computer resource utilization did not show anything remotely close to reaching the limits of the powerful Windows machine I am using (64 core CPU, 128GB or RAM, NvME Hard Discs).
In summary, by parallelizing the process, I cut the total run time in half but that's not anywhere near close to 10 times corresponding to 10 parallel runs of the models.
Can anyone help me understand why this is?
More importantly, how do I optimize the workflow. That is, would 50 parallel runs be faster than 10 or would 5 be better? I can, of course, just try but the process is very time-consuming.
Thanks for your thoughts.
... View more
03-30-2023
03:28 PM
I want a single column PROC in the SAS dataset that contains value PROC = "[ 2800, 2980, 4090, 4170 ]".
... View more