r - what is a model matrix / design matrix -


i stumbeled upon stats::model.matrix function in r. in description sais create design matrix. gives me weired number of rows, not correspend neither number of observations in data, nor number of parameters in model.

what design matrix / model matrix?

here how used it:

m03b <- glmer(apms ~ prepost + gf + eyefrf + (1|content) + (eyefrf|id),    data=mlmdata, family=binomial("logit")) x <- model.matrix(m03b) 

it gives me 2895x4 matrix. id has 105 levels , content 28, number of rows not make sense me. maybe missing values issue?

in regression model, written in matrix-vector form as

y = x * b + e, 

the matrix x design matrix, while y vector of observations on dependent variable, b vector of response coefficients (one each explanatory variable) , e vector containing values of model's error term various observations. in design matrix, each column vector of observations on 1 of explanatory variables.

thus, size of x must such n x m matrix , b m x p matrix, allowing product xb defined if number of columns in x equal number of rows in b, in case m.

given 2895x4 dim x, should able confirm b, m03b, has 4 response coefficients.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -