[R] Generating weights based on certain condition in the dataset
Sudhi.Upadhyaya
sudhi.upadhyaya at ndsu.edu
Tue Dec 13 17:12:28 CET 2011
Dear all,
My goal is to create weights.
I have three covariates x1 x2 x3
These three covariates are discrete, they can only store either 1 or 0. So
x1 x2 x3
----------
0 1 0
0 0 1
1 0 0
1 1 0
1 0 1
0 1 1
......
Sometimes they have missing data
x1 x2 x3
----------
0 1 -
0 0 1
1 - 0
1 1 0
- 0 1
0 - -
......
I need help to generate the following situation
a) If there is a missing data then it can either be 0 0r 1. So lets consider
the first row. The new program should create 2 new rows because x13 is
missing. The two new rows should be like this
x1 x2 x3 weight
----------------
0 1 0 w1=0.5
0 1 0 w2=0.5
0 0 1
1 - 0
1 1 0
- 0 1
0 - -
......
Consider the last row. The last row contains two missing data. So the new
program should create 4 new rows. The new rows should be like this.
x1 x2 x3 weight
----------------
0 1 0 w1=0.5
0 1 0 w2=0.5
0 0 1
1 - 0
1 1 0
- 0 1
0 0 0 w1 =0.25
0 1 1 w2 =0.25
0 0 1 w3 =0.25
0 1 0 w4 =0.25
......
Also please see the image attached. Please let me know if you have more
questions.
Sincerely
Sudhi Upadhyaya
http://r.789695.n4.nabble.com/file/n4190948/weights.png weights.png
--
View this message in context: http://r.789695.n4.nabble.com/Generating-weights-based-on-certain-condition-in-the-dataset-tp4190948p4190948.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list