OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can you generate MCAR, MNAR and MAR missingness pattern in a dataset using python?

  • Thread starter Thread starter Rajesh Bhandari
  • Start date Start date
R

Rajesh Bhandari

Guest
For MCAR, it is simply missing completely at random, and using random might work for MCAR. Example:

Code:
reshaped = data.reshape(data.shape[0]*data.shape[1],data.shape[2])
x = reshaped.shape[0]
y = reshaped.shape[1]
for i in range(0,math.ceil(x*y*mdp/100)):
  reshaped[random.randint(0,x-1),random.randint(0,y-1)] = float('nan')

I have looked into several documents, but not exactly I could find simpler version with proper explanation to generation of missing data pattern
<p>For MCAR, it is simply missing completely at random, and using random might work for MCAR.
Example:</p>
<pre><code>reshaped = data.reshape(data.shape[0]*data.shape[1],data.shape[2])
x = reshaped.shape[0]
y = reshaped.shape[1]
for i in range(0,math.ceil(x*y*mdp/100)):
reshaped[random.randint(0,x-1),random.randint(0,y-1)] = float('nan')

</code></pre>
<p>I have looked into several documents, but not exactly I could find simpler version with proper explanation to generation of missing data pattern</p>
 

Latest posts

Top