Hello,
I've executed the following predict.coxph function to enable prediction for
new variable values (error is included).

*predict(cox_out,newdata=data.frame(Meter3.Value=100.001,
Meter4.Value=200.001,Meter5.Value=300.001,Meter10.Value=
400.001,type="expected"))

Error in model.frame.default(data = data.frame(Meter3.Value = 100.001,  :
  variable lengths differ (found for 'Meter3.Value')

6: model.frame.default(data = data.frame(Meter3.Value = 100.001,
       Meter4.Value = 200.001, Meter5.Value = 300.001, Meter10.Value =
400.001,
       type = "expected"), formula = ads1S ~ Meter3.Value + Meter4.Value +
       Meter5.Value + Meter10.Value, na.action = function (object, ...)
 object)*


I feel as though I've exhaustively researched the "variable length" problem,
that is:
Meter3.Value is Double, Numeric in both the original dataframe that created
the cox_out object (i.e., type: list   class:coxph) and Double, Numeric in
the newdata dataframe below.

Thanks for taking a look at this.
Steve

I've included all the code and two datasets at this location in Dropbox:

https://www.dropbox.com/sh/2m51tl4l60iq9ru/0DkPYA1E-c

   1. R_code_for_coxph.txt is the set of R functions used in the analysis
   2. final_sheet_v3_2.xlsx is the input data set
   3. cox_out.R is the coxph object





I'm also curious if anyone has had any experience with the collapse
parameter in predict().  Any insight here would be very helpful.
I'm using the same data as above.
I'm assuming, based on the documentation, that collapse is just a vector of
the subject ID's to aggregate
the hazard function by subject ID but it's not working.  I created a simple
dataframe
called collapse:
ASSET_ID
1       260
2       263

but the predict function is complaining about one of the covariates:

*predict(cox_out,type="expected",collapse)*

*Error in eval(expr, envir, enclos) : object 'Meter3.Value' not found*

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to