How to write a code for multiple linear regression looking at predictors sex, age, weight for an outcome

huangapple go评论97阅读模式
英文:

How to write a code for multiple linear regression looking at predictors sex, age, weight for an outcome

问题

我对统计学非常陌生,只学过一门课程(但没有涵盖这个内容),所以我有点超出我的专业领域。提前感谢你提供的任何帮助。

我正在使用SAS工作,尝试编写一段代码,以确定这些预测变量中的哪些(如果有的话)会影响我的"value"结果。

关于我的数据的详细信息:基本上有4个组,年轻女性成年人、老年女性成年人、年轻男性成年人、老年男性成年人。我为每个组记录了一个值,但想要连续分析这些数据,而不是按组进行,因为每个组的年龄值范围不同。到目前为止,我的数据(以及我尝试但失败的代码)看起来像这样:

  1. /*测试数据*/
  2. Data;
  3. input Sex$ Age Value;
  4. cards;
  5. M 13 1
  6. M 3 0.5
  7. F 2 0.6
  8. M 3 0.5
  9. M 3 0.5
  10. M 3 0.5
  11. F 1 0.6
  12. F 11 1.2
  13. F 2 0.6
  14. M 3 0.5
  15. M 13 1
  16. F 2 0.6
  17. F 3 0.6
  18. F 3 0.6
  19. M 9 1
  20. M 1 0.5
  21. M 9 1
  22. M 9 1
  23. F 13 1.2
  24. M 11 1
  25. F 11 1.2
  26. M 11 1
  27. M 3 0.5
  28. F 3 0.6
  29. M 3 0.5
  30. M 1 0.5
  31. M 16 1
  32. M 11 1
  33. M 3 0.5
  34. M 1 0.5
  35. M 2 0.5
  36. F 9 1.2
  37. F 9 1.2
  38. M 3 0.5
  39. F 2 0.6
  40. F 12 1.2
  41. F 9 1.2
  42. ;
  43. run;
  44. proc reg;
  45. model Value= Age Sex;
  46. run;
  47. proc reg;
  48. model Value= Age;
  49. run;
  50. proc reg;
  51. model Value= Sex;
  52. run;
  53. Proc reg;
  54. model Value= Age Sex / selection= stepwise slentry=0.05;
  55. run;
  56. proc corr;
  57. var Sex Age Value;
  58. run;

我甚至还没有设法添加体重预测变量,因为我不确定如何添加它。我的代码也不喜欢有性别(Sex)这个变量在那里。

我真的只需要弄清楚年龄、性别或体重是否会影响我的"value"。提前感谢!

英文:

I am very new to stats and have only taken one course so far (which did not cover this) so I am a little out of my wheelhouse. Thank you in advance for any help you can give.

I am working in SAS and am trying to figure out how to write a code where I can determine which, if any, of these predictors affect my outcome "value".

Details on my data: 4 groups basically, young female adults, senior female adults, young male adults, senior male adults. I have recorded a value for each group, but want to analyse this data continously rather than by group since each group ranges in age values. So far my data (and code that I have tried, and failed) looks something like this:

  1. /*TestData*/
  2. Data;
  3. input Sex$ Age Value;
  4. cards;
  5. M 13 1
  6. M 3 0.5
  7. F 2 0.6
  8. M 3 0.5
  9. M 3 0.5
  10. M 3 0.5
  11. F 1 0.6
  12. F 11 1.2
  13. F 2 0.6
  14. M 3 0.5
  15. M 13 1
  16. F 2 0.6
  17. F 3 0.6
  18. F 3 0.6
  19. M 9 1
  20. M 1 0.5
  21. M 9 1
  22. M 9 1
  23. F 13 1.2
  24. M 11 1
  25. F 11 1.2
  26. M 11 1
  27. M 3 0.5
  28. F 3 0.6
  29. M 3 0.5
  30. M 1 0.5
  31. M 16 1
  32. M 11 1
  33. M 3 0.5
  34. M 1 0.5
  35. M 2 0.5
  36. F 9 1.2
  37. F 9 1.2
  38. M 3 0.5
  39. F 2 0.6
  40. F 12 1.2
  41. F 9 1.2
  42. ;
  43. run;
  44. proc reg;
  45. model Value= Age Sex;
  46. run;
  47. proc reg;
  48. model Value= Age;
  49. run;
  50. proc reg;
  51. model Value= Sex;
  52. run;
  53. Proc reg;
  54. model Value= Age Sex / selection= stepwise slentry=0.05;
  55. run;
  56. proc corr;
  57. var Sex Age Value;
  58. run;

I haven't even managed to put the weight predictor in there because I'm not sure how to add it. My code also does not like Sex being there.

I really just need to figure out if age, sex, or weight will affect my "value". Thank you in advance!

答案1

得分: 0

当然,您在性别方面遇到了问题:它是一个分类变量,不是数值变量,因此不适合使用 proc reg。您所需的是其中之一的混合模型

尝试这样做:

  1. proc mixed;
  2. class sex;
  3. model Value = Age Sex;
  4. run;
英文:

Of course, you have troubles with sex: it is a class variable, not a numeric one, so not suited for proc reg. What you need, is one of the Mixed Models

Try this

  1. proc mixed;
  2. class sex;
  3. model Value = Age Sex;
  4. run;

huangapple
  • 本文由 发表于 2023年7月7日 07:58:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76633166.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定