楼主: Lisrelchen
1151 4

Workshops & Lectures: Applied Longitudinal Data Analysis [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4194份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50288 个
通用积分
83.6306
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2016-5-29 05:19:40 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

Applied Longitudinal Data Analysis with HLM
Association for Behavioral and Cognitive Therapies (ABCT) conference



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Longitudinal Longitudina workshop Analysis Lectures

本帖被以下文库推荐

沙发
Lisrelchen 发表于 2016-5-29 05:20:22
  1. * Stata code for 2010 ABCT workshop on HLM for Longitudinal Data Analysis
  2. clear
  3. set more off

  4. *read in data
  5. insheet using "Sex and Stress Data UPDATED.txt", tab

  6. *take a look at data structure
  7. describe, detail

  8. *first 10 rows of data
  9. list in 1/10

  10. *create a numeric gender variable (men=1, women=0)
  11. gen gender2=gender=="Male"

  12. *summary of variables
  13. summarize week-sex stress-gender2, detail

  14. *sort by id and week
  15. sort id week

  16. *Is data balanced by week and id?
  17. tabulate week
  18. tabulate id

  19. *What does outcome look like?
  20. histogram sex, freq discrete xtitle("") ytitle("Frequency") title("Histogram of Number of Sexual Encounters (per week)") text(250 20 "M: 2.6") text(230 20 "SD: 2.9")

  21. *Growth curves for 20 individuals
  22. twoway line sex week if (id>=75 & id<=94), by(id, note("") title("Number of Sexual Encounters"  "Across Weeks for 20 Subjects")) xtitle("Week") ytitle("Sex") xlabel(0(2)12) ylabel(0(3)15)

  23. *Spaghetti Plot
  24. spagplot sex week, id(id) nofit by(gender)

  25. *Fit HLMs
  26. xtmixed sex || id:, var

  27. *grand mean center stress
  28. quietly summarize stress
  29. generate stress_c=stress-r(mean)

  30. *stress main-effects model
  31. xtmixed sex stress_c || id:,var

  32. *add gender main effect
  33. xtmixed sex stress_c gender2 || id:, var

  34. *add interaction
  35. xtmixed sex c.stress_c##i.gender2 || id:, var
  36. estimates store mod1
  37. estat ic

  38. *do we need a random effect for stress?
  39. xtmixed sex c.stress_c##i.gender2 || id:stress_c, var cov(un)
  40. estimates store mod2
  41. estat ic

  42. lrtest mod2 mod1

  43. *is there any residual "week" effect?
  44. xtmixed sex c.stress_c##i.gender2 week || id:stress_c, var cov(un)
  45. estat ic

  46. *create residuals,random effects, and fitted values
  47. predict residuals, residuals
  48. predict reffect*, reffects
  49. predict fitted, fitted

  50. *histograms and q-q plots of residuals and random effects
  51. histogram(residuals)
  52. qnorm(residuals)

  53. histogram(reffect1)
  54. qnorm(reffect1)

  55. histogram(reffect2)
  56. qnorm(reffect2)

  57. *scatterplot of residuals against fitted values
  58. twoway scatter resid fitted, jitter(2)

  59. *calculating means of stress and sex within person
  60. *can use these to calculate centered values
  61. by id, sort: egen stressmn=mean(stress)
  62. by id, sort: egen sexmn=mean(sex)



  63. *couple data
  64. clear
  65. insheet using "Atkins 2005 wide w missing.txt"

  66. destring das, replace

  67. *unconditional model
  68. xtmixed das || id: || sex: , var
  69. estimates store model1

  70. *add time and therapy
  71. xtmixed das therapy time || id: || sex: , var
  72. estimates store model2

  73. *add time random-effect at couple-level
  74. xtmixed das therapy time || id:time || sex:, var
  75. estimates store model3

  76. *add time random-effect at individual-level
  77. xtmixed das therapy time || id:time || sex:time, var
  78. estimates store model4

  79. lrtest model3 model2
  80. lrtest model4 model3
复制代码

藤椅
jgchen1966 发表于 2016-5-31 19:43:09

板凳
yyyyyy88 发表于 2016-5-31 19:47:48
谢谢谢谢谢谢

报纸
ynsxx 在职认证  发表于 2016-6-2 21:28:14
try to see

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-27 05:19