在 sas proc 混合中指定具有交叉和嵌套因子的模型
Specify a model with crossed and nested factors in sas proc mixed
小问题
如何在 proc mixed
中编写 model
语句来研究一个因素与嵌套在第三个因素中的第二个因素之间的相互作用?
- 所以
factor_1
独立于其他(就像年份独立于位置)
- 但
factor_2
是 factor_3
的细分(就像省是州的细分一样)。
我希望它是 model factor_1 * factor_2(factor_3);
但这行不通。
真正的问题和背景
我正在尝试建模 this Crossed - Nested Design example from an Analysis of Variance and Design of Experiments course of Eberly College of Science using the techniques from this Nested Treatment Design example and the instructions given in this video。
正在使用
加载我的数据
data PRODUCTION;
infile datalines dsd dlm='09'x;
array _M {6} _temporary_ (1 1 2 2 3 3);
array _C {6} _temporary_ (1 2 1 2 1 2);
array _O {6} _M1_C1 _M1_C2 _M2_C1 _M2_C2 _M3_C1 _M3_C2;
input Power _M1_C1 _M1_C2 _M2_C1 _M2_C2 _M3_C1 _M3_C2;
do _i = 1 to 6;
Machine = _M(_i);
Config = _C(_i);
Out_put = _O(_i);
output;
end;
drop _:;
datalines;
1 10.2 4.2 12.0 4.1 13.1 4.1
1 13.1 5.2 13.5 6.1 12.9 6.1
2 16.2 8.0 12.6 4.0 12.9 2.2
2 16.9 9.1 14.6 6.1 13.7 3.8
3 13.8 2.5 12.9 3.7 11.8 2.7
3 14.9 4.4 15.0 5.0 13.5 4.1
;run;
运行这个分析
proc mixed data=PRODUCTION
method=type3
plots=all;
class Machine Config Power;
model Out_put =
Machine
Config(Machine)
Power
Machine*Power
Config(Machine)*Power;
store PRODUCTION;
run;
proc plm restore=PRODUCTION;
lsmeans Machine Config(Machine) Power
Power*Machine Power*Config(Machine)
/ adjust=tukey plot=meanplot cl lines;
ods exclude diffplot;
run;
我在日志中得到了这个
54 model Out_put =
55 Machine
56 Config(Machine)
2 The SAS System 08:31 Sunday, January 3, 2021
57 Power
58 Machine*Power
59 Config(Machine)*Power;
_
22
ERROR 22-322: Expecting a name.
60 store PRODUCTION;
ERROR: Variable NAME not found.
明智地分配法律
Config(Machine)*Power
可能是其中之一(其中 model
语句确实接受 )
Config(Machine*Power)
Power*Config(Machine)
MODEL
语句根据代数展开解析复杂的效果规范。
用户指南的 SAS/STAT 部分 "Specification of Effects" 嵌套效果的要点是
- Nested effects are specified by following a main effect or crossed effect with a classification variable or list of classification variables enclosed in parentheses. The main effect or crossed effect is nested within the effects listed in parentheses:
B(A) C(B*A) D*E(C*B*A)
. In this example, B(A)
is read "B nested within A."
NOTE: My bold. For me, things inside () are often concepted as the nested thing (deeper tier) within a hierarchy. So I might struggle here a little if I indeed need to mentally crossover concepts.
SAS/STAT 用户指南部分 "Parameterization of PROC GLM Models" 指出
The GLM procedure constructs a linear model according to the specifications in the MODEL statement. Each effect generates one or more columns in a design matrix . This section shows precisely how is built.
并讨论创建的流程和设计矩阵。
小问题
如何在 proc mixed
中编写 model
语句来研究一个因素与嵌套在第三个因素中的第二个因素之间的相互作用?
- 所以
factor_1
独立于其他(就像年份独立于位置) - 但
factor_2
是factor_3
的细分(就像省是州的细分一样)。
我希望它是 model factor_1 * factor_2(factor_3);
但这行不通。
真正的问题和背景
我正在尝试建模 this Crossed - Nested Design example from an Analysis of Variance and Design of Experiments course of Eberly College of Science using the techniques from this Nested Treatment Design example and the instructions given in this video。
正在使用
加载我的数据data PRODUCTION;
infile datalines dsd dlm='09'x;
array _M {6} _temporary_ (1 1 2 2 3 3);
array _C {6} _temporary_ (1 2 1 2 1 2);
array _O {6} _M1_C1 _M1_C2 _M2_C1 _M2_C2 _M3_C1 _M3_C2;
input Power _M1_C1 _M1_C2 _M2_C1 _M2_C2 _M3_C1 _M3_C2;
do _i = 1 to 6;
Machine = _M(_i);
Config = _C(_i);
Out_put = _O(_i);
output;
end;
drop _:;
datalines;
1 10.2 4.2 12.0 4.1 13.1 4.1
1 13.1 5.2 13.5 6.1 12.9 6.1
2 16.2 8.0 12.6 4.0 12.9 2.2
2 16.9 9.1 14.6 6.1 13.7 3.8
3 13.8 2.5 12.9 3.7 11.8 2.7
3 14.9 4.4 15.0 5.0 13.5 4.1
;run;
运行这个分析
proc mixed data=PRODUCTION
method=type3
plots=all;
class Machine Config Power;
model Out_put =
Machine
Config(Machine)
Power
Machine*Power
Config(Machine)*Power;
store PRODUCTION;
run;
proc plm restore=PRODUCTION;
lsmeans Machine Config(Machine) Power
Power*Machine Power*Config(Machine)
/ adjust=tukey plot=meanplot cl lines;
ods exclude diffplot;
run;
我在日志中得到了这个
54 model Out_put =
55 Machine
56 Config(Machine)
2 The SAS System 08:31 Sunday, January 3, 2021
57 Power
58 Machine*Power
59 Config(Machine)*Power;
_
22
ERROR 22-322: Expecting a name.
60 store PRODUCTION;
ERROR: Variable NAME not found.
明智地分配法律
Config(Machine)*Power
可能是其中之一(其中 model
语句确实接受 )
Config(Machine*Power)
Power*Config(Machine)
MODEL
语句根据代数展开解析复杂的效果规范。
用户指南的 SAS/STAT 部分 "Specification of Effects" 嵌套效果的要点是
- Nested effects are specified by following a main effect or crossed effect with a classification variable or list of classification variables enclosed in parentheses. The main effect or crossed effect is nested within the effects listed in parentheses:
B(A) C(B*A) D*E(C*B*A)
. In this example,B(A)
is read "B nested within A."
NOTE: My bold. For me, things inside () are often concepted as the nested thing (deeper tier) within a hierarchy. So I might struggle here a little if I indeed need to mentally crossover concepts.
SAS/STAT 用户指南部分 "Parameterization of PROC GLM Models" 指出
The GLM procedure constructs a linear model according to the specifications in the MODEL statement. Each effect generates one or more columns in a design matrix . This section shows precisely how is built.
并讨论创建的流程和设计矩阵。