哑变量矩阵生成dummy matrix with sas
来源:互联网 发布:mac怎么升级到10.12 编辑:程序博客网 时间:2024/06/05 09:06
FROM:http://support.sas.com/kb/23/217.html
For a specified model, there are several procedures that allow you to save the design matrix to a data set:
- For models using GLM parameterization (also called indicator or dummy coding) of CLASS variables, you can use an ODS OUTPUT statement with PROC GLMMOD to save the design matrix to a data set. Note that modeling procedures such as GLM, MIXED, GLIMMIX and others use GLM parameterization. Specify the model in the MODEL statement and identify any categorical predictors in the CLASS statement. Note that PROC GLMMOD only offers GLM parameterization of CLASS variables. For example, the GLM statements below fit the indicated model and the GLMMOD statements that follow create a data set from the same design matrix that was used in PROC GLM. Use the ODS LISTING statements if you want to suppress display of the GLMMOD output in the Output window.
proc glm data=a; class a b c; model y=a b c a*b; run; ods output designpoints=xmatrix; ods listing close; proc glmmod data=a; class a b c; model y=a b c a*b; run; ods listing;
- For models that use GLM or other parameterizations, you can use the OUTDESIGN= option in PROC GLMSELECT or PROC LOGISTIC. These procedures can create design variables using any of several different parameterizations including GLM, reference, effects, polynomial, and others. Specify the model in the MODEL statement and identify any categorical predictors in the CLASS statement. Use the PARAM= option in the CLASS statement to select the parameterization. Each of the GLMSELECT and LOGISTIC steps below creates a data set containing the same design matrix as produced above by PROC GLMMOD (and as used internally by PROC GLM). Note that the OUTDESIGNONLY option in PROC LOGISTIC suppresses the inclusion of the other variables in the input data set. The SELECTION=NONE option in PROC GLMSELECT requests that the procedure fit the specified model rather than use a model selection method.
proc logistic data=a outdesign=xmatrix outdesignonly; class a b c / param=glm; model y=a b c a*b; run; proc glmselect data=a outdesign=xmatrix; class a b c / param=glm; model y=a b c a*b / selection=none; run;
But you can also use other coding methods. For example, these statements use effects coding for the categorical (CLASS) variables:proc logistic data=a outdesign=xmatrix outdesignonly; class a b c / param=effect; model y=a b c a*b; run;
See the LOGISTIC and GLMSELECT documentation for information about the various coding methods that are available. - For models using GLM, reference, or effects parameterization, you can use PROC TRANSREG. Specify any categorical variables in the CLASS expansion. Use the ZERO= option to select a reference category or, as below, ZERO=NONE to specify GLM parameterization. Specify any continuous predictors, the response, and any other variables that you want transferred to the output data set in the ID statement. For example, the following statements create a data set containing the same design matrix as produced above by PROC GLMMOD (and as used internally by PROC GLM):
proc transreg data=a design; model class(a b c a*b / zero=none); id y; output out=xmatrix; run;
Effects coding can be done as follows:proc transreg data=a design; model class(a b c a*b / effects); id y; output out=xmatrix; run;
Note that PROC TRANSREG automatically creates a macro variable, &_trgind, which contains a list of variable names that it creates. You can use this macro variable in subsequent procedures to refer to the full model.
- 哑变量矩阵生成dummy matrix with sas
- SAS中生成哑变量的一段宏代码
- Dummy variable (变量dummy化)
- R语言 | 多元回归分析中的对照编码(contrast coding) | 第一节 dummy variable(哑变量) 和 dummy coding
- R语言分类变量转换为哑变量(dummy vairable)
- LeetCode Spiral Matrix II (生成螺旋矩阵)
- leetcode59-Spiral Matrix II(生成蛇形矩阵)
- dummy
- dummy
- Python中的虚拟变量(dummy variables)
- sas/iml矩阵算术
- 矩阵Matrix
- Matrix 矩阵
- 矩阵(Matrix)
- Matrix矩阵
- 矩阵(Matrix)
- SAS中文变量
- 蛇形螺旋矩阵的生成和遍历 Spiral Matrix
- C
- 递归分治算法之二分搜索(Java版本)
- 递归分治算法之棋盘分割问题(Java版本)
- 递归分治算法之全排列问题(Java版本)
- HOJ 1370 Candy
- 哑变量矩阵生成dummy matrix with sas
- 递归分治算法之整数划分问题(Java版本)
- 百度开发者中心
- sql 语句对时间操作的总结
- 递归分治算法之N皇后问题(Java版本)
- 安装snecha touch 2的sdk工具
- 递归分治算法之矩阵链问题(Java版本)
- at oException:racle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1401)
- 递归分治算法之合并排序(Java版本)