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

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

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

问题

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

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

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

/*测试数据*/
Data;
input Sex$ Age Value;
cards;
M	13	1
M	3	0.5
F	2	0.6
M	3	0.5
M	3	0.5
M	3	0.5
F	1	0.6
F	11	1.2
F	2	0.6
M	3	0.5
M	13	1
F	2	0.6
F	3	0.6
F	3	0.6
M	9	1
M	1	0.5
M	9	1
M	9	1
F	13	1.2
M	11	1
F	11	1.2
M	11	1
M	3	0.5
F	3	0.6
M	3	0.5
M	1	0.5
M	16	1
M	11	1
M	3	0.5
M	1	0.5
M	2	0.5
F	9	1.2
F	9	1.2
M	3	0.5
F	2	0.6
F	12	1.2
F	9	1.2
;
run;

proc reg;
model Value= Age Sex;
run;

proc reg;
model Value= Age;
run;

proc reg;
model Value= Sex;
run;

Proc reg;
model Value= Age Sex / selection= stepwise slentry=0.05;
run;

proc corr;
var Sex Age Value;
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:

/*TestData*/
Data;
input Sex$ Age Value;
cards;
M	13	1
M	3	0.5
F	2	0.6
M	3	0.5
M	3	0.5
M	3	0.5
F	1	0.6
F	11	1.2
F	2	0.6
M	3	0.5
M	13	1
F	2	0.6
F	3	0.6
F	3	0.6
M	9	1
M	1	0.5
M	9	1
M	9	1
F	13	1.2
M	11	1
F	11	1.2
M	11	1
M	3	0.5
F	3	0.6
M	3	0.5
M	1	0.5
M	16	1
M	11	1
M	3	0.5
M	1	0.5
M	2	0.5
F	9	1.2
F	9	1.2
M	3	0.5
F	2	0.6
F	12	1.2
F	9	1.2


;
run;
proc reg;
model Value= Age Sex;
run;
proc reg;
model Value= Age;
run;
proc reg;
model Value= Sex;
run;
Proc reg;
model Value= Age Sex / selection= stepwise slentry=0.05;
run;
proc corr;
var Sex Age Value;
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。您所需的是其中之一的混合模型

尝试这样做:

proc mixed;
  class sex;
  model Value = Age Sex;
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

proc mixed;
  class sex;
  model Value = Age Sex;
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:

确定