[R] recurrent events data analysis

2010-06-19 Thread avsha38

I am looking for code for modeling recurrent events with R, Especially
Andersen Gill Model /PWP models. I would greatly appreciate it if anyone can
advise of refferences / books / other relevant information. thanks in
advance.
Avshalom
-- 
View this message in context: 
http://r.789695.n4.nabble.com/recurrent-events-data-analysis-tp2261427p2261427.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] Create Dot Chart

2010-09-19 Thread avsha38

Hello everyone...

I would like to create a chart (see below), how can I do it with R?

Any help, suggestion, samples... will be greatly appreciated.

Thanks... Avi

http://r.789695.n4.nabble.com/file/n2545921/DotChart.jpg 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-Dot-Chart-tp2545921p2545921.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Create Dot Chart

2010-09-19 Thread avsha38

Hi Josh,

Great samples! Thanks a lot!
I ran your code and saw the Dot Chart, looks like what I need.

I would like to ask for your help with applying it to my file,
coming from the Theoretical world making it tough for me to apply in the
Code..
attached below is part of my dataset
num1 is ID variable
Grouping variable = ESHKOL_tert (factor with 3 levels: 1-3)
T1 - T4 are the recurrent events (time in months from index for each
subject)

http://r.789695.n4.nabble.com/file/n2546019/recmi_dots.jpg 

thanks in advance,
Avi
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-Dot-Chart-tp2545921p2546019.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Create Dot Chart

2010-09-19 Thread avsha38

Hi Josh, 

Great samples! Thanks a lot! 
I ran your code and saw the Dot Chart, looks like what I need. 

I would like to ask for your help with applying it to my file, 
coming from the Theoretical world making it tough for me to apply in the
Code.. 
attached below is part of my dataset 
num1 is ID variable 
Grouping variable = ESHKOL_tert (factor with 3 levels: 1-3) 
T1 - T4 are the recurrent events (time in months from index for each
subject) 
http://r.789695.n4.nabble.com/file/n2546047/recmi.txt recmi.txt 
thanks in advance,
Avi
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-Dot-Chart-tp2545921p2546047.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Create Dot Chart

2010-09-19 Thread avsha38

Hi Josh 

Wow, I greatly appreciate you taking the time to help out. It works
excellent!!!
I am just a beginner with R; thanks a lot for your books recommendation, I
will be using them.

If I may ask you, I have about 300 records in the full file and once I ran
the code with the full file,
The values on the Y axis are not showing properly, as they overlap each
other. 
Do you have any suggestion for solving that?

Thanks again,
Avi

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Create-Dot-Chart-tp2545921p2546250.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] poisson regression

2010-11-09 Thread avsha38

Hello All,

I have a question regarding using Poission Regression, I would like to Model
the number of hospitalizations by a set of covariates. 

The issue I ran into is "lack of fit" even after I tried to solve the
"overdispersion" problem with negetive binomial. 

What would you suggest?
1. Is the Poission Regression the right Model?
2. is there another Model that is better for my needs?

Any ideas will be more the welcome.
Thank you,
Avi

The File is attached and the code is below:
Please note that the "offset" is for dealingwith different followup times of
the subjects.

pr2<-read.csv("c:/rfiles/pr/pr_na.csv",header=TRUE)
head(pr2)
# distribution of the Response variable "zb44" , number of hospitalization. 
tab <- table(pr2$zb44)
tab
x <- as.numeric(names(tab))
plot(x, tab, type='h', xlab='Number of hospitalizations', ylab='Frequency',
main="Distribution of hospitalization")
points(x, tab, pch=16)
mean(pr2$zb44)
# find the "best model" according to AIC
fit.pr0<- glm(zb44 ~1+ offset(log(timem)),data=pr2, family=poisson) 
fit.full<- glm(zb44 ~
ESHKOL+factor(Phys_activity)+factor(PTCAwin45d)+factor(White_collar)+factor
(Asia_Africa)+factor(Sex)+Age+ factor(SteadyPartner)
 + factor(RelIncome)+ factor(Employment)+
Education+factor(CA_blockers)+Health_Prob+factor(PerceivHealth)+factor(Diuretics)+
factor(ACE)
 + factor(DiabTreat)+ factor(Insulin)+ factor(LLD)+ factor(Aspirin)+
factor(Smoking)+factor(CHD_duration)+ factor(HTN)+ factor(Diabetes)
 + factor(Hyperchol)+ factor(Intens_care)+ factor(Thromb)+
factor(AP)+ factor(QWave)+factor(AntMI)+hosp_days+factor(COPD)+
factor(B_blockers)
 + factor(Cancer)+factor(Ulcer)+factor(kilip2)+ factor(HF_index)+
factor(CVA)+Charlson_cat
 + factor(Cardiac_death)+
factor(CABGwin45d)+offset(log(timem)),data=pr2,family=poisson) 
Forw <- step(fit.pr0, scope = list(lower =fit.pr0, upper=
fit.full),direction = "both")
summary(Forw)
anova.glm(Forw ,test = "Chisq") # display significate factors
# checking model fit
1-pchisq(Forw$dev, Forw$df.residual)
# p value is nearly zero, There is a lack of fit!!!

# Residuals plots
dev.new()
par(mfrow=c(2,2))
plot(Forw , pch=23, bg='red', cex=2)

# Examine (over) dispersion
# Pearson’s residuals
(dp <- sum(resid(Forw , type = "pearson")^2)/Forw$df.resid)
summary(Forw,dispersion=dp)
# Deviance
(dp1<-Forw$deviance/Forw$df.resid)
summary(Forw,dispersion=dp1)
# Model is over dispersed

# Consider a negative binomial  to deal with overdispersion

NB.model<- step(glm.nb(hosp_total~
ESHKOL+factor(Phys_activity)+factor(PTCAwin45d)+factor(White_collar)+factor(Asia_Africa)+factor(Sex)+Age+
factor(SteadyPartner)
 + factor(RelIncome)+ factor(Employment)+
Education+factor(CA_blockers)+Health_Prob+factor(PerceivHealth)+factor(Diuretics)+
factor(ACE)
 + factor(DiabTreat)+ factor(Insulin)+ factor(LLD)+ factor(Aspirin)+
factor(Smoking)+factor(CHD_duration)+ factor(HTN)+ factor(Diabetes)
 + factor(Hyperchol)+ factor(Intens_care)+ factor(Thromb)+
factor(AP)+ factor(QWave)+factor(AntMI)+hosp_days+factor(COPD)+
factor(B_blockers)
 + factor(Cancer)+factor(Ulcer)+factor(kilip2)+ factor(HF_index)+
factor(CVA)+Charlson_cat
 + factor(Cardiac_death)+
factor(CABGwin45d)+offset(log(timem)),data=pr2)) 
summary(NB.model)
1 - pchisq(NB.model$dev, NB.model$df.residual)
par(mfrow=c(2,2))
plot(NB.model, pch=23, bg='red', cex=2)
# p value is nearly zero, There is still a lack of fit!!!
http://r.789695.n4.nabble.com/file/n3035613/pr_na.csv pr_na.csv 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/poisson-regression-tp3035613p3035613.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] using if statment and loops to create data layout of recurrent events

2010-11-13 Thread avsha38

Hi ,
I have a data set with recurrence time (up to four) of myocardial infarction
(MI).
Part of the file is showing below:
Num1Trt Sex TimeT1  T2  T3  T4
10111   1   9   
12110   1   59  
30201   2   14  3
12450   1   18  12  16  
30691   2   26  6   12  13  
20510   1   53  3   15  46  51  

The data consist of the following eight variables: 
Num1 , patient number
Trt, treatment group (1=placebo and 2=drug) 
Sex, Respondent Sex
Time, follow-up time 
T1, T2, T3, and T4, times of the  four potential recurrences of MI. A
patient with only two recurrences has missing values in T3 and T4. 
In the data set, four observations should be created for each patient, one
for each of the four potential MI recurrences. In addition to values of Trt,
and Sex for the patient, each observation contains the following variables: 
ID, patient’s identification (which is the sequence number of the subject) 
Visit, visit number (with value k for the kth potential MI recurrence) 
TStart, time of the (k–1)th recurrence for Visit=k, or the entry time 0 if
VISIT=1, or the follow-up time if the (k–1)th recurrence does not occur 
TStop, time of the  kth recurrence if Visit=k or follow-up time if the  kth
recurrence does not occur 
Status, event status of TStop (1=recurrence and 0=censored) 
For instance, patient # 3 with only one recurrence time at month 3 who was
followed until month 14 will have values for Visit, TStart, TStop, and
Status of (1,0,3,1), (2,3,14,0), (3,14,14,0), and (4,14,14,0), respectively.
If the follow-up time is beyond the time of the fourth MI recurrence, you
must ignore it. Which means that even patient with 4 recurrence times has
only four rows. 
How can I do it with R ?
Any suggestions will be more than welcome.
Avi

-- 
View this message in context: 
http://r.789695.n4.nabble.com/using-if-statment-and-loops-to-create-data-layout-of-recurrent-events-tp3040784p3040784.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] recurrent events

2010-08-09 Thread avsha38

Hello,
I have a cohort with approx 1,200 patients at the ages of 30-65 that had
their first myocardial infarction during 1992:
•   They were in a follow up until 2005.
•   About 400 of them died during this period of time (right censored)
•   Each one of them had up to 4 mi recurrent events.
I am using the semi-parametric model in order to assess the relationship of
predictors to rate of occurrence allowing for multiple events per subject.
The exposure variable ("ESHKOL") is the socio-economic of the neighborhood
while adjusting for additional variables such as age, sex, etc. In addition
each patient has geo- statics -code for his neighborhood ("stat_unit").
I ran an Andersen Gill model:
Ag<-coxph(Surv(TStart,TStop,Status)~ ESHKOL+VAR1+
VAR2+cluster(id),data=recmi)
My questions are:
•   I would like to check the unique effect of the "stat_unit" variable. How
can I write it in code?
•   In your opinion does the AG model is the best model for this type of 
data?
Or should I use models that consider the order of the events such as PWP or
WLW?
Thank you, Avi.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/recurrent-events-tp2318296p2318296.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] frailtypack

2010-08-17 Thread avsha38

Hello everyone,

I have a question about using frailtypack to run recurrent events data. 
I have a file with 1,580 events. The file structure fits the andersen gill
model.
When I run the file with all records, the R stops and shuts down.
Once I run only part of the file, about 400 events, R runs without a
problem.
Any idea why it happens?

In addition when I run a Nested frailty model with the below code the R
stops and shuts down as well:
cgd.nfm <-frailtyPenal(Surv(TStart, TStop,
Status)~cluster(Center)+subcluster(ID)+
Treatment,data=cgd.ag, n.knots=8,kappa1=5) 

I would greatly appreciate it if anyone can help me out.
Thank you very much,
Avi


-- 
View this message in context: 
http://r.789695.n4.nabble.com/frailtypack-tp2328606p2328606.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] recurrent events

2010-08-18 Thread avsha38

Hello everyone,

I have a question about using "frailtypack" to run recurrent events data. 
I have a file with 1,580 events. The file structure fits the andersen gill
model.
When I run the file with all records, the R stops and shuts down.
Once I run only part of the file, about 400 events, R runs without a
problem.
Any idea why it happens?

In addition when I run a "Nested frailty model" with the below code, R stops
and shuts down as well:
cgd<-frailtyPenal(Surv(TStart, TStop,
Status)~cluster(Center)+subcluster(ID)+
Treatment,data=cgd.ag, n.knots=8,kappa1=5) 

I would greatly appreciate it if anyone can help me out.
Thank you very much,
Avi

-- 
View this message in context: 
http://r.789695.n4.nabble.com/recurrent-events-tp2329539p2329539.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] memory problem

2010-08-18 Thread avsha38

Hi,
when i run the following code i get this massege:

"The instruction at 0x reference memory at 

0x###, the memory cannot be "read". 
and then i have to close R.

what is the problem and how can i solve it?

thanks in advance
Avi

my code

# frailtypack
library(frailtypack)
cgd.ag <- read.csv("C:/rfiles/RE/cgd.csv")
cgd.nfm <-frailtyPenal(Surv(TStart, TStop,
Status)~cluster(Center)+subcluster(ID) 
 Treatment,data=cgd.ag,Frailty=TRUE,n.knots=8,kappa1=5, 
   cross.validation=TRUE,recurrentAG=TRUE)

  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/memory-problem-tp2330510p2330510.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] Survival Analysis

2011-07-05 Thread avsha38
Hello,

I have few questions about recurring events. I would greatly appreciate it
if anyone can assist me.

I have data that consist of approx 1,100 Consecutive patients released from
hospital after first Myocardial infarction (MI). They were followed for 13
years. Recurrent MI and unstable angina pectoris (UAP) leading to
hospitalization were recorded (within-subject range: 0-4 for recurrent MI;
0-19 for UAP). Socio demographic and clinical data were obtained at study
entry. 
I want to fit Semiparametric regression models. 

1. What will be the best method regarding the time scale (calendar times or
gap times) when I want the fit a model for recurrent MI ? For the UAP
recurrent event? 

2. In 25% of the subjects the last MI event was fatal; will it be correct to
consider fatal and non-fatal events as if they are events of the same type?
Which R Package is best to deal with informative censoring? Can the
"Survival" Package deal with this?

Thanks in advance,
Avi

--
View this message in context: 
http://r.789695.n4.nabble.com/Survival-Analysis-tp3646804p3646804.html
Sent from the R help mailing list archive at Nabble.com.

__
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.