BookmarkSubscribeRSS Feed
jbwells7474
Calcite | Level 5

I'm new to SAS and I’m having difficulties asking for a random slope. If anybody has any insight, it would begreatly appreciated. (the first proc works, the second one does not)

datasubtype;                   

input y center study age race gender height weightcat;

datalines;

0 1 1 44 3 1 161 4

1 1 1 61 3 1 137 1

1 1 1 63 2 0 194 4

0 1 1 71 3 1 153 4

0 2 1 66 3 1 198 3

1 2 1 36 2 1 166 4

1 2 1 32 2 0 121 3

1 2 1 45 2 1 128 2

1 3 1 32 2 1 104 1

1 3 1 54 1 0 135 3

0 3 1 47 2 1 106 1

1 3 1 34 3 0 104 2

0 4 2 40 2 0 114 3

0 4 2 60 3 0 183 2

0 4 2 79 2 1 177 2

0 4 2 62 2 0 197 1

1 5 2 58 1 0 189 2

1 5 2 48 1 1 157 4

0 5 2 43 2 1 162 3

0 5 2 68 3 0 135 2

0 6 2 69 2 1 115 3

1 6 2 42 3 0 165 3

0 6 2 30 1 0 150 3

0 6 2 50 1 1 157 2

0 7 3 42 3 0 176 1

0 7 3 31 3 0 183 3

0 7 3 75 1 1 147 2

0 7 3 53 1 0 160 3

1 8 3 45 1 0 100 2

1 8 3 74 2 0 127 4

1 8 3 63 3 1 143 4

1 8 3 64 1 1 131 2

1 9 3 56 1 0 107 2

1 9 3 78 2 1 195 2

0 9 3 35 3 0 182 2

1 9 3 47 1 0 123 3

;

proc glimmix;

classcenter;

modely = height / dist=bin link=logitsolution;

randomintercept / type =un subject= center;

random_residual_;

run;

proc glimmix;

classcenter;

modely = height / dist=bin link=logitsolution;

randomintercept height / type =un subject= center;

random_residual_;

run;

13 REPLIES 13
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

Use:

model y = height / dist=bin link=logit s;

random int height / sub=center type=un;

random _residual_;

This will give you a random coefficient model (with random effects for intercept and slope).

JatinRai
Obsidian | Level 7

I'm using the similar statements on SAS on Unix platform. I've 500,000 different customer ids on which I'm trying to run this program & each is has 5 different observations. But I get the error message that memory is not sufficient. Any suggestions on how to run this successfully will be deeply appreciated.

proc glimmix data=xxx;

model y = x1 x2 x3 / dist=bin link=logit solution;

random intercept / subject=id;

run;

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

You will probably not get GLIMMIX to run with that many observations. I suggest you take a random sample of the customers (keeping all the observations for the selected customers), and do the analysis on this sample.

Note: you did not define ID as a factor using a class statement. That is OK, as long as the data are sorted by ID before running GLIMMIX. If not sorted, you could get incorrect results (when you have a small enough sample to get any results).

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

HPMIXED is only for normal data.

JatinRai
Obsidian | Level 7

Thanks for the input. Yes I looked into HPMixed and that just handles issues from proc mixed and not from proc glimmix. I wish I could run this procedure for entire population.

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

One way around this would be to use the macro %hpglimmix written by a sas user (not a sas employee). Just do a google search for %hpglimmix. However, last time I looked, this macro is not yet available for the public. You can always write and ask.

SteveDenham
Jade | Level 19

I don't know if this is possible, because I don't know if there is any way to collapse the data, so that the dependent variable is a proportion rather than a 0/1 for each individual.  If you could collapse and calculate the proportion, then the problem may become tractable, either in GLIMMIX with perhaps a beta or a binomial distribution, or in MIXED after transformation (say, arcsine square root transform).  The random slopes, however, would describe the population that you collapse to.

If you are able to use the %hpglimmix macro, please let the group know how it turns out, and any tweaks you might have had to use to get it to work.

Steve Denham

JatinRai
Obsidian | Level 7

I tried finding %hpglimmix but all the posts on Google point to the same blog. It sounds like a great solution but seems that I'll have to wait.

lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

Yes, the macro will not be available for several more months, or later. I suggest you look at a random subset of your data set with the procedure.

Muller
Calcite | Level 5

I just saw this question and thought the following might help.

If you would like to fit the model without an R side matrix (without the random _residual_ statement in your code) which will lead to a random coefficient model with a G side matrix, I think the non-convergence problem might be resolved using NLOPTIONS. With the given data example above, the following code leads to convergence with four iterations. However, the problem of nonconvergence with very large datasets still remains to be a problem. You have to of course check if that is what you want.

proc glimmix data=subtype;

class center;

model y = height / dist=bin link=logit solution;

random intercept height / type =un subject= center;

nloptions tech=NRRIDG;

run;

JatinRai
Obsidian | Level 7

Let me ask you guys another question as you all are very familiar with this procedure (I don't find many experts on glimmix!).

Glimmix allows for joint modeling of binary and poisson distributed variables (as cited by an example in the documentation). Does it also allow modelling two binary DVs jointly?

Also what if I want to model two DVs jointly in genmod, can I do that?

Thanks a lot.

SteveDenham
Jade | Level 19

I know GLIMMIX can do the joint modeling of variables--follow along the example in the documentation for the binary/poisson, and replace poisson throughout.  Probably have to fix up the dataset so that the variable 'dist' is on each record.

I don't think you can do it in GENMOD, but GLIMMIX should give the same results, assuming that you have no random effects.  If you are doing repeated measures in GENMOD (GEE stuff), you can get approximately similar answers in GLIMMIX with an appropriate RANDOM statement with the residual option.

Steve Denham

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 13 replies
  • 3154 views
  • 5 likes
  • 6 in conversation