I have a balanced panel data of life satisfaction for 1607 individuals across three years (2014, 2016, 2018).
I'd like to create a transition matrices for life satisfaction between two years: (2014,2016), (2014, 2018) and (2016, 2018)
Here is the example table that I would like to make
Life satisfaction | 2016 | ||||
1 | 2 | 3 | 4 | ||
2014 | 1 | ||||
2 | |||||
3 | |||||
4 |
Could you please tell me how can I make the above transition matrix? and if possible, to make transition matrices in bar charts, too.
I copy here my panel data
Thank you very much!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(pid2014 year) byte life_satisfaction 5 2014 2 5 2016 3 5 2018 2 6 2014 3 6 2016 2 6 2018 2 7 2014 3 7 2016 3 7 2018 2 8 2014 1 8 2016 2 8 2018 2 9 2014 1 9 2016 2 9 2018 2 10 2014 2 10 2016 2 10 2018 2 14 2014 3 14 2016 2 14 2018 2 16 2014 3 16 2016 2 16 2018 2 17 2014 3 17 2016 2 17 2018 2 18 2014 2 18 2016 2 18 2018 2 22 2014 4 22 2016 2 22 2018 2 26 2014 2 26 2016 2 26 2018 2 27 2014 2 27 2016 2 27 2018 1 30 2014 3 30 2016 2 30 2018 2 35 2014 3 35 2016 3 35 2018 2 36 2014 3 36 2016 2 36 2018 2 39 2014 2 39 2016 2 39 2018 2 45 2014 4 45 2016 3 45 2018 3 47 2014 3 47 2016 2 47 2018 2 53 2014 2 53 2016 3 53 2018 3 57 2014 3 57 2016 2 57 2018 1 60 2014 2 60 2016 2 60 2018 2 61 2014 3 61 2016 2 61 2018 3 65 2014 3 65 2016 2 65 2018 2 68 2014 2 68 2016 3 68 2018 2 72 2014 4 72 2016 2 72 2018 3 77 2014 4 77 2016 3 77 2018 2 78 2014 3 78 2016 2 78 2018 2 80 2014 2 80 2016 2 80 2018 2 81 2014 2 81 2016 2 81 2018 2 82 2014 2 82 2016 2 82 2018 2 83 2014 3 83 2016 3 83 2018 2 87 2014 2 87 2016 2 87 2018 2 88 2014 3 88 2016 3 88 2018 2 90 2014 2 90 2016 2 90 2018 2 91 2014 3 91 2016 3 91 2018 2 92 2014 3 92 2016 2 92 2018 2 94 2014 2 94 2016 2 94 2018 2 97 2014 2 97 2016 2 97 2018 2 98 2014 4 98 2016 3 98 2018 2 102 2014 2 102 2016 2 102 2018 3 105 2014 3 105 2016 2 105 2018 2 106 2014 3 106 2016 2 106 2018 2 108 2014 3 108 2016 2 108 2018 2 109 2014 2 109 2016 2 109 2018 2 112 2014 2 112 2016 2 112 2018 3 114 2014 1 114 2016 2 114 2018 2 115 2014 2 115 2016 2 115 2018 2 116 2014 4 116 2016 3 116 2018 3 117 2014 2 117 2016 3 117 2018 2 118 2014 2 118 2016 3 118 2018 2 119 2014 4 119 2016 3 119 2018 2 124 2014 3 124 2016 2 124 2018 2 128 2014 2 128 2016 2 128 2018 2 129 2014 2 129 2016 2 129 2018 2 130 2014 2 130 2016 2 130 2018 2 135 2014 3 135 2016 2 135 2018 2 140 2014 2 140 2016 2 140 2018 2 147 2014 2 147 2016 2 147 2018 2 148 2014 2 148 2016 2 148 2018 2 155 2014 2 155 2016 2 155 2018 2 158 2014 3 158 2016 3 158 2018 2 165 2014 3 165 2016 3 165 2018 2 167 2014 3 167 2016 3 167 2018 2 169 2014 4 169 2016 4 169 2018 4 175 2014 3 175 2016 2 175 2018 2 176 2014 2 176 2016 2 176 2018 2 181 2014 3 181 2016 2 181 2018 2 182 2014 3 182 2016 3 182 2018 2 183 2014 2 183 2016 2 183 2018 2 184 2014 3 184 2016 3 184 2018 2 188 2014 3 188 2016 2 188 2018 2 189 2014 4 189 2016 2 189 2018 2 190 2014 2 190 2016 3 190 2018 2 193 2014 3 193 2016 2 193 2018 2 195 2014 2 195 2016 2 195 2018 2 201 2014 3 201 2016 2 201 2018 2 204 2014 2 204 2016 2 204 2018 2 205 2014 3 205 2016 3 205 2018 2 206 2014 3 206 2016 2 206 2018 3 211 2014 1 211 2016 2 211 2018 2 212 2014 3 212 2016 2 212 2018 2 213 2014 3 213 2016 2 213 2018 2 214 2014 2 214 2016 3 214 2018 3 215 2014 3 215 2016 2 215 2018 2 217 2014 2 217 2016 2 217 2018 2 218 2014 2 218 2016 2 218 2018 2 223 2014 2 223 2016 2 223 2018 2 224 2014 3 224 2016 2 224 2018 3 225 2014 3 225 2016 2 225 2018 3 226 2014 3 226 2016 3 226 2018 3 227 2014 2 227 2016 3 227 2018 3 232 2014 3 232 2016 2 232 2018 2 233 2014 3 233 2016 2 233 2018 1 234 2014 2 234 2016 2 234 2018 3 237 2014 3 237 2016 4 237 2018 3 240 2014 3 240 2016 3 240 2018 3 241 2014 3 241 2016 3 241 2018 2 242 2014 3 242 2016 1 242 2018 2 244 2014 3 244 2016 2 244 2018 2 246 2014 2 246 2016 2 246 2018 2 251 2014 2 251 2016 2 251 2018 2 252 2014 2 252 2016 2 252 2018 3 253 2014 3 253 2016 2 253 2018 2 255 2014 2 255 2016 2 255 2018 2 256 2014 2 256 2016 2 256 2018 2 259 2014 2 259 2016 2 259 2018 2 263 2014 3 263 2016 2 263 2018 2 270 2014 2 270 2016 2 270 2018 2 273 2014 3 273 2016 2 273 2018 2 274 2014 2 274 2016 2 274 2018 1 278 2014 2 278 2016 2 278 2018 1 279 2014 2 279 2016 2 279 2018 2 280 2014 3 280 2016 2 280 2018 2 284 2014 2 284 2016 2 284 2018 2 285 2014 2 285 2016 2 285 2018 2 287 2014 3 287 2016 2 287 2018 2 289 2014 2 289 2016 2 289 2018 2 292 2014 2 292 2016 2 292 2018 2 295 2014 3 295 2016 3 295 2018 2 296 2014 2 296 2016 2 296 2018 2 297 2014 3 297 2016 2 297 2018 1 302 2014 2 302 2016 2 302 2018 2 305 2014 2 305 2016 2 305 2018 2 309 2014 4 309 2016 2 309 2018 2 310 2014 4 310 2016 3 310 2018 2 311 2014 2 311 2016 2 311 2018 2 316 2014 4 316 2016 2 316 2018 2 318 2014 2 318 2016 2 318 2018 3 319 2014 3 319 2016 3 319 2018 2 322 2014 4 322 2016 2 322 2018 2 327 2014 2 327 2016 3 327 2018 2 331 2014 2 331 2016 2 331 2018 2 332 2014 2 332 2016 2 332 2018 3 334 2014 1 334 2016 2 334 2018 3 336 2014 1 336 2016 2 336 2018 2 338 2014 1 338 2016 2 338 2018 2 340 2014 1 340 2016 3 340 2018 2 341 2014 2 341 2016 3 341 2018 2 342 2014 2 342 2016 2 342 2018 2 344 2014 1 344 2016 2 344 2018 1 345 2014 2 345 2016 3 345 2018 2 346 2014 2 346 2016 1 346 2018 2 351 2014 2 351 2016 1 351 2018 2 354 2014 2 354 2016 2 354 2018 3 355 2014 3 355 2016 2 355 2018 3 356 2014 2 356 2016 3 356 2018 2 359 2014 1 359 2016 2 359 2018 2 364 2014 2 364 2016 2 364 2018 2 366 2014 2 366 2016 2 366 2018 2 367 2014 1 367 2016 2 367 2018 2 368 2014 2 368 2016 2 368 2018 2 369 2014 2 369 2016 2 369 2018 2 371 2014 2 371 2016 2 371 2018 2 372 2014 3 372 2016 2 372 2018 3 377 2014 1 377 2016 2 377 2018 2 380 2014 3 380 2016 3 380 2018 4 381 2014 3 381 2016 2 381 2018 2 382 2014 2 382 2016 2 382 2018 2 383 2014 2 383 2016 2 383 2018 2 384 2014 2 384 2016 2 384 2018 2 387 2014 2 387 2016 2 387 2018 2 388 2014 2 388 2016 3 388 2018 3 392 2014 2 392 2016 3 392 2018 2 394 2014 3 394 2016 2 394 2018 2 395 2014 2 395 2016 2 395 2018 3 396 2014 3 396 2016 2 396 2018 2 397 2014 2 397 2016 2 397 2018 2 400 2014 4 400 2016 2 400 2018 2 401 2014 2 401 2016 2 401 2018 2 408 2014 3 408 2016 2 408 2018 2 409 2014 3 409 2016 2 409 2018 2 413 2014 2 413 2016 2 413 2018 2 417 2014 4 417 2016 3 417 2018 2 419 2014 2 419 2016 2 419 2018 2 426 2014 2 426 2016 2 426 2018 3 427 2014 2 427 2016 2 427 2018 2 430 2014 2 430 2016 2 430 2018 2 431 2014 3 431 2016 2 431 2018 2 432 2014 3 432 2016 2 432 2018 2 434 2014 1 434 2016 3 434 2018 2 435 2014 2 435 2016 2 435 2018 2 436 2014 1 436 2016 2 436 2018 2 437 2014 3 437 2016 2 437 2018 2 439 2014 2 439 2016 2 439 2018 2 440 2014 2 440 2016 2 440 2018 2 443 2014 3 443 2016 2 443 2018 2 447 2014 2 447 2016 2 447 2018 2 450 2014 2 450 2016 2 450 2018 2 451 2014 2 451 2016 2 451 2018 2 454 2014 3 454 2016 2 454 2018 2 455 2014 4 455 2016 2 455 2018 3 460 2014 2 460 2016 2 460 2018 2 465 2014 2 465 2016 2 465 2018 2 467 2014 2 467 2016 2 467 2018 2 472 2014 2 472 2016 1 472 2018 2 473 2014 2 473 2016 2 473 2018 2 476 2014 3 476 2016 2 476 2018 2 495 2014 3 495 2016 2 495 2018 2 497 2014 3 497 2016 2 497 2018 2 end
0 Response to How to create transition matrices for life satisfaction
Post a Comment