Survival model error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Survival model error

R help mailing list-2

Hi - Below is my code and then the error when I run the last line.
 
time_np <- train1_na$tte
event_np <- train1_na$censored
 
 
X_np <- cbind(
  train1_na$AMT,
  train1_na$DISCOUNT_AMT,
  train1_na$high_price_pcnt,
  train1_na$EM_RECEIVED,
  train1_na$DM_RECEIVED,
  train1_na$TXN_WITH_RINGCODE,
  train1_na$WEB,
  train1_na$clearance_pcnt,
  train1_na$bts_pcnt,
  train1_na$sales_pcnt,
  train1_na$holiday_pcnt,
  train1_na$TXN,
  train1_na$REDEEMED_REWARDS
 
  )
 
# Kaplan-Meier non-parametric analysis

kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np)
 
Error in `[.default`(y, who, 1) : (subscript) logical subscript too long
 
Any ideas?  
I have tried several things and still get this error.  
 

Thanks,
Meghna

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Survival model error

David Winsemius
You should stop trying to use matrices on the RHS and using separate vectors to Surv. Instead use a data argument and have the names in your formula refer to column names.


David

Sent from my iPhone

> On Nov 5, 2017, at 7:21 PM, Meghna Govil via R-help <[hidden email]> wrote:
>
>
> Hi - Below is my code and then the error when I run the last line.
>
> time_np <- train1_na$tte
> event_np <- train1_na$censored
>
>
> X_np <- cbind(
>  train1_na$AMT,
>  train1_na$DISCOUNT_AMT,
>  train1_na$high_price_pcnt,
>  train1_na$EM_RECEIVED,
>  train1_na$DM_RECEIVED,
>  train1_na$TXN_WITH_RINGCODE,
>  train1_na$WEB,
>  train1_na$clearance_pcnt,
>  train1_na$bts_pcnt,
>  train1_na$sales_pcnt,
>  train1_na$holiday_pcnt,
>  train1_na$TXN,
>  train1_na$REDEEMED_REWARDS
>
>  )
>
> # Kaplan-Meier non-parametric analysis
>
> kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np)
>
> Error in `[.default`(y, who, 1) : (subscript) logical subscript too long
>
> Any ideas?  
> I have tried several things and still get this error.  
>
>
> Thanks,
> Meghna
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Survival model error

R help mailing list-2
Thanks David. Could you show me how to do that in my example ?

Thanks,
Meghna

> On Nov 6, 2017, at 12:58 AM, David Winsemius <[hidden email]> wrote:
>
> You should stop trying to use matrices on the RHS and using separate vectors to Surv. Instead use a data argument and have the names in your formula refer to column names.
>
> —
> David
>
> Sent from my iPhone
>
>> On Nov 5, 2017, at 7:21 PM, Meghna Govil via R-help <[hidden email]> wrote:
>>
>>
>> Hi - Below is my code and then the error when I run the last line.
>>
>> time_np <- train1_na$tte
>> event_np <- train1_na$censored
>>
>>
>> X_np <- cbind(
>> train1_na$AMT,
>> train1_na$DISCOUNT_AMT,
>> train1_na$high_price_pcnt,
>> train1_na$EM_RECEIVED,
>> train1_na$DM_RECEIVED,
>> train1_na$TXN_WITH_RINGCODE,
>> train1_na$WEB,
>> train1_na$clearance_pcnt,
>> train1_na$bts_pcnt,
>> train1_na$sales_pcnt,
>> train1_na$holiday_pcnt,
>> train1_na$TXN,
>> train1_na$REDEEMED_REWARDS
>>
>> )
>>
>> # Kaplan-Meier non-parametric analysis
>>
>> kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np)
>>
>> Error in `[.default`(y, who, 1) : (subscript) logical subscript too long
>>
>> Any ideas?  
>> I have tried several things and still get this error.  
>>
>>
>> Thanks,
>> Meghna
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Survival model error

Michael Dewey-3
Try putting your data.frame (train_na) as argument to the data=
parameter and then in the formula put the actual variable names but
without the train_na$ prefix.

On 06/11/2017 13:45, Meghna Govil via R-help wrote:

> Thanks David. Could you show me how to do that in my example ?
>
> Thanks,
> Meghna
>
>> On Nov 6, 2017, at 12:58 AM, David Winsemius <[hidden email]> wrote:
>>
>> You should stop trying to use matrices on the RHS and using separate vectors to Surv. Instead use a data argument and have the names in your formula refer to column names.
>>
>> —
>> David
>>
>> Sent from my iPhone
>>
>>> On Nov 5, 2017, at 7:21 PM, Meghna Govil via R-help <[hidden email]> wrote:
>>>
>>>
>>> Hi - Below is my code and then the error when I run the last line.
>>>
>>> time_np <- train1_na$tte
>>> event_np <- train1_na$censored
>>>
>>>
>>> X_np <- cbind(
>>> train1_na$AMT,
>>> train1_na$DISCOUNT_AMT,
>>> train1_na$high_price_pcnt,
>>> train1_na$EM_RECEIVED,
>>> train1_na$DM_RECEIVED,
>>> train1_na$TXN_WITH_RINGCODE,
>>> train1_na$WEB,
>>> train1_na$clearance_pcnt,
>>> train1_na$bts_pcnt,
>>> train1_na$sales_pcnt,
>>> train1_na$holiday_pcnt,
>>> train1_na$TXN,
>>> train1_na$REDEEMED_REWARDS
>>>
>>> )
>>>
>>> # Kaplan-Meier non-parametric analysis
>>>
>>> kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np)
>>>
>>> Error in `[.default`(y, who, 1) : (subscript) logical subscript too long
>>>
>>> Any ideas?
>>> I have tried several things and still get this error.
>>>
>>>
>>> Thanks,
>>> Meghna
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Survival model error

David Winsemius
In reply to this post by R help mailing list-2

> On Nov 6, 2017, at 5:45 AM, Meghna Govil <[hidden email]> wrote:
>
> Thanks David. Could you show me how to do that in my example ?

Possibly:

kmsurvival_np <- survfit(Surv( tte, censored) ~ . , data=train1_na)

I say "possibly" because I don't know whether all the columns of `train1_na` were included in the matrix you constructed. If they weren't then you would need to do something like:

kmsurvival_np <- survfit(Surv( tte, censored) ~ <lots of names separated by "+"'s> , data=train1_na)


The formalism of `reg_func( Y , Xm)` Where Xm is a matrix is typical for various machine-learning types of procedures, but breaks the "process-names-in-an-environment model of typical R regression functions. R regression functions often omit "step-down" options so loved by beginning SAS users.


>
> Thanks,
> Meghna
>
>> On Nov 6, 2017, at 12:58 AM, David Winsemius <[hidden email]> wrote:
>>
>> You should stop trying to use matrices on the RHS and using separate vectors to Surv. Instead use a data argument and have the names in your formula refer to column names.
>>
>> —
>> David
>>
>> Sent from my iPhone
>>
>>> On Nov 5, 2017, at 7:21 PM, Meghna Govil via R-help <[hidden email]> wrote:
>>>
>>>
>>> Hi - Below is my code and then the error when I run the last line.
>>>
>>> time_np <- train1_na$tte
>>> event_np <- train1_na$censored
>>>
>>>
>>> X_np <- cbind(
>>> train1_na$AMT,
>>> train1_na$DISCOUNT_AMT,
>>> train1_na$high_price_pcnt,
>>> train1_na$EM_RECEIVED,
>>> train1_na$DM_RECEIVED,
>>> train1_na$TXN_WITH_RINGCODE,
>>> train1_na$WEB,
>>> train1_na$clearance_pcnt,
>>> train1_na$bts_pcnt,
>>> train1_na$sales_pcnt,
>>> train1_na$holiday_pcnt,
>>> train1_na$TXN,
>>> train1_na$REDEEMED_REWARDS
>>>
>>> )
>>>
>>> # Kaplan-Meier non-parametric analysis
>>>
>>> kmsurvival_np <- survfit(Surv(time_np,event_np) ~ X_np)
>>>
>>> Error in `[.default`(y, who, 1) : (subscript) logical subscript too long
>>>
>>> Any ideas?  
>>> I have tried several things and still get this error.  
>>>
>>>
>>> Thanks,
>>> Meghna
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.