Thanks Michael.
I have read the original article and I guess whether the following formula
could resolve my question?

*for adjusted HR of each BMI category,*
fit<-coxph(Surv~factor(BMI-category)+..+covariates)
*for trend, *
fit<-coxph(Surv~as.numeric(BMI-category)+..+covariates)
*# p trend may be the p value of BMI-category coded as continuous*
*for linearity*
fit1<-coxph(Surv~BMI-as-continuous+..+covariates)
fit2<-coxph(Surv~rcs(BMI-as-continuous,3)+..+covariates) # some non-linear
coding of BMI-as-continuous
lrtest(fit1, fit2)
*# p linearity may be the p value of lrtest*

*Yao Zhu*


*Department of UrologyFudan University Shanghai Cancer CenterShanghai,
China*


2014/1/5 Michael Friendly <friendly@yorku.ca>

> On 1/4/2014 12:39 AM, zhu yao wrote:
>
>> Dear Sir
>> Many papers calculated the p value of trends for odds ratios of ordered
>> category variables. I have found the tabodds command in Stata. But how to
>> do it in R?
>> Thanks
>>
>> *Yao Zhu*
>>
>
> If what you are looking at is a 2 x 2 x k table, where you want the odds
> ratios for the k strata, which are ordered, perhaps something like this:
>
> data("CoalMiners", package="vcd")
>
> ## Log Odds Ratio Plot
> lodds <- oddsratio(CoalMiners)
> summary(lodds)
>
> plot(lodds, lwd=2, cex=1.25, pch=16,
>      xlab = "Age Group",
>      main = "Breathlessness and Wheeze in Coal Miners")
>
> age <- seq(25, 60, by = 5)
> mod <- lm(lodds ~ poly(age,2))
> lines(fitted(mod), col = "red", lwd=2)
>
> Tests of the coefficients in mod give the tests of linear and quadratic
> changes in the odds ratio with age.
>
>
> --
> Michael Friendly     Email: friendly AT yorku DOT ca
> Professor, Psychology Dept. & Chair, Quantitative Methods
> York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
> 4700 Keele Street    Web:   http://www.datavis.ca
> Toronto, ONT  M3J 1P3 CANADA
>

	[[alternative HTML version deleted]]


