BookmarkSubscribeRSS Feed
agnes12
Calcite | Level 5

I'd like to use a public available SAS macro "NLEstimate" to calculate the adjusted rate difference between treated and untreated groups, and I'm having trouble in the "DF" element in NLEstimate macro.  I looked at some examples online but it's getting more confusing, especially for the following two examples:

Example1: sample size=180, one discrete variable for treated vs. untreated, and one continuous variable "dose."

                  It's DF in  NLEstimate macro is 14.

                  Link: http://support.sas.com/kb/44/354.html, the section about "Using the NLEstimate macro".

Example2: sample size=6, one discrete variable for age groups (age group1 vs. age group 2), and one continuous variable "car."

                  It's DF in  NLEstimate macro is 6.

                  Link:http://support.sas.com/kb/44/354.html. the section about "Using the NLEstimate macro".

 

In my dataset, I have one binary outcome, one categorical variable (treated vs. untreated), and age as either a continuous or discrete variables(e.g. young vs. old age groups), and a total of 120 observations.

I'd like to calculate the rate difference between the treated and untreated which

1. without any adjustment.

2. with age adjustment when age is treated as a continuous variable

3. with age adjustment when age is treated as a discrete variable, young vs. old.

 

My question is how to decide the df when using the NLEstimate macro  ?

 

Here's part of my SAS code for 1. (I got the df=2 somewhere, not sure if it is right. )

 

%macro poissonrate(var);

data dat1;

set dat;

if d2_&var ne 0 then log_&var._years = log(d2_&var/365.25);

else if d2_&var = 0 then log_&var._years = log(1/365.25);

run;

 

proc genmod data = dat1;

CLASS treatment;

model &var = treatment/ dist=poisson offset = log_&var._years;

estimate 'Estimated Rate' intercept 1/ exp;

store out=insmodel;

run;

%mend;

%poissonrate(outcome1);

%NLEstimate(instore=insmodel, label=Rate Difference, f=exp(b_p1+b_p2)-exp(b_p1), df=2);/*for rate difference*/

 

(NLEstimate macro can be found: the download tab on http://support.sas.com/kb/58/775.html)

 

Thanks a lot!

 

 

1 REPLY 1
StatDave
SAS Super FREQ

As noted in the NLEstimate macro description of the DF= option: "The degrees of freedom for testing a linear combination of parameters in a linear model would typically be the number of observations used in fitting the model minus the number of parameters estimated in the model – essentially, the error degrees of freedom."  So for your example with 120 observations and a single binary predictor resulting in two model parameters being estimated, you could use 118 degrees of freedom. But note that large sample Wald statistics are often used, as they are in procedures like GENMOD, which are chi-square with 1 df. So, you could get the Wald statistic as (estimate/stderr)**2 and its p-value is 1-probchi((estimate/stderr)**2, 1) .  At df as large as 118, you probably won't see much difference in the two p-values.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1577 views
  • 1 like
  • 2 in conversation