Last active
December 11, 2015 07:19
-
-
Save ramnathv/4565745 to your computer and use it in GitHub Desktop.
Brew with knitR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Preprocess template using brew and then run knit | |
| brew_knit <- function(template, ...){ | |
| input = gsub(".Rnwe", '.Rnw', template) | |
| brew(template, input) | |
| knit(input, ...) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \section{Analysis of Hip Bone Mineral Density} | |
| \subsection{26w BMD and Baseline Predictors} | |
| In this section I model 26w interpolated BMD using baseline BMD (all four measures, not just the target measure), baseline weight, age,sex, race, \$t\$-score stratum, and treatment. I first fit a saturatedmodel with respect to all of the continuous predictors, using restricted cubic splines with 5 knots, then potentially use partial \$\chi^2\$ (blinded to nonlinearity components) to reassign degrees of freedom. | |
| << hip-sat26,results="asis", eval = F>>= | |
| f <- ols(hip26 ~ sex*rcs(hip0,5) + | |
| rcs(lumbar0,5) + rcs(femur0,5) + | |
| rcs(forearm0,5) + sex*rcs(wt0, 5) + trtp + | |
| rcs(age, 5) + race + sex + blppar + bltscgrp, data=d) | |
| print(f, coefs = FALSE, latex = TRUE) | |
| lan(f) | |
| @ | |
| The global test for nonlinearity is nowhere close to being significant, so all nonlinear effects will be dropped. | |
| \section{Analysis of Lumbar Bone Mineral Density} | |
| \subsection{26w BMD and Baseline Predictors} | |
| In this section I model 26w interpolated BMD using baseline BMD (all four measures, not just the target measure), baseline weight, age,sex, race, \$t\$-score stratum, and treatment. I first fit a saturatedmodel with respect to all of the continuous predictors, using restricted cubic splines with 5 knots, then potentially use partial \$\chi^2\$ (blinded to nonlinearity components) to reassign degrees of freedom. | |
| << lumbar-sat26,results="asis", eval = F>>= | |
| f <- ols(lumbar26 ~ sex*rcs(lumbar0,5) + | |
| rcs(hip0,5) + rcs(femur0,5) + | |
| rcs(forearm0,5) + sex*rcs(wt0, 5) + trtp + | |
| rcs(age, 5) + race + sex + blppar + bltscgrp, data=d) | |
| print(f, coefs = FALSE, latex = TRUE) | |
| lan(f) | |
| @ | |
| The global test for nonlinearity is nowhere close to being significant, so all nonlinear effects will be dropped. | |
| \section{Analysis of Femur Bone Mineral Density} | |
| \subsection{26w BMD and Baseline Predictors} | |
| In this section I model 26w interpolated BMD using baseline BMD (all four measures, not just the target measure), baseline weight, age,sex, race, \$t\$-score stratum, and treatment. I first fit a saturatedmodel with respect to all of the continuous predictors, using restricted cubic splines with 5 knots, then potentially use partial \$\chi^2\$ (blinded to nonlinearity components) to reassign degrees of freedom. | |
| << femur-sat26,results="asis", eval = F>>= | |
| f <- ols(femur26 ~ sex*rcs(femur0,5) + | |
| rcs(hip0,5) + rcs(lumbar0,5) + | |
| rcs(forearm0,5) + sex*rcs(wt0, 5) + trtp + | |
| rcs(age, 5) + race + sex + blppar + bltscgrp, data=d) | |
| print(f, coefs = FALSE, latex = TRUE) | |
| lan(f) | |
| @ | |
| The global test for nonlinearity is nowhere close to being significant, so all nonlinear effects will be dropped. | |
| \section{Analysis of Forearm Bone Mineral Density} | |
| \subsection{26w BMD and Baseline Predictors} | |
| In this section I model 26w interpolated BMD using baseline BMD (all four measures, not just the target measure), baseline weight, age,sex, race, \$t\$-score stratum, and treatment. I first fit a saturatedmodel with respect to all of the continuous predictors, using restricted cubic splines with 5 knots, then potentially use partial \$\chi^2\$ (blinded to nonlinearity components) to reassign degrees of freedom. | |
| << forearm-sat26,results="asis", eval = F>>= | |
| f <- ols(forearm26 ~ sex*rcs(forearm0,5) + | |
| rcs(hip0,5) + rcs(lumbar0,5) + | |
| rcs(femur0,5) + sex*rcs(wt0, 5) + trtp + | |
| rcs(age, 5) + race + sex + blppar + bltscgrp, data=d) | |
| print(f, coefs = FALSE, latex = TRUE) | |
| lan(f) | |
| @ | |
| The global test for nonlinearity is nowhere close to being significant, so all nonlinear effects will be dropped. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% v = c("hip", "lumbar", "femur", "forearm") -%> | |
| <% oth1 = c("lumbar", "hip", "hip", "hip") -%> | |
| <% oth2 = c("femur", "femur", "lumbar", "lumbar") -%> | |
| <% oth3 = c("forearm", "forearm", "forearm", "femur") -%> | |
| <% for (i in 1:4) { -%> | |
| <% title = gsub('^([a-z])', '\\U\\1', v[i], perl = T) %> | |
| \section{Analysis of <%= title %> Bone Mineral Density} | |
| \subsection{26w BMD and Baseline Predictors} | |
| In this section I model 26w interpolated BMD using baseline BMD (all four measures, not just the target measure), baseline weight, age,sex, race, \$t\$-score stratum, and treatment. I first fit a saturatedmodel with respect to all of the continuous predictors, using restricted cubic splines with 5 knots, then potentially use partial \$\chi^2\$ (blinded to nonlinearity components) to reassign degrees of freedom. | |
| << <%= v[i] %>-sat26,results="asis", eval = F>>= | |
| f <- ols(<%= v[i] %>26 ~ sex*rcs(<%= v[i] %>0,5) + | |
| rcs(<%= oth1[i] %>0,5) + rcs(<%= oth2[i] %>0,5) + | |
| rcs(<%= oth3[i] %>0,5) + sex*rcs(wt0, 5) + trtp + | |
| rcs(age, 5) + race + sex + blppar + bltscgrp, data=d) | |
| print(f, coefs = FALSE, latex = TRUE) | |
| lan(f) | |
| @ | |
| The global test for nonlinearity is nowhere close to being significant, so all nonlinear effects will be dropped. | |
| <% } %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment