+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 36

Thread: Calculating the standard error of an odds ratio from the standard errors of 2 logits

  1. #1
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Calculating the standard error of an odds ratio from the standard errors of 2 logits




    I've just completed a logistic regression model with a continuous covariate, and calculated the logit and standard errors using SAS for creating a plot of the logit vs. the predictor. I'd like to use this data to calculate and plot the odds ratio and 95% confidence interval using an arbitrary level of the predictor as the reference for calculating the odds ratio; however, I don't know how to go about calculating the standard error of an odds ratio from the standard errors of the two logits used to calculate the odds ratio. Does this procedure make sense and can anyone provide a reference or offer some suggestions?

  2. #2
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    So you are trying to make a graph that will look like the line part on the figure of your overlay post except the ci will be zero at the reference value, correct. It wont be that graph but stylistically it will resemble it. Are you planning on using SAS? I have wanted to do this as well.

    There is probably an easier way but you may be able to get them by just running a bunch of oddsratio statements after your model statement. Do you conduct medical research? I like your questions and plus you are using SAS. I have done something like this using proc nlmixed (sp?) once but I used estimate statement and a bunch of connected points with whiskers.
    Stop cowardice, ban guns!

  3. #3
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    My area of research is epidemiology and I pretty much use SAS (though I've been trying to slowly learn R). I'm not necessarily at the point where I'd like to try making the figure I mentioned in the other post, I just wanted to start thinking about that figure in advance because I thought it might be useful to play around with at some point.

    For this problem I'm working with a continuous predictor so I created plots of the predicted logits by the predictor, but I thought a plot of the odds ratio would be nice. The main issue I've had with tackling this problem is that for this current project I'm using complex survey data and so I have to use proc surveylogistic, which I've found doesn't have quite the same level of options as other SAS procedures. In this case I'd like to use a level of the covariate as the reference (e.g. the mean or the minimum). I was under the impression that the estimate, contrast, and lsmeans/lsmestiamte statements only allow class variables, but I may be wrong about that.

    My initial approach was to use the lsmeans statement to calculate predicted "adjusted" logits (and their standard errors) for the entire range of the continuous covariate, and then calculate the odds ratios from those, but I got stumped when it came to getting the confidence interval of these odds ratios. I'm curious whether there might be an easier/better approach to getting the same result. I'd thought to just use a data step to manually calculate the standard error of the odds ratio using the standard errors of the logit, but I don't know how to perform this calculation and haven't been able to find a reference.

  4. #4
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    I'm currently looking into proc nlmixed, which you mentioned. I think this might provide an easier way of getting what I would like.

  5. #5
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    Will play around with some code in the morning and post.
    Stop cowardice, ban guns!

  6. #6
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    Yeah, unless there is a nice SAS User Group Paper out there, you can definitely do this using Proc nlmixed. In particular the estimate statement. You would need to write one for each ORs of interest. Then take the estimates with their confidence intervals and input that data into a proc sgplot with the band option for the nice blue semi-transparent CIs.

    Let me know if you want to work on writing the actual code. Perhaps we can use one of the SAS.help datasets. I usually play around with Heart (the Framingham dataset).
    Stop cowardice, ban guns!

  7. #7
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    I am definitely interested in this. My only concern is whether proc nlmixed provide appropriate estimates of the standard errors, because I will be using it with survey data.

  8. #8
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    Why do you think your survey data is different from other data sources? Is it weighted or manipulated in some way?
    Stop cowardice, ban guns!

  9. #9
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    Yes, the data is from NHANES, which is a complex, multistage, probability sampling design. So analyses need to take into account strata, clusters, and weights.

  10. #10
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    Hmm, probably could still do it, but it may be quite a bit of work (probably too much, unless you are pretty good at linear algebra in the face of clusters). Have you run a logistic model with these data yet? Will it be multi-level?
    Stop cowardice, ban guns!

  11. #11
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    I've run two logistic regression models using proc surveylogistic, and calculated the predicted logits for levels of the covariate. The outcome is binary and the covariate is continuous (for one model the covariate has about 400 possible values and the other about 1200). This is why I was hoping to use the standard error of the logit to get the confidence interval for the OR, but I haven't had any luck finding any equation or reference (maybe it's too obvious?)

  12. #12
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    Would it be correct to calculate the SE of the OR from the SE of the logits as

    SE_{ln(OR)}=\sqrt{SE_{logit1}^2+SE_{logit2}^2}

  13. #13
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    So you are obtaining results from two models and are trying to pool them? Are both models using the same dataset? Your last 2 posts really confused my interpretation of what you are trying to do.

    Do you have to use proc surveylogistic, are you controlling for other variables or using weights in either of the models. Perhaps posting the code may help me get what you are doing.
    Stop cowardice, ban guns!

  14. #14
    Points: 3,730, Level: 38
    Level completed: 54%, Points required for next Level: 70

    Posts
    155
    Thanks
    7
    Thanked 30 Times in 29 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log

    I'm running proc suryvelogistic with strata,clusters, and weights. I'm running both adjusted and unadjusted models using a quadratic truncated power function spline with 3 knots, and using a do loop and the lsmeans statement to calculate the logit at the mean level of the covariates. I wanted to then use the minimum of the predictor as the reference level to calculate odds ratios from these logits (which I've done), but all I have to work with from lsmeans are the standard errors of the logits, so I was trying to figure out a way to get the standard error of the odds ratio from these logit standard errors. Here is the code I am using:

    Code: 
    %macro macro;
    %let k=0.01;
    %do %until (&k=8);
    ods select none;
    proc surveylogistic data=data; 
    strata strata;cluster cluster;weight weight;domain domain;class var1(ref='0') / param=glm;
    effect spl = spline( var2 / degree=2 basis=tpf details knotmethod=list(0.5 1 1.5)); 
    model y(event='1')=spl var1 spl*var1;
    lsmeans var1 / at var2=(&k) cl exp;
    ods output LSmeans=udat;
    run;
    data udat(where=(domain="var2=1"));set udat;run;
    	%if &k=0.01 %then %do; 
    	data adju;set udat;run;
    	%end;
    	%else %do;
    	data adju;set adju udat;run;
    	%end;
    	%let k=%sysevalf(&k+0.01);
    %end;
    %mend;
    %macro;

  15. #15
    Omega Contributor
    Points: 38,334, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,998
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Calculating the standard error of an odds ratio from the standard errors of 2 log


    Yeah, that is a beastly model, glad I don't mess around with nation survey data. Not familiar with proc surveylogistic, can you use estimate statements?

    If so, you may be able to mess around with writing the odds in them along with their division to get the ORs. Not sure how this works out in a model with clusters, so I would first write an estimate statement for something you can calculate the odds for and make sure it is correct -then evolve it.
    Stop cowardice, ban guns!

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats