{"id":366,"date":"2017-05-05T19:51:55","date_gmt":"2017-05-05T19:51:55","guid":{"rendered":"http:\/\/sites.warnercnr.colostate.edu\/gwhite\/?page_id=366"},"modified":"2017-05-06T04:34:36","modified_gmt":"2017-05-06T04:34:36","slug":"design-matrix-basics","status":"publish","type":"page","link":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix-basics\/","title":{"rendered":"Design Matrix Basics"},"content":{"rendered":"<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\"><a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/mark-program-help-file-contents\/\">Contents<\/a> &#8211; <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/mark-program-help-file-index\/\">Index<\/a><\/span><\/p>\n<hr \/>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: medium\"><b>Design Matrix Basics<\/b><\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">Suppose that a single group of animals are being analyzed, with live recaptures and 5 capture occasions (making 4 re-encounter occasions, and hence 4 survival rates and 4 recapture parameters).\u00a0 Suppose that the parameter matrices for each of these <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/real-parameters\/\">real parameters<\/a> are specified as a <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/time-matrix\/\">Time Matrices<\/a>.\u00a0 Thus, the matrix for survival or Phi would be<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 2\u00a0 3\u00a0 4\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0\u00a0\u00a0\u00a0 2\u00a0 3\u00a0 4\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 3\u00a0 4\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">and the matrix for recaptures, or p, would be<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 5\u00a0 6\u00a0 7\u00a0 8\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0\u00a0\u00a0\u00a0 6\u00a0 7\u00a0 8\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 7\u00a0 8\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">If you want to estimate each of these <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/real-parameters\/\">real parameters<\/a>, the Identity matrix would be used for the <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix\/\">design matrix<\/a>, i.e.,<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">Each row corresponds to a <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/real-parameters\/\">real parameter<\/a>, and in this case, each column also corresponds to a <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/beta-parameters\/\">beta parameter<\/a>.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">Another design matrix that would estimate the same <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/aic-aicc-qaic-aicc\/\">AIC<\/a> value for the model, and thus the exact same <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/real-parameters\/\">real parameter<\/a> estimates, but would reparameterize the <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/beta-parameters\/\">beta parameter<\/a> space is<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 1\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 1\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 1\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">This design matrix estimates an intercept term for each <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/real-parameters\/\">real parameter<\/a>, and then an additional time effect for occasions 1, 2, and 3.\u00a0 Note that the intercept corresponds to occasion 4.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">Another example would be to estimate a mean of <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/real-parameters\/\">real parameter<\/a> values across time, and then an offset for each of the 4 occasions.\u00a0 The following matrix does this.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 -1\u00a0 -1\u00a0 -1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 1\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 1\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 1\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 -1\u00a0 -1\u00a0 -1\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">The first column corresponds to the mean Phi value, and columns 2-4 provide the time effects.\u00a0 Likewise, column 5 provides the mean p, and columns 6-8 provide the time effects on p.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">In all the examples shown so far, we have ignored the confounding of Phi(4) and p(5), i.e., only the product Phi(4)p(5) can be estimated.\u00a0 We could eliminate p(5) by changing the parameter matrices, e.g., changing all the occurrences of parameter 8 to parameter 4.\u00a0 However, another approach is to use the design matrix to make parameter 4 and parameter 8 equal, as is done in the following design matrix.\u00a0 I started with an identity design matrix.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0<\/span><br \/>\n<span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">\u00a0 0\u00a0 0\u00a0 0\u00a0 1\u00a0 0\u00a0 0\u00a0 0\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">This design matrix only has 7 columns, but still 8 rows (because there are 8 parameters).\u00a0 Note that column 4 corresponds to both parameter 4 (row 4) and parameter 8 (row 8).\u00a0 Row 4 and row 8 are identical, making parameters 4 and 8 identical.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">More advanced examples of the design matrix are shown in <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix-advanced-applications\/\">Design Matrix Advanced<\/a> and <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix-advanced-applications-2\/\">Design Matrix Advanced 2<\/a>.<\/span><\/p>\n<p><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\">Values in the design matrix should be <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix-scaling-covariates\/\">scaled<\/a> to achieve numerical convergence of the estimates.<\/span><\/p>\n<p><span style=\"font-family: Arial, helvetica, sans-serif;font-size: small\"><a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix-functions\/\">Functions<\/a><\/span><span style=\"color: #0000ff;font-family: Arial, helvetica, sans-serif;font-size: small\"> of the values in the design matrix can also be computed to create interactions.\u00a0 The <a href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/link-functions\/\">link function<\/a> can be used to impose constraints on the range of the real parameters, and even force a set of them to sum to 1, or force a montonic increasing relationship in a set of real parameters.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contents &#8211; Index Design Matrix Basics Suppose that a single group of animals are being analyzed, with live recaptures and 5 capture occasions (making 4 re-encounter occasions, and hence 4 survival rates and 4 recapture parameters).\u00a0 Suppose that the parameter &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/design-matrix-basics\/\"> <span class=\"screen-reader-text\">Design Matrix Basics<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":117,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-366","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/pages\/366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/users\/117"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":5,"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/pages\/366\/revisions"}],"predecessor-version":[{"id":421,"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/pages\/366\/revisions\/421"}],"wp:attachment":[{"href":"https:\/\/sites.warnercnr.colostate.edu\/gwhite\/wp-json\/wp\/v2\/media?parent=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}