Multiple time-series -- measuring medication weight gain First - very new to Statistics; about half through a basic biostats book and an R book. 
I have a set of data where I"m trying to see if there is a correlation between a medication and weight gain. The dataset: 


*

*~2200 patients

*A list of their primary diagnoses, weight, date's of visit, and whether they were on medication at that time. 

*Each patient may be on or off the medication at various points, though I have limited the data set to patients receiving at least 90 days of medication. 

*Different patients are on / off the medication for varying # of days. Also, each patient has recorded visit for a varying amount of total days (though at least 90 based on 90 day min. medication limit from #2). 



My main goals are:  


*

*Is this medication correlated with weight gain? 

*If so / not - does it depend on a certain threshold length of constant use? 

*(Eventually) do either of the above two correlations change based on the patients diagnoses (Some pt's will be grouped together) 


My question is - really, where should I begin? What types of analyses should I be doing? I'm willing to put in the reading / work to figure it out; but I'm not quite sure where to look. As stated in intro, I have - some - experience with R, and am expecting to carry out my in depth analysis in that. 
UPDATE:
So far, I have been looking at Average of change in weight / days on medication; so basically giving each patient a Wt. Change per day of med. Im planning on adding wt. change per day while off medication and all patient variables, but this illuminates what I need something more advanced for --
How do I account for trends occurring independent of medication. A thought - say a patient started a diet, and has been steadily losing 1lb per week prior to medicaiton. If that medication is started, it is possible the overall trend will overshadow the medication effect. In this case - is there a practical way to account for long term trends, without examining each patients data individually? 
 A: Welcome to the wonderful world of Statistics.  Despite a Masters degree in Medical Statistics, it never ceases to amaze me that the one thing I am learning over and over again is how little I actually understand about this fascinating modality!!
For what it is worth from a non-practising and not very experienced statistician, you need to look at a time-series data analysis with a time varying covariate. The Cox Proportional Hazards model can be used for this data with relative ease.
Check out this paper on the CRAN website:
Cox Proportional Hazards Regression (J Fox, 2002)
My two cents - hope it's useful.
A: You have a panel (2200 patiens x 90 days). But it could be complicated to organize it that way. Suggestion as a starting point: (1) Compare two states, i.e. "before" and "after" treatment-period (90 days), and look at changes in weight (x) and medication (y) during the 90-days period. (2) Run a regression (ordinary least squares) between y = f(x) with and without a constant. The constant absorbes autonomous effects from other factors than weight loss. You can also add other, relevant variables in the model.
P.
