BookmarkSubscribeRSS Feed
Lindy
Calcite | Level 5

Hi there,

I used R to get a sample size I need for a logistic regression study. 

> wp.logistic(n = NULL, p0 = 0.5, p1 = 0.6, alpha = 0.05,
+ power = 0.8, family = "normal", parameter = c(0,1))
R said I need a sample N=214 if I want to discover a significant difference of .1 (p2=.6 and p1=.5, p2-p1=.1), at alpha=.05, power=.8. 

 

However, when I use SAS to find the sample size based on the covariates I would like to have , it gives me smaller sample sizes (N=168, N=175) than N=214 when I want alpha=.05 and power=.8. Who can help me figure out what is going on? R said N at least should be 214 even without covariates. So I think adding covariates the required sample size should be at least more than N=214.

proc power;
logistic
vardist("recidivism") = BINOMIAL (0.5, 1)
vardist("gender") = BINOMIAL (0.5, 1)
vardist("self-control") = ordinal((2 4 6) : (0.4 0.4 0.2))
vardist("age") = normal(24, 6)
vardist("income") = normal(2400, 600)
testpredictor = "recidivism"
covariates = "gender"|"self-control" "age" "income"
responseprob = 0.5 0.6 .07
testoddsratio = 2.4
alpha = 0.05
power = 0.8
ntotal = .;
run;

20190804194559.png

3 REPLIES 3
PaigeMiller
Diamond | Level 26

If R and SAS are using different algorithms, the results don't have to give comparable results. So, if I were you, I'd try to figure out if the same algorithms are being used; or just pick one and go with it.

 

Ancient Hekawe saying: Man with one watch knows what time it is. Man with two watches never sure. (If you are not familiar with the Hekawe tribe, they appeared on the USA comedy TV show "F-Troop" in the 1960s)

--
Paige Miller
Lindy
Calcite | Level 5

Thank you so much for your help! I am quite an armature in using SAS for power analysis. If it is at your convenience, could you please provide me with the several line of SAS code I should use for this task?

The rate of a type of disease in the general population is 50%, and I am giving a group of randomly selected people a type of vitamin to observe if the vitamin can decrease the rate of disease in this treatment group. I want to be able to identify the significant effect as long as there is 40% rate of this disease in my treatment group at alpha .05 and power .80. What sample size minimally I should have?

Thank you so much!

 

PaigeMiller
Diamond | Level 26

What is wrong with the results from the SAS code that you ran?

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1399 views
  • 0 likes
  • 2 in conversation