When comparing the causal effect of peritoneal dialysis (PD) and hemodialysis (HD) treatment on lowering mortality in renal patients, using observational data, it is necessary to adjust for different forms of confounding and informative censoring. Both the type of dialysis treatment that is started with and mortality are affected by baseline covariates. Longitudinal and baseline variables can affect both the probability of switching from one type of dialysis to the other, and mortality. Longitudinal and baseline variables can also affect the probability of receiving a kidney transplant, possibly causing informative censoring. Adjusting for longitudinal variables by including them as covariates in a regression model potentially causes bias, for instance by losing a possible indirect effect of dialysis on mortality via these longitudinal variables. Instead, we fitted a marginal structural model (MSM) to estimate the causal effect of dialysis type, adjusted for confounding and informative censoring. We used the MSM to compare the hazard of death as well as cumulative survival between the potential treatment trajectories "always PD" and "always HD" over time, conditional on age and diabetes mellitus status. We used inverse probability weighting (IPW) to fit the MSM.