Medical cost due to different treatments is one of the important aspects to evaluate in addition to the clinical outcomes. Commonly used approaches in the literature are to compare the average lifetime cost (or one-year cost) due to treatments since the diagnosis of a disease, which usually doesn’t provide cost pattern. Here, we develop a dynamic model (i.e., I–spline model) to examine the average cost trajectory over time due to treatment based on observational data and compare their cost trajectory differences due to treatments. To control for the selection bias, we use the propensity score-based approaches, such as the inverse probability of treatment weighting (IPTW) method and doubly robust method to estimate the cost trajectory. In the doubly robust method, we use I-splines, which is quite flexible to capture different cost patterns, to model the cost trajectory. We also consider the possible censoring observations and use the IPTW of non-censoring to estimate the spline function and cost trajectory. Extensive simulations are carried out to examine the performance of the proposed method for estimating the cost trajectory on pancreatic patients in the SEER-Medicare database.