Sas code for cubic model selected

PROC MIXED; CLASS type pat;

MODEL virus=age type month month2 month3/ S DDFM=KR; RANDOM INT month month2/ SUB=pat TYPE=UN;

Iteration History

Iteration

Evaluations

-2 Res

Log Like

Criterion

0

1

2062.

27052887

1

2

1601.

35658286

0.00904154

2

1

1598.

68139127

0.00345910

3

1

1597.

70596681

0.00073106

4

1

1597.

51448892

0.00004682

5

1

1597.

50321956

0.00000027

6

1

1597.

50315684

0.00000000

Convergence criteria met.

Covariance Parameter Estimates

Cov

Parm

Subject

Estimate

UN(1

,1)

pat

0.5960

UN(2

,1)

pat

-0.04470

UN(2

,2)

pat

0.02356

UN(3

,1)

pat

0.001705

UN(3

,2)

pat

-0.00071

UN(3

,3)

pat

0.000022

Residual

0.5258

UN(1,1), UN(2,2) and UN(3,3) are the variance component estimates for the patient, patient-time and patient-time2 random coefficients. UN(2,1), UN(3,1) and UN(3,2) are the covariances between the random coefficients. Note that the relative sizes of the patient-time and patient-time2 variance components cannot be compared directly with other variance components because they involve time.

Effect

Fit Statistics

-2 Res Log Likelihood 1597.5

AIC (smaller is better) 1611.5

AICC (smaller is better) 1611.7

BIC (smaller is better) 1624.0

Null Model Likelihood Ratio Test DF Chi-Square Pr > ChiSq

Solution for Fixed Effects type

Estimate

Standard Error

Effect type

Estimate

Intercept

3.7385

0.2506

50

14.92

<

age

-0.04

852

0.03947

43.3

-1.23

0

type

AL

-0.06019

0.2553

43

-0.24

0

type

ST

0

month

-0.1182

0.03635

39.6

-3.25

0

month2

0.006543

0.002553

123

2.56

0

month3

-0.00011

0.000064

79.5

-1.69

0

Type 3

Tests of Fixed

Effects

Num

Den

Effect

DF

DF F Value

Pr > F

age

1

43.3

1.51

0.2255

type

1

43

0.06

0.8147

month

1

39.6 10.58

0.0023

month2

1

123

6.57

0.0116

month3

1

79.5

2.84

0.0959

sas code for other models tested (without output)

PROC MIXED; CLASS type pat; MODEL virus=age type month/ S DDFM=KR; RANDOM int month/ SUB=pat TYPE=UN; PROC MIXED; CLASS type pat;

MODEL virus=age type month month2/ S DDFM=KR; RANDOM int month month2/ SUB=pat TYPE=UN;

PROC MIXED; CLASS type pat;

MODEL virus=age type month month2 month3 type*month type*month2 type*month3/ S DDFM=KR;

RANDOM int month month2/ SUB=pat TYPE=UN; PROC MIXED; CLASS type pat;

MODEL virus=age type month month2 month3 age*month age*month2 age*month3/ S DDFM=KR;

RANDOM int month month2/ SUB=pat TYPE=UN;

Model checking using Model 3

PROC MIXED; CLASS type pat;

MODEL virus=age type month month2 month3/ S DDFM=KR

OUTP=work.resid OUTPM=work.predm;

RANDOM int month month2/ SUB=pat TYPE=UN SOLUTION;

ID pat month;

ODS OUTPUT SOLUTIONR=solut;

PROC PRINT NOOBS DATA=resid; VAR pat month resid pred;

TITLE 'RESIDUALS AND PREDICTED VALUES';

RUN;

PROC PLOT DATA=resid; PLOT resid*pred;

TITLE 'RESIDUALS AGAINST THEIR PREDICTED VALUES';

PROC PLOT DATA=resid; PLOT resid*month;

TITLE 'RESIDUALS AGAINST TIME (MONTHS)';

PROC RANK DATA=resid OUT=norm NORMAL=TUKEY; VAR resid; RANKS

s_resid;

PROC PLOT DATA=norm; PLOT resid*s_resid;

TITLE 'RESIDUALS - NORMAL PLOT';

DATA solut; SET solut;

patx=pat*1; * obtain numeric patient variable;

DROP pat;

DATA p_resid(KEEP=pat p_resid) pt_resid(KEEP=pat pt_

resid)

pt2_resi(KEEP=pat pt2_resi); SET solut;

pat=patx;

IF effect='Intercept' THEN DO;

p_resid=Estimate ;

OUTPUT p_resid;

END;

ELSE IF effect='month2' THEN DO;

pt2_resi=Estimate ;

OUTPUT pt2_resi;

END;

ELSE DO;

pt_resid=Estimate;

OUTPUT pt_resid;

END;

PROC SORT DATA=predm; BY pat;

PROC MEANS NOPRINT DATA=predm; BY pat;

VAR pred; OUTPUT OUT=predm MEAN=p_pred N=freq;

DATA a; MERGE p_resid pt_resid pt2_resi predm; BY pat ;

PROC PRINT NOOBS; VAR pat p_resid pt_resid pt2_resi

p pred

freq;

TITLE 'RANDOM COEFFICIENTS AND PREDICTED VALUES FOR

EACH

PATIENT';

PROC PLOT; PLOT p_resid*pt_resid;

TITLE 'PATIENT COEFFICIENTS VS PATIENT.TIME

COEFFICIENTS';

PROC PLOT; PLOT p_resid*pt2_resi;

TITLE 'PATIENT COEFFICIENTS VS PATIENT.TIME2

COEFFICIENTS';

PROC PLOT; PLOT pt_resid*pt2_resi;

TITLE 'PATIENT.TIME COEFFICIENTS VS PATIENT.

TIME2

COEFFICIENTS'

This code may not at first sight be straightforward to understand. The steps used are summarised below:

2. Use option OUTP to output the residuals (and predicted values given by Xa + Zp which are not required here) to dataset resid. Use OUTPM to output the predicted values given by Xa to dataset predm.Use ODS OUTPUT statement to output the random effects estimates to dataset solut. The ID statement causes the pat and month variables to be included in the datasets resid and predm.

3. Produce a print and plots of residuals.

4. Create datasets p_resid, pt_resid and pt2_resid containing random coefficients estimates for the patient and patient-time and patient-time2 effects, respectively.

5. Obtain predicted means for each patient (based on the predicted values X&) and merge these with the datasets of random coefficients.

6. Produce print and plots of the random coefficients.

RESIDUALS AND PREDICTED VALUES

pat

month

Resid

Pred

3

0.

00

1.

55766

3.

93234

3

0.

. 75

-0.

33901

3.

.80413

3

2.

00

-0.

25526

3.

61185

3

4.

00

-0.

. 42664

3.

35687

3

7.

00

-0.

45030

3.

08596

3

9.

00

-0.

13501

2.

97222

3

10.

00

-0.

47612

2.

93348

3

11.

00

-0.

01450

2.

90597

3

12.

00

-0.

. 04408

2.

88904

3

13.

00

-0.

.80454

2.

88206

3

16.

00

-0.

69730

2.

91435

3

21.

00

0.

61393

3.

10700

3

22.

00

1.

. 33944

3.

16056

3

23.

00

0.

99236

3.

21764

3

23.

50

0.

80270

3.

24730

3

24.

00

0.

52241

3.

27759

3

24.

25

-0.

09292

3.

.29292

3

26.

00

-0.

34351

3.

.40351

3

26.

. 75

-0.

. 53195

3.

45195

3

27.

00

-0.

07820

3.

46820

3

28.

00

-1.

05319

3.

53319

5

0.

00

0.

.30924

2.

82254

5

0.

50

-0.

29235

2.

78072

ETC

RANDOM COEFFICIENTS AND PREDICTED VALUES FOR EACH PATIENT

pat

P-

_resid

Pt-

resid

pt2- resi

p- pred

freq

3

0.

35106

-0.

05926

0.

002288204

3.

07590

21

5

-0.

71021

0.

03226

-.

001866166

3.

05075

22

13

0.

87930

0.

04089

0.

000270946

3.

06776

32

61

-0.

21678

0.

11842

004333146

3.

07713

22

63

0.

72495

0.

03671

-.

000784259

2.

82919

20

65

0.

70394

-0.

09316

0.

003276862

2.

82020

10

67

0.

38619

-0.

30506

0.

.009039204

2.

93704

9

69

-0.

27759

-0.

00126

0.

000636630

2.

72964

26

71

0.

64374

0.

16498

-.

004001423

2.

90710

25

73

-0.

13393

-0.

05631

0.

001523998

3.

39389

7

77

1.

17548

-0.

27558

0.

008724335

3.

46298

2

79

0.

49003

0.

04483

-.

000441731

3.

04050

24

All the residual plots appear in the main text.

Was this article helpful?

0 0

Post a comment