[R] help with formula for clogit

Weidong Gu anopheles123 at gmail.com
Tue Nov 8 01:03:12 CET 2011


clogit needs to spell out formula plus strata, you can try modify the code
...
d2=d[,c(mols,'group','Age','strata')]
fo<-as.formula(paste(paste('group~','Age',sep=''),'strata(strata)',sep='+'))
log.reg<-clogit(fo,data=d2)
...

Weidong

On Mon, Nov 7, 2011 at 10:19 AM, 1Rnwb <sbpurohit at gmail.com> wrote:
> I would like to know if clogit function can be used as below
> clogit(group~., data=dataframe)
>
> When I try to use in above format it takes a long time, I would appreciate
> some pointers to get multiple combinations tested.
>
> set.seed(100)
>  d=data.frame(x=rnorm(20)+5,
>  x1=rnorm(20)+5,
>  x2=rnorm(20)+5,
>  x3=rnorm(20)+5,
>  x4=rnorm(20)+5,
>  x5=rnorm(20)+5,
>  x6=rnorm(20)+5,
>  x7=rnorm(20)+5,
>  x8=rnorm(20)+5,
> group=rep(c(1,2),10), Age=rnorm(20)+35,strata=c(rep(1,10), rep(2,10)))
>
> nam=names(d)[1:9]
> results <- c("Protein", "OR", "p-val")
> pc3=combinations(n=length(nam),r=2)
>
> for (len in 1:dim(pc3)[2])
>  {
>  prs=pc3[len,]
>  mols=nam[prs]
>  d2=d[,c(mols,'group','Age','strata')]
>  log.reg<-clogit(group~.,data=d2)
>  a = summary(log.reg)$conf.int
>  z= summary(log.reg)$coefficients[1,4]  #ncol in coefficients is 3 * number
> of parameters
>  pval  = 2*pnorm(-abs(z))
>  res2 = c(paste('IL8+',molecule,sep=''), paste (round(a[1,1],2), " ("  ,
> round(a[1,3],2), " - " , round(a[1,4],2), ")" , sep=""), pval)
>  results  = rbind (results ,res2 )
> }
>
> Thanks
> Sharad
>
> --
> View this message in context: http://r.789695.n4.nabble.com/help-with-formula-for-clogit-tp3998967p3998967.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list