Trying to find diffusion coefficient, need advice on coding concept

Hi Rstudio community,

I am still fairly new to R and would love some advice on developing a line of code to help calculate the diffusion coefficient given that I have x, y, and t coordinates. This is more of a conceptual question rather than a full on coding question. I appreciate any help, thank you!

This is my currently work flow

  1. Calculate displacement and append to data frame
  2. Aggregating / grouping displacement based on an identifier and averaging the values
  3. Calculate the mean squared displacement by squaring the mean displacement
  4. Repeat mean squared displacement calculation for steps in t (t = 2, t = 3 ... corresponding to skipping over every other or every third row)
  5. Average all MSD in each group of T (Average MSD1 in T1, ... MSD# in T#)
  6. Plotting the averaged MSD against T
  7. Performing a linear least squared regression to get the coefficients

I am unsure if I am working in the right direction or is completely off track.

Thanks!

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.