predtable([keyword phrases] [,silent:T]) or predtable(Term [,keyword phrases] [,silent:T]), Term a CHARACTER scalar of the form "A.B. ...", where A, B are factors in current GLM model, or term:k, where k is a positive integer, and allowed keyword phrases seest:T, sepred:T, estimate:F, wtdmeans:T or x:values as for glmtable(). |

predtable() computes a table of fitted values (estimated cell expected values) based on the computations of the most recent GLM (generalized linear or linear model) command such as anova() or poisson(). The table has a dimension for each factor in the model, in the order the variables appear in the model. It is an error if there are no factors in the model. See glmtable() for a somewhat more general function. predtable(seest:T) does the same, except the result is a structure with two components, 'estimate' and 'SEest' containing the table of fitted values and their standard errors. predtable(sepred:T) does the same, except the structure result has components 'estimate' and 'SEpred', where SEpred contains standard errors of prediction (usually sqrt(SEest^2 + MSE)) for each cell. You can use both 'sepred:T' and 'seest:T' together, and can suppress the table of estimates with 'estimate:F'. predtable(Term) returns an estimated table of marginal means where the margins are specified by Term. Term must be a quoted string or CHARACTER scalar of the form "Name1.Name2.Name3....", where Name1, Name2, ... are names of factors in the current GLM model. When there are k factor names in Term, the value of predtable() is an array with k dimensions (vector if k = 1, matrix if k = 2), with the dimensions ordered in the same order as in Term, not the order they appear in the model if that is different. predtable(Term, seest:T) does the same, but the result is a structure with components 'estimate' and 'SEest', where SEest contains the standard errors of the estimated marginal means. You cannot use 'sepred:T' with Term when Term specifies a marginal table, that is, Term does not include all factors in the model. predtable(term:k [,seest:T]) is essentially equivalent to predtable(TERMNAMES[k] [,seest:T]), computing the marginal table matching term k in the model. You cannot use predtable(Term [,...]) after anova() with a balanced design unless Term includes all the factors in the model. Examples: Cmd> anova("y=a+b") # two-way ANOVA Model used is y=a+b WARNING: summaries are sequential DF SS MS CONSTANT 1 0.021986 0.021986 a 2 12.082 6.041 b 3 12.419 4.1397 ERROR1 24 39.977 1.6657 Cmd> predtable() # estimates of cell means (1,1) 1.0316 0.23603 -0.43016 -1.3688 (2,1) 0.98354 0.18795 -0.47824 -1.4169 (3,1) 2.1081 1.3125 0.64631 -0.29238 Cmd> predtable(seest:T,sepred:T) #cell mean estimates and SE's component: estimate (1,1) 1.0316 0.23603 -0.43016 -1.3688 (2,1) 0.98354 0.18795 -0.47824 -1.4169 (3,1) 2.1081 1.3125 0.64631 -0.29238 component: SEest [SE of estimated cell mean] (1,1) 1.2906 0.48563 0.58437 0.57713 (2,1) 1.4245 0.57943 0.4888 0.57981 (3,1) 1.4247 0.4894 0.56226 0.66824 component: SEpred [SE of prediction for cell] (1,1) 1.8252 1.379 1.4168 1.4138 (2,1) 1.9222 1.4147 1.3801 1.4149 (3,1) 1.9223 1.3803 1.4078 1.4534 Cmd> predtable(a,seest:T) # marginal mean estimate and SE's component: estimate (1) -0.13284 -0.18092 0.94363 component: SEest (1) 0.44971 0.5415 0.56229 Cmd> predtable(term:2) #second term is a (1) -0.13284 -0.18092 0.94363 predtable(silent:T) and predtable(Term, silent:T) do the same, except that certain advisory messages are suppressed. 'silent:T' can be used with any other keywords. The default value of 'silent' is False unless the value of option' 'warnings' is False. Behavior when there are variates in the model The fitted values are by default computed with each variate set to its unweighted mean value and thus are what are sometimes called the covariate adjusted cell means. predtable(wtdmeans:T [,...]) does the same except it adjusts cell fitted values to the weighted means of the variates. You can use wtdmeans:T only when there are variates and when the previous GLM command used weighted OLS (anova() or manova()). This option would be probably appropriate when the weights were proportional to sample sizes. predtable(x:Vals [,...]), where Vals is a REAL vector with length = the number of variates (non-factors) in the model, does the same computation, except it uses the elements of Vals instead of unweighted or weighted variate means. This option allows you to estimate cell means that are adjusted to any level of the covariates. Use of x:Vals is an error if there are no variates in the current GLM model. predtable() and predtable(Term) are equivalent to glmtable(seest:F) and glmtable(Term, seest:F). Usage of keywords 'seest' and 'sepred' is the same as for glmtable(). For GLM functions involving a binomial response variable (logistic(), probit(), glmfit() with dist:"binomial"), the values computed are the estimated probabilities p of "success" associated with each cell. In this case, you can also use keyword phrase n:N, where N is a REAL variable, to specify the number of trials for each cell. N can be a scalar, a vector whose length matches the size of the table, or a matrix or array whose dimensions match those of the table. The resulting table is a table of N*p. Example: Cmd> logistic("y=a+b",n:100); predtable(n:100) Caution: When the marginal table for any term in the model contains empty cells, especially when a factor is nested in another with different numbers of levels, the estimated means may not be what you want. After fitting a non-linear model by logistic(), probit(), poisson(), or glmfit(), when Term doesn't contain all the factors in the model, predtable(Term) first computes the estimated marginal table in the linear scale (logit, probit, or log) and then transforms it back into the scale of the response. This means that the computed marginal table is not the marginal means of the fitted table. For example, if b is a factor with 3 levels, after logistic("y=a*b", n:40), sum(predtable("a.b"))/3 is not the same as predtable("b"). When keyword phrase coefs:F was an argument on the most recent GLM command, predtable() is not available. See also topics anova(), anovapred(), glmpred(), glmtable(), regpred(), modelinfo(), popmodel(), pushmodel(), 'glm'.

Gary Oehlert 2003-01-15