-
Notifications
You must be signed in to change notification settings - Fork 1
/
R-bios6643-L09sas.Rmd
executable file
·105 lines (71 loc) · 2.93 KB
/
R-bios6643-L09sas.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
title: "BIOS6643. L09 Specifying both G and R"
cheauthor: "EJC"
-- date: ""
header-includes:
- \usepackage{amsmath}
- \usepackage{float}
output: pdf_document
---
\newcommand{\bi}{\begin{itemize}}
\newcommand{\ei}{\end{itemize}}
\newcommand{\itt}{\item}
```{r setup, include=FALSE, echo=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
<!-- -->
```{r installp, echo = FALSE, eval=T, include=F}
library(SASmarkdown)
```
```{r include=FALSE}
# set up the options so that knit knows where you SAS executable is
# set the line size to be easily readable on letter size paper, portrait
# and set the knitr options using opts_chunk$set().
sasopts <- "-nosplash -linesize 75"
saspath <- "C:/Program Files/SASHome/SASFoundation/9.4/sas.exe"
## those two parts should have been universal
## just copy and paste into your Rmarkdown files
knitr::opts_chunk$set(engine = "sas",
engine.path = saspath,
engine.opts = sasopts,
comment = NA)
```
The RANDOM statement may be used with TYPE=UN
and possibly the GROUP= option to specify the among-individual
covariance matrix G (possibly different by levels of GROUP).
The REPEATED statement may be used with various TYPE= specifications,
and possibly the GROUP = option with SUBJECT = to
specify the within-individual covariance matrix R_i.
```{r engine="sas", engine.path="C:/Program Files/SASHome/SASFoundation/9.4/sas.exe", engine.opts="-nosplash -linesize 75", collectcode=TRUE}
proc import DATAFILE='C:\Users\juarezce\OneDrive - The University of Colorado Denver\BIOS6643\BIOS6643_Notes\data\dental.csv'
replace out=dental0 dbms=csv; run;
data dental;
set dental0;
time=age;
run;
proc print data=dental(obs=2);run;
title '(a) DIAGONAL WITHIN-CHILD COVARIANCE MATRIX R_i';
title2 'WITH CONSTANT VARIANCE SAME FOR EACH GENDER';
title3 'SAME G MATRIX FOR BOTH GENDERS';
proc mixed method=ml data=dental;
class gender id;
model distance = gender gender*age / noint solution;
random intercept age / type=un subject=id g gcorr v vcorr;
run;
/******************************************************************
MODEL (b)
Fit the same model as (a) but with a separate diagonal Ri matrix for
each gender. Thus, there are 2 separate variances sigma^2_(G and B)
specified using GROUP=GENDER in the REPEATED statement
*******************************************************************/
title '(b) DIAGONAL WITHIN-CHILD COVARIANCE MATRIX R_i';
title2 'WITH SEPARATE CONSTANT VARIANCE FOR EACH GENDER';
title3 'SAME G MATRIX FOR BOTH GENDERS';
proc mixed method=ml data=dental;
class id gender;
model distance = gender gender*age / noint solution;
repeated / group=gender subject=id r=1,4 rcorr=1,4;
random intercept age / type=un subject=id g gcorr v=1,4 vcorr=1,4;
run;
/* */
```