|
74 | 74 | "\n",
|
75 | 75 | "# Extras\n",
|
76 | 76 | "\n",
|
77 |
| - "## Extracting summary statistics from a model fit in R\n", |
| 77 | + "## Extracting Summary Statistics From a Model Fit in R\n", |
78 | 78 | "\n",
|
79 |
| - "If you are new to R, here we will just run through some details on the type of objects these data are stored in and how to access specific elements. This can be helpful for writing automated analysis scripts. Due to the need to contain different types of data in different formats and structures, the output of the regression model fit is stored in a bespoke object, with slots for the the different parts of the output. These slots are named and can be assessed using the `$`. For example to extract just the table of estimated regression coefficients, which are named `coefficients` we use the following command: \n" |
| 79 | + "If you are new to R, here we will just run through some details on the type of objects these data are stored in and how to access specific elements. This can be helpful for writing automated analysis scripts. Due to the need to contain different types of data in different formats and structures, the output of the regression model fit is stored in a bespoke object, with slots for the different parts of the output. These slots are named and can be assessed using the `$`. For example, to extract just the table of estimated regression coefficients which are named `coefficients`, we use the following command: \n" |
80 | 80 | ]
|
81 | 81 | },
|
82 | 82 | {
|
|
135 | 135 | "id": "32a4c285-faf9-4068-bc1c-d09afee71792",
|
136 | 136 | "metadata": {},
|
137 | 137 | "source": [
|
138 |
| - "The output of the command tells us it is stored in a matrix, which is a data-type in R, where you have rows and columns. A similar data-type is called a data.frame. The difference between these two data-types is that matrices can only contain one data type, which we can determine with the function `mode()`. Here it contains exclusively numeric values. In constrast, in a data frame each column can be a different data type. Our demoDat data is stored in a data.frame and the output of the `str()` function, tells us the data type assigned to each column. \n", |
| 138 | + "The output of the command tells us it is stored in a matrix, which is a data-type in R, where you have rows and columns. A similar data-type is called a data.frame. The difference between these two data-types is that matrices can only contain one data type, which we can determine with the function `mode()`. Here it contains exclusively numeric values. In contrast, in a data frame each column can be a different data type. Our demoDat data is stored in a data.frame and the output of the `str()` function, tells us the data type assigned to each column. \n", |
139 | 139 | "\n",
|
140 | 140 | "Let's say we wanted to extract a single value from this matrix, there are a number of commands we can use. For example, let's extract the p-value for the age regression slope parameter using the slicing function `[`.\n",
|
141 | 141 | "\n",
|
|
325 | 325 | "id": "3ae53dea-1a32-437d-a137-b460ef31b27f",
|
326 | 326 | "metadata": {},
|
327 | 327 | "source": [
|
328 |
| - "In the `summary(model)` output we can see at the bottom that the results of testing the full model with an F-test. If we want to see the full table of sums of squares statistics we can use the `anova()` function on our fitted regression model.\n", |
| 328 | + "In the `summary(model)` output, we can see at the bottom the results of testing the full model with an F-test. If we want to see the full table of sums of squares statistics, we can use the `anova()` function on our fitted regression model.\n", |
329 | 329 | "\n",
|
330 |
| - "Comparing this table with the coefficients table, we can see that the p-value from the t-test of the age regression parameter and the F-test for the full model are identical. This is not a coincidence and is always true for the specific case of simple linear regerssion.\n", |
| 330 | + "Comparing this table with the coefficients table, we can see that the p-value from the t-test of the age regression parameter and the F-test for the full model are identical. This is not a coincidence and is always true for the specific case of simple linear regression.\n", |
331 | 331 | "\n",
|
332 | 332 | "### Extracting Variance Explained Statistics\n",
|
333 | 333 | "\n",
|
|
0 commit comments