Question: Compute confidence intervals for predicted values in glm R same as proc genmod SAS
0
gravatar for besson.andrea
15 months ago by
besson.andrea0 wrote:

Hi everyone,

My current goal is to translate a SAS program to R. My issue here is that I can't find the equivalence/how to compute predicted values for a glm model as the ones I get in SAS.

I have found the following explanations in SAS documentation : https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_genmod_sect045.htm But I have troubles to translate the formula with a concrete code in R, specially concerning the covariance ...

For now I have computed the CI the following way (I'm working with lists)

# GLM
  models <- lapply(combia, function (x) {glm(cbind(n,s-n) ~ scm, family = binomial, data = x)})

  # Get confidence intervals
  p <- lapply(models, function (x) {predict(x, type = "link", se.fit = TRUE)})

  lowerlogit <- lapply(p, function(x) {x$fit - 1.96*x$se.fit})
  upperlogit <- lapply(p, function(x) {x$fit + 1.96*x$se.fit})

  borneinf <- lapply(lowerlogit, function(x) {exp(x)/(1+exp(x))})
  bornesup <- lapply(upperlogit, function(x) {exp(x)/(1+exp(x))})

But I don't get the same CI as SAS, and it's a problem for me in the futures steps.

I hope some of you would be able to help me on that, that would be so helpful !!

Thanks in advance

R • 597 views
ADD COMMENTlink modified 15 months ago by Jean-Karim Heriche18k • written 15 months ago by besson.andrea0
0
gravatar for Jean-Karim Heriche
15 months ago by
EMBL Heidelberg, Germany
Jean-Karim Heriche18k wrote:

What you're doing seems OK at first glance. The difference could be in the way the covariance matrix is estimated. This blog post and the referenced SO post might help. Another way could be to use the glm.predict package.

ADD COMMENTlink written 15 months ago by Jean-Karim Heriche18k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 914 users visited in the last hour