[R] Problem with predict.coxph
michael.conklin at markettools.com
Wed Aug 19 16:21:53 CEST 2009
In examining the predict.coxph functions for the library I have with 2.7.1 versus the library with 2.9.1 I find a major rewrite of the function. A number of "internal survival functions" are no longer present so much of the code has changed. This makes identifying the specific problem beyond my capabilities. What I want to do, is generate predictions for specific combinations of covariates. The number of combinations I am interested in is different than the number of records in the original data file. Any help would be appreciated as some of the graphic routines I want to use on the data are only available in 2.8 or greater - meaning I am currently looking at trying to run two different versions of R to get the project done.
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Michael Conklin
Sent: Tuesday, August 18, 2009 8:26 PM
To: r-help at r-project.org
Subject: [R] Problem with predict.coxph
We occasionally utilize the coxph function in the survival library to fit multinomial logit models. (The breslow method produces the same likelihood function as the multinomial logit). We then utilize the predict function to create summary results for various combinations of covariates. For example:
The model runs fine.
Then we create some new data that is all combinations of Price and Product and retrieve the summary linear predictors.
## create a utility matrix for all combinations of prices and products
Under R 2.7.1 this produces the following output:
The problem is that under R 2.8.1 and R 2.9.1 the previous line fails with the following error:
Error in model.frame.default(Terms2, newdata, xlev = object$xlevels) :
variable lengths differ (found for 'Price')
In addition: Warning message:
'newdata' had 25 rows but variable(s) found have 43350 rows
Does anyone have an idea what is going on?
W. Michael Conklin
MarketTools, Inc. | www.markettools.com<http://www.markettools.com>
6465 Wayzata Blvd | Suite 170 | St. Louis Park, MN 55426. PHONE: 952.417.4719 | CELL: 612.201.8978
This email and attachment(s) may contain confidential and/or proprietary information and is intended only for the intended addressee(s) or its authorized agent(s). Any disclosure, printing, copying or use of such information is strictly prohibited. If this email and/or attachment(s) were received in error, please immediately notify the sender and delete all copies
[[alternative HTML version deleted]]
R-help at r-project.org mailing list
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