modelvars(varList [,Model]), varList a vector of integers >= 0, Model a CHARACTER scalar modelvars(y:T or x:T or variates:T or factors:T or all:T [, Model]) modelvars(nx:T or nvariates:T or nfactors:T or hasconst:T [, Model]) |

modelvars(VarList,Model), where VarList is a vector of non-negative integers, say vector(i1,i2,i3,...), returns a vector or matrix whose columns are the variables in the model specified by the scalar CHARACTER variable or quoted string Model. Variable 0 is the dependent variable (the variable before '=' in Model) and, if i > 0, variable i is the i-th variate or factor appearing on the right hand side of Model (after '='). See topic 'models' for information on specifying Model. modelvars(y:T,Model) returns a vector or matrix containing the dependent variable of Model. This usage yields the same result as modelvars(0, Model). modelvars(x:T,Model) returns a vector or matrix containing the independent variates and factors of on the right hand side of Model. This yields the same as modelvars(run(nv), Model), where nv is the number of variates and factors. When there are no variates and factors ("y=1"), NULL is returned. See topic 'NULL'. See keyword 'nx' below for determining the total number of variates and factors. modelvars(factors:T,Model) returns a vector or matrix containing the factors on the right hand side of Model. When there are no factors in the model, NULL is returned. See keyword 'nfactors' below for determining the total number of factors. modelvars(variates:T,Model) returns a vector or matrix containing the variates on the right hand side of Model. When there are no variates in the model, NULL is returned. See keyword 'nvariates' below for determining the total number of variates. modelvars(all:T,Model) returns a matrix containing the dependent variable followed by the independent variates and factors of Model. Equivalent to this is modelvars(run(0,nv),Model). When Model is omitted (modelvars(VarList) or modelvars(keyword:T)), variables are taken from internal copies of the variables in the current active model. This allows retrieval of the dependent variable and/or model variables even if they were temporary variables (their names started with '@'). When there is no active model but variable STRMODEL exists, modelvars(keyword:T) and modelvars(VarList) are equivalent to modelvars(keyword:T,STRMODEL) and modelvars(VarList,STRMODEL). Here keyword is one of 'x', 'y', 'factors', 'variates', or 'all'. Examples: modelvars(vector(1,2,0),"y=x+a") is equivalent to hconcat(x,a,y) modelvars(x:T,"y=x+a+a.x") is equivalent to hconcat(x,a) modelvars(all:T,"y=x1+x2") is equivalent to hconcat(y,x1,x2) Note: Any variables that are factors are returned unchanged. This is very different from xvariables(), which computes dummy X-variables associated with a factor. Counting Factors and Variables You can also use modelvars() to determine how many factors and variates there are in a model or to check whether the constant term is in the model. This can be useful in a macro using the results of a GLM command to do further analyses. modelvars(nx:T [,Model]) returns the number of independent variates and factors on the right hand side of Model, that is, what would be computed by ncols(modelvars(x:T [,Model])). When there are no variates and factors ("y=1"), 0 is returned. modelvars(nfactors:T [,Model]) returns the number of factors on the right hand side of Model, that is, what would be computed by ncols(modelvars(factors:T, [,Model])). When there are no factors 0 is returned. modelvars(nvariates:T [,Model]) returns the number of variates on the right hand side of Model, that is, what would be computed by ncols(modelvars(variates:T [,Model])). When there are no variates 0 is returned. modelvars(hasconst:T [,Model]) is True if and only if the constant term is in the model. Examples: modelvars(nfactors:T,"y=x+a+b+a.x") returns 2 modelvars(nvariates:T,"y=x+a+b+a.x") returns 1 modelvars(nx:T,"y=x+a+b+a.x") returns 3 modelvars(hasconst:T, "y=x") returns True modelvars(hasconst:T, "y=x-1") returns False See also topics 'models', varnames(), xvariables().

Gary Oehlert 2003-01-15