GavinB Tracker
https://communities.sas.com/kntur85557/tracker
GavinB TrackerTue, 23 Apr 2024 04:48:45 GMT2024-04-23T04:48:45ZRe: Repeated measures on calculated variables
https://communities.sas.com/t5/Statistical-Procedures/Repeated-measures-on-calculated-variables/m-p/606883#M29448
<P>Example of a code that I would run: </P><PRE><CODE class=" language-sas">ods graphics /imagemap=on;
proc mixed data=performance2 plots=all;
class TT time box block;
model DWG=TT|time/ ddfm=kenwardroger s cl influence(est effect=box iter=5) outp=mixout;
repeated time /subject=box type=un;
random INT/subject=block s cl;
store mixmodel;
run;
proc plm restore=mixmodel;
effectplot interaction(x=time sliceby=TT) / ilink clm connect;
slice TT*time/ sliceby=time pdiff=all cl ilink means plots=diffogram lines adjdfe=row adjust=simulate;
lsmeans TT/ pdiff=all adjust=simulate means lines;
run;</CODE></PRE><P>My time would be the timepoints at which I have measured the bodyweight. If I run this piece of code with bodyweight the lsmeans are quite close to the actual means. If I run it with daily weight gain (as I said before, I calculate this value by substracting previous BW with new BW and dividing this by the # of days) the lsmeans of the entire period (<U>Not the individual timepoints)</U> are quite far off...... Example of the dataset:</P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"><img src="https://communities.sas.com/t5/image/serverpage/image-id/34211iCCD9E07E24E0DAF9/image-size/large?v=v2&px=999" role="button" title="image.png" alt="image.png" /></span></P>Mon, 25 Nov 2019 07:25:42 GMThttps://communities.sas.com/t5/Statistical-Procedures/Repeated-measures-on-calculated-variables/m-p/606883#M29448GavinB2019-11-25T07:25:42ZRepeated measures on calculated variables
https://communities.sas.com/t5/Statistical-Procedures/Repeated-measures-on-calculated-variables/m-p/605422#M29406
<P>I am struggling with something which I believe is of no issue, but I cannot wrap my mind around it. The following is the issue:</P><P>Lets assume I run a trial in which I measure growth of a broiler from day 0-42, measuring every 7 days. Each 7 days, I myself calculate the daily growth, simply by dividing the growth of those 7 days by 7. When I analyze bodyweight of these birds using the repeated statement, the lsmeans of the model align with the actual means that I have measured. When I analyze the daily weight gain, the lsmeans of the individual timepoints align with my actual means, but the lsmeans of the average daily weight gain do not align with the calculated 0-42 weight gain (a +- 10% difference is not abnormal). Is it still valid to use the repeated measurement statement with a variable that is not measured, but calculated?</P><P> </P><P> </P>Tue, 19 Nov 2019 15:39:15 GMThttps://communities.sas.com/t5/Statistical-Procedures/Repeated-measures-on-calculated-variables/m-p/605422#M29406GavinB2019-11-19T15:39:15ZWhere statement with double digits
https://communities.sas.com/t5/SAS-Procedures/Where-statement-with-double-digits/m-p/447398#M69521
<P>After running a mixed model on 16 different treatments, where I also compare among the treatments I save the differences in a new file. With this new file I run a proc sgplot to create a difference plot showing the differences with respective confidence limit. In order for me to make this readable I put in a where between and statement to have it select all the differences for the comparisons between treatment 1vs2 till 1vs16. For some reason it fails to show what I want it to show when the second part contains double digits. To show what happens:<BR /><BR />proc sgplot data=differences noautolegend;<BR />where comparison between '1vs2' and'1vs9';</P><P>-->gives me the plot showing all comparisons between 1vs2 till 1vs9</P><P> </P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 160px;"><img src="https://communities.sas.com/t5/image/serverpage/image-id/19359i3E993ADC01B92C91/image-dimensions/160x120?v=v2" width="160" height="120" role="button" title="image.png" alt="image.png" /></span></P><P> </P><P><SPAN>proc sgplot data=differences noautolegend;</SPAN><BR /><SPAN>where comparison between '1vs2' and'1vs16'</SPAN><SPAN>;</SPAN></P><P><SPAN>-->only gives me the differences for 1vs2 and 1vs16 without any in between</SPAN></P><P><SPAN><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 200px;"><img src="https://communities.sas.com/t5/image/serverpage/image-id/19358iA1F7795AEE1B2AE6/image-dimensions/200x150?v=v2" width="200" height="150" role="button" title="image.png" alt="image.png" /></span></SPAN><SPAN><BR /></SPAN></P><P> </P><P><SPAN>It has to do with the second 1vs statement having double digits, because as soon as I change that it messes up the graph. It has to do with the way SAS reads this comparison, but does anyone have a solution for this??</SPAN></P><P> </P><P><SPAN>Thanks in advance,<BR />Gavin</SPAN></P>Wed, 21 Mar 2018 13:02:49 GMThttps://communities.sas.com/t5/SAS-Procedures/Where-statement-with-double-digits/m-p/447398#M69521GavinB2018-03-21T13:02:49ZRe: Proc glimmix contrasts
https://communities.sas.com/t5/Statistical-Procedures/Proc-glimmix-contrasts/m-p/411076#M21515
<P>Well, we managed to figure out what the problem was after quite some time (and a lot of headaches). </P><P> </P><P>The way the code was setup was simply not correct to show the results that I wanted. The design was a randomized complete block design and because of the way a mixed model works (using the entire dataset to estimate variance) – the difference between treatments will always be the same in each of the blocks if you code it like I did above. In order to actually see if treatment differences change due to the positioning in (for this particular dataset) barn, you need to include an interaction effect. This will give the replicated estimates of the treatments that I wanted. </P><P> </P><P>That basically solves the issue <img id="manwink" class="emoticon emoticon-manwink" src="https://communities.sas.com/i/smilies/16x16_man-wink.png" alt="Man Wink" title="Man Wink" /></P>Tue, 07 Nov 2017 07:26:06 GMThttps://communities.sas.com/t5/Statistical-Procedures/Proc-glimmix-contrasts/m-p/411076#M21515GavinB2017-11-07T07:26:06ZProc glimmix contrasts
https://communities.sas.com/t5/Statistical-Procedures/Proc-glimmix-contrasts/m-p/403485#M21039
<P>Dear Reader,</P><P> </P><P> </P><P>In my model, where treatment is fixed and block is random, there seems to be a different treatment effect for a different set of blocks. Attached you see code where I estimate treatment effects per set of random blocks, and code where I estimate the difference for a set of blocks. The estimates do NOT coincide, meaning that the difference per treatment does not flow from the estimates of a treatment. Any help on explaining this difference would be much appreciated. </P><P> </P><P> </P><P> </P><PRE><CODE class=" language-sas">proc glimmix data=test_Per plots=all;
class TT block;
model Per=TT / s cl ddfm=kenwardroger;
random block / s cl g gcorr;
estimate 'trt=1 @ blocks 1-6' intercept 6 TT 6 0 | block 1 1 1 1 1 1 0 0 0 0 0 0 / divisor=6;
estimate 'trt=2 @ blocks 1-6' intercept 6 TT 0 6 | block 1 1 1 1 1 1 0 0 0 0 0 0 / divisor=6;
estimate 'trt=1 vs trt=2 @ blocks 1-6' TT -6 6 0 0 0 0 0 0 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=3 @ blocks 1-6' TT -6 0 6 0 0 0 0 0 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=4 @ blocks 1-6' TT -6 0 0 6 0 0 0 0 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=5 @ blocks 1-6' TT -6 0 0 0 6 0 0 0 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=6 @ blocks 1-6' TT -6 0 0 0 0 6 0 0 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=7 @ blocks 1-6' TT -6 0 0 0 0 0 6 0 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=8 @ blocks 1-6' TT -6 0 0 0 0 0 0 6 0 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=9 @ blocks 1-6' TT -6 0 0 0 0 0 0 0 6 0 | block 1 1 1 1 1 1 0 0 0 0 0 0,
'trt=1 vs trt=10 @ blocks 1-6' TT -6 0 0 0 0 0 0 0 0 6 | block 1 1 1 1 1 1 0 0 0 0 0 0 / divisor=6 e adjdfe=row adjust=simulate(nsamp=100000);
estimate 'trt=1 vs trt=2 @ blocks 7-12' TT -6 6 0 0 0 0 0 0 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=3 @ blocks 7-12' TT -6 0 6 0 0 0 0 0 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=4 @ blocks 7-12' TT -6 0 0 6 0 0 0 0 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=5 @ blocks 7-12' TT -6 0 0 0 6 0 0 0 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=6 @ blocks 7-12' TT -6 0 0 0 0 6 0 0 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=7 @ blocks 7-12' TT -6 0 0 0 0 0 6 0 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=8 @ blocks 7-12' TT -6 0 0 0 0 0 0 6 0 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=9 @ blocks 7-12' TT -6 0 0 0 0 0 0 0 6 0 | block 0 0 0 0 0 0 1 1 1 1 1 1,
'trt=1 vs trt=10 @ blocks 7-12' TT -6 0 0 0 0 0 0 0 0 6 | block 0 0 0 0 0 0 1 1 1 1 1 1 / divisor=6 e adjdfe=row adjust=simulate(nsamp=100000);
store glimmix_Per;
run;</CODE></PRE><P> </P><P> </P><P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 371px;"><img src="https://communities.sas.com/t5/image/serverpage/image-id/15820i821B3C07A50DD8A3/image-size/large?v=v2&px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /></span><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 466px;"><img src="https://communities.sas.com/t5/image/serverpage/image-id/15821i52B363008CFABFE0/image-size/large?v=v2&px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /></span></P><P> </P><P> </P><P> </P><P> </P><P>Kind regards,</P><P>Gavin</P>Thu, 12 Oct 2017 10:08:07 GMThttps://communities.sas.com/t5/Statistical-Procedures/Proc-glimmix-contrasts/m-p/403485#M21039GavinB2017-10-12T10:08:07ZSAS studio macro's
https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/SAS-studio-macro-s/m-p/401315#M2696
<P>Hi,</P><P> </P><P>Some macro's are standard within SAS, for example the %logtest. However, within SAS studio that my company runs on a server build by SAS I cannot run these macro's. Is there a method to install these macro's or do you need to "activate" them first?</P><P> </P><P>Thanks in advance,</P><P>Gavin</P>Thu, 05 Oct 2017 13:00:41 GMThttps://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/SAS-studio-macro-s/m-p/401315#M2696GavinB2017-10-05T13:00:41ZRe: Proc nlin method
https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378579#M65558
<P>Hi Rick,</P><P> </P><P>This indeed seems to solve the problem for most of my parameters! Will look further into the ones that still give errors. Thanks for clearing things up.</P><P> </P><P> </P>Mon, 24 Jul 2017 05:42:18 GMThttps://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378579#M65558GavinB2017-07-24T05:42:18ZRe: Proc nlin method
https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378045#M65490
<P>Hi Rick,</P><P> </P><P>First of, thanks for replying so quickly!</P><P> </P><P>The model fits but refuses to go through the first points for some reason, which gives the following error message. <IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10437i1896A5F9135FF2C8/image-size/original?v=1.0&px=-1" border="0" alt="output SAS Nlin.png" title="output SAS Nlin.png" /></P><P>This then leads to improper estimations of the parameters since it does not fit through the first points. It gives the first values as missing values. I feel like the answer is rather simple, but I cannot seem to grasp it. </P><P> </P><P>The data has been read properly, the table shows the correct values and plotting the data also gives the proper graphs.</P><P> </P><P>Im running this on a SAS server running SAS studio <STRONG>9.04.01M4P11092016</STRONG> </P><P> </P><P> </P>Fri, 21 Jul 2017 09:52:51 GMThttps://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/378045#M65490GavinB2017-07-21T09:52:51ZRe: Proc nlin method
https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377917#M65478
<P>Hi Rick,</P><P> </P><P>I see I made a mistake when posting this, X in the table above is the DCt. I have adjusted that now, but that was already okay in my input file SAS. So the issues still remains......</P>Thu, 20 Jul 2017 20:27:54 GMThttps://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377917#M65478GavinB2017-07-20T20:27:54ZProc nlin method
https://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377649#M65470
<P> </P><P>I have a dataset with samples taken over time which looks as follows (took out one ID to show what it looks like):</P><TABLE><TBODY><TR><TD>Name</TD><TD>Time</TD><TD>X</TD></TR><TR><TD>1703187-01</TD><TD>0</TD><TD>2.07936</TD></TR><TR><TD>1703187-01</TD><TD>0</TD><TD>1.795714</TD></TR><TR><TD>1703187-01</TD><TD>30</TD><TD>21.24958</TD></TR><TR><TD>1703187-01</TD><TD>30</TD><TD>22.44529</TD></TR><TR><TD>1703187-01</TD><TD>60</TD><TD>34.25629</TD></TR><TR><TD>1703187-01</TD><TD>60</TD><TD>33.70213</TD></TR><TR><TD>1703187-01</TD><TD>90</TD><TD>44.95228</TD></TR><TR><TD>1703187-01</TD><TD>90</TD><TD>44.56428</TD></TR><TR><TD>1703187-01</TD><TD>120</TD><TD>54.86515</TD></TR><TR><TD>1703187-01</TD><TD>120</TD><TD>55.98709</TD></TR><TR><TD>1703187-01</TD><TD>150</TD><TD>66.58977</TD></TR><TR><TD>1703187-01</TD><TD>150</TD><TD>62.09209</TD></TR><TR><TD>1703187-01</TD><TD>180</TD><TD>80.25785</TD></TR><TR><TD>1703187-01</TD><TD>180</TD><TD>77.43605</TD></TR><TR><TD>1703187-01</TD><TD>240</TD><TD>88.45111</TD></TR><TR><TD>1703187-01</TD><TD>240</TD><TD>88.8228</TD></TR></TBODY></TABLE><P>I am using the Nlin method to solve the following equation: X=A + B * (1 - Exp(-km * :Time)) ^ c.</P><P>My code then looks like this: </P><P> </P><P>proc nlin data=IV plots=all maxiter=2000;<BR />parms A=2.5 Km=0.004 B=65 C=1;<BR />model X= A + B * (1 - exp(-Km * Time))**C;<BR />output out=IV p=yhat r=resid u95=upper l95=lower<BR />parms= A Km B C;<BR />run;</P><P> </P><P>This model will not fit properly if I try to run it on the dataset, however, if I change the Time values of my first time-point to for example 0.01 it does work. If I change them to 0.001 and run it again, it does not work anymore.</P><P>One of my collagues works in JMP and if he tries to fit the model on the original data it works perfectly, so I am really struggling to determine why it wont work in SAS, but more importantly, why it does fit when I change the first timepoint to something above 0. Does Nlin have issues with a 0 point?? </P><P> </P>Thu, 20 Jul 2017 20:27:06 GMThttps://communities.sas.com/t5/SAS-Procedures/Proc-nlin-method/m-p/377649#M65470GavinB2017-07-20T20:27:06Z