Converting SAS Code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting SAS Code

andrewharmon42
Hello all,

My statistical analysis training up until this point has been entirely done
in SAS. The code I frequently used was:

*Yield Champagin;

data yield;

set stress;

if field='YV' then delete;

if field='HB' then delete;

if barcode='16187DD4015' then delete;

if barcode='16187DD6002' then delete;

if barcode='16187DD2007' then delete;

if barcode='16187DD5016' then delete;

if barcode='16187DD8007' then delete;

if barcode='16187DD7010' then delete;

if barcode='16187DD7007' then delete;

if barcode='16187DD8005' then delete;

if barcode='16187DD6004' then delete;

if barcode='16187DD5008' then delete;

if barcode='16187DD7012' then delete;

if barcode='16187DD6010' then delete;

run; quit;



Title'2016 Asilomar Stress Relief champagin yield';

proc mixed method=reml data=yield;

class rep Management Foliar_Fungicide Chemical_Treatment;

model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;

random rep rep*Management rep*Management*Foliar_Fungicide;

lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;

ods output diffs=ppp lsmeans=means;

ods listing exclude diffs lsmeans;

run; quit;

%include'C:\Users\harmon12\Desktop\pdmix800.sas';

%pdmix800(ppp,means,alpha=0.10,sort=yes);

ods graphics off;

run; quit;

proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
pearsonresid; var resid;
proc print data=resids (obs=3);run;

Can someone please help me convert my code to R? Any help would be much
appreciated.


Thanks,


Andrew Harmon

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Tobias Fellinger
Hello,

in my experience the most direct path of converting SAS code to R is by
using dplyr. dplyr provides the filter function, the first part of your
code could look like this, assuming your datasets are stored as
data.frames:

library(dplyr)

yield <- filter(stress,
  field != "YV",
  field != "HV",
  barcode != "16187DD4015",
  barcode != "16187DD6002")

(and so on for the other barcodes.)

For mixed effects look into the lme4 package, lmer should use the reml
criterion per default, the model specifications work very different in
R. Look into the vingette [1] of the lme4 package chapter 2.1. gives an
explanation of the used model formulas.

You should get the coeficients of the fitted glmer model with the coef
function.

The Plots and univariate statistics work very different in R, have a
look at the functions group_by and summarise provided by the dplyr
package for calculating univariate statistics by groups, and the ggplot
2 package for plotting.

Tobi

[1] https://cran.r-project.org/web/packages/lme4/vignettes/lmer.pdf


On Fri, 2017-09-29 at 07:47 -0500, Andrew Harmon wrote:

> Hello all,
>
> My statistical analysis training up until this point has been entirely done
> in SAS. The code I frequently used was:
>
> *Yield Champagin;
>
> data yield;
>
> set stress;
>
> if field='YV' then delete;
>
> if field='HB' then delete;
>
> if barcode='16187DD4015' then delete;
>
> if barcode='16187DD6002' then delete;
>
> if barcode='16187DD2007' then delete;
>
> if barcode='16187DD5016' then delete;
>
> if barcode='16187DD8007' then delete;
>
> if barcode='16187DD7010' then delete;
>
> if barcode='16187DD7007' then delete;
>
> if barcode='16187DD8005' then delete;
>
> if barcode='16187DD6004' then delete;
>
> if barcode='16187DD5008' then delete;
>
> if barcode='16187DD7012' then delete;
>
> if barcode='16187DD6010' then delete;
>
> run; quit;
>
>
>
> Title'2016 Asilomar Stress Relief champagin yield';
>
> proc mixed method=reml data=yield;
>
> class rep Management Foliar_Fungicide Chemical_Treatment;
>
> model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>
> random rep rep*Management rep*Management*Foliar_Fungicide;
>
> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>
> ods output diffs=ppp lsmeans=means;
>
> ods listing exclude diffs lsmeans;
>
> run; quit;
>
> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>
> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>
> ods graphics off;
>
> run; quit;
>
> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
> pearsonresid; var resid;
> proc print data=resids (obs=3);run;
>
> Can someone please help me convert my code to R? Any help would be much
> appreciated.
>
>
> Thanks,
>
>
> Andrew Harmon
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Michael Dewey-3
In reply to this post by andrewharmon42
You might get better answers if you

1 - break this down into separate issues
2 - tell us what you want to achieve in words rather than SAS, we all
read English but few of us speak SAS
3 - post in plain text not HTML as HTML mangles your post

On 29/09/2017 13:47, Andrew Harmon wrote:

> Hello all,
>
> My statistical analysis training up until this point has been entirely done
> in SAS. The code I frequently used was:
>
> *Yield Champagin;
>
> data yield;
>
> set stress;
>
> if field='YV' then delete;
>
> if field='HB' then delete;
>
> if barcode='16187DD4015' then delete;
>
> if barcode='16187DD6002' then delete;
>
> if barcode='16187DD2007' then delete;
>
> if barcode='16187DD5016' then delete;
>
> if barcode='16187DD8007' then delete;
>
> if barcode='16187DD7010' then delete;
>
> if barcode='16187DD7007' then delete;
>
> if barcode='16187DD8005' then delete;
>
> if barcode='16187DD6004' then delete;
>
> if barcode='16187DD5008' then delete;
>
> if barcode='16187DD7012' then delete;
>
> if barcode='16187DD6010' then delete;
>
> run; quit;
>
>
>
> Title'2016 Asilomar Stress Relief champagin yield';
>
> proc mixed method=reml data=yield;
>
> class rep Management Foliar_Fungicide Chemical_Treatment;
>
> model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>
> random rep rep*Management rep*Management*Foliar_Fungicide;
>
> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>
> ods output diffs=ppp lsmeans=means;
>
> ods listing exclude diffs lsmeans;
>
> run; quit;
>
> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>
> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>
> ods graphics off;
>
> run; quit;
>
> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
> pearsonresid; var resid;
> proc print data=resids (obs=3);run;
>
> Can someone please help me convert my code to R? Any help would be much
> appreciated.
>
>
> Thanks,
>
>
> Andrew Harmon
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com
>
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Kevin E. Thorpe
Regarding point 3, as a moderator I have been helping Andrew get this
post out to the list over the past week. His previous attempts were
encoded in some way that the listserv rejected. He sent me the post via
his gmail account and viewing the source I saw it had at least both
plain test and HTML an I said it was worth a try to post it. Certainly
on my mail client his post displays acceptably with the notice that the
HTML alternative was removed.

Kevin

On 09/29/2017 09:51 AM, Michael Dewey wrote:

> You might get better answers if you
>
> 1 - break this down into separate issues
> 2 - tell us what you want to achieve in words rather than SAS, we all
> read English but few of us speak SAS
> 3 - post in plain text not HTML as HTML mangles your post
>
> On 29/09/2017 13:47, Andrew Harmon wrote:
>> Hello all,
>>
>> My statistical analysis training up until this point has been
>> entirely done
>> in SAS. The code I frequently used was:
>>
>> *Yield Champagin;
>>
>> data yield;
>>
>> set stress;
>>
>> if field='YV' then delete;
>>
>> if field='HB' then delete;
>>
>> if barcode='16187DD4015' then delete;
>>
>> if barcode='16187DD6002' then delete;
>>
>> if barcode='16187DD2007' then delete;
>>
>> if barcode='16187DD5016' then delete;
>>
>> if barcode='16187DD8007' then delete;
>>
>> if barcode='16187DD7010' then delete;
>>
>> if barcode='16187DD7007' then delete;
>>
>> if barcode='16187DD8005' then delete;
>>
>> if barcode='16187DD6004' then delete;
>>
>> if barcode='16187DD5008' then delete;
>>
>> if barcode='16187DD7012' then delete;
>>
>> if barcode='16187DD6010' then delete;
>>
>> run; quit;
>>
>>
>>
>> Title'2016 Asilomar Stress Relief champagin yield';
>>
>> proc mixed method=reml data=yield;
>>
>> class rep Management Foliar_Fungicide Chemical_Treatment;
>>
>> model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
>> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>>
>> random rep rep*Management rep*Management*Foliar_Fungicide;
>>
>> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>>
>> ods output diffs=ppp lsmeans=means;
>>
>> ods listing exclude diffs lsmeans;
>>
>> run; quit;
>>
>> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>>
>> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>>
>> ods graphics off;
>>
>> run; quit;
>>
>> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
>> pearsonresid; var resid;
>> proc print data=resids (obs=3);run;
>>
>> Can someone please help me convert my code to R? Any help would be much
>> appreciated.
>>
>>
>> Thanks,
>>
>>
>> Andrew Harmon
>>
>>     [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ---
>> This email has been checked for viruses by AVG.
>> http://www.avg.com
>>
>>
>

--
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's Hospital
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: [hidden email]  Tel: 416.864.5776  Fax: 416.864.3016

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Bert Gunter-2
I will offer an opinion, with which others may fairly take issue.

If you are coming from SAS and wish to learn R, you should forget about SAS
entirely; it is ancient and convoluted. But more to the point, as others
have already suggested, you will only confuse and hamstring yourself trying
to convert the programming paradigms of one language into another. Better
to consider the **tasks** you wish to accomplish and learn how to approach
them in the new language. I would add that this especially includes
learning about R's varied data structures for which there is no cognate in
SAS I think (correction requested if I'm wrong about this).

If this is a one-off, just finding a local resource to do the job for you
might be the best approach.

Cheers,
Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Sep 29, 2017 at 10:21 AM, Kevin E. Thorpe <[hidden email]>
wrote:

> Regarding point 3, as a moderator I have been helping Andrew get this post
> out to the list over the past week. His previous attempts were encoded in
> some way that the listserv rejected. He sent me the post via his gmail
> account and viewing the source I saw it had at least both plain test and
> HTML an I said it was worth a try to post it. Certainly on my mail client
> his post displays acceptably with the notice that the HTML alternative was
> removed.
>
> Kevin
>
> On 09/29/2017 09:51 AM, Michael Dewey wrote:
>
>> You might get better answers if you
>>
>> 1 - break this down into separate issues
>> 2 - tell us what you want to achieve in words rather than SAS, we all
>> read English but few of us speak SAS
>> 3 - post in plain text not HTML as HTML mangles your post
>>
>> On 29/09/2017 13:47, Andrew Harmon wrote:
>>
>>> Hello all,
>>>
>>> My statistical analysis training up until this point has been entirely
>>> done
>>> in SAS. The code I frequently used was:
>>>
>>> *Yield Champagin;
>>>
>>> data yield;
>>>
>>> set stress;
>>>
>>> if field='YV' then delete;
>>>
>>> if field='HB' then delete;
>>>
>>> if barcode='16187DD4015' then delete;
>>>
>>> if barcode='16187DD6002' then delete;
>>>
>>> if barcode='16187DD2007' then delete;
>>>
>>> if barcode='16187DD5016' then delete;
>>>
>>> if barcode='16187DD8007' then delete;
>>>
>>> if barcode='16187DD7010' then delete;
>>>
>>> if barcode='16187DD7007' then delete;
>>>
>>> if barcode='16187DD8005' then delete;
>>>
>>> if barcode='16187DD6004' then delete;
>>>
>>> if barcode='16187DD5008' then delete;
>>>
>>> if barcode='16187DD7012' then delete;
>>>
>>> if barcode='16187DD6010' then delete;
>>>
>>> run; quit;
>>>
>>>
>>>
>>> Title'2016 Asilomar Stress Relief champagin yield';
>>>
>>> proc mixed method=reml data=yield;
>>>
>>> class rep Management Foliar_Fungicide Chemical_Treatment;
>>>
>>> model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
>>> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>>>
>>> random rep rep*Management rep*Management*Foliar_Fungicide;
>>>
>>> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>>>
>>> ods output diffs=ppp lsmeans=means;
>>>
>>> ods listing exclude diffs lsmeans;
>>>
>>> run; quit;
>>>
>>> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>>>
>>> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>>>
>>> ods graphics off;
>>>
>>> run; quit;
>>>
>>> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
>>> pearsonresid; var resid;
>>> proc print data=resids (obs=3);run;
>>>
>>> Can someone please help me convert my code to R? Any help would be much
>>> appreciated.
>>>
>>>
>>> Thanks,
>>>
>>>
>>> Andrew Harmon
>>>
>>>     [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>> ---
>>> This email has been checked for viruses by AVG.
>>> http://www.avg.com
>>>
>>>
>>>
>>
> --
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC)
> Li Ka Shing Knowledge Institute of St. Michael's Hospital
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: [hidden email]  Tel: 416.864.5776  Fax: 416.864.3016
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

JLucke
I wish to second this approach to learning R.

I tried for several years to translate other stat programs  or provide
parallel analyses with R.
This dabbling-in-R approach did not work
.
When a transferred to a research unit  that could ill afford commercial
software, I devoted my entire time to doing everything in R.
This was a difficult learning process, but I eventually became proficient
in R.

The conceptual paradigm for R is only marginally commensurate with that of
standard statistical software.
You must immerse yourself in R to become proficient.

Good luck,
Joe
 


Bert Gunter <[hidden email]>
Sent by: "R-help" <[hidden email]>
09/29/2017 02:09 PM

To
"Kevin E. Thorpe" <[hidden email]>,
cc
R-help <[hidden email]>, Andrew Harmon <[hidden email]>
Subject
Re: [R] Converting SAS Code






I will offer an opinion, with which others may fairly take issue.

If you are coming from SAS and wish to learn R, you should forget about
SAS
entirely; it is ancient and convoluted. But more to the point, as others
have already suggested, you will only confuse and hamstring yourself
trying
to convert the programming paradigms of one language into another. Better
to consider the **tasks** you wish to accomplish and learn how to approach
them in the new language. I would add that this especially includes
learning about R's varied data structures for which there is no cognate in
SAS I think (correction requested if I'm wrong about this).

If this is a one-off, just finding a local resource to do the job for you
might be the best approach.

Cheers,
Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Sep 29, 2017 at 10:21 AM, Kevin E. Thorpe
<[hidden email]>
wrote:

> Regarding point 3, as a moderator I have been helping Andrew get this
post
> out to the list over the past week. His previous attempts were encoded
in
> some way that the listserv rejected. He sent me the post via his gmail
> account and viewing the source I saw it had at least both plain test and
> HTML an I said it was worth a try to post it. Certainly on my mail
client
> his post displays acceptably with the notice that the HTML alternative
was

> removed.
>
> Kevin
>
> On 09/29/2017 09:51 AM, Michael Dewey wrote:
>
>> You might get better answers if you
>>
>> 1 - break this down into separate issues
>> 2 - tell us what you want to achieve in words rather than SAS, we all
>> read English but few of us speak SAS
>> 3 - post in plain text not HTML as HTML mangles your post
>>
>> On 29/09/2017 13:47, Andrew Harmon wrote:
>>
>>> Hello all,
>>>
>>> My statistical analysis training up until this point has been entirely
>>> done
>>> in SAS. The code I frequently used was:
>>>
>>> *Yield Champagin;
>>>
>>> data yield;
>>>
>>> set stress;
>>>
>>> if field='YV' then delete;
>>>
>>> if field='HB' then delete;
>>>
>>> if barcode='16187DD4015' then delete;
>>>
>>> if barcode='16187DD6002' then delete;
>>>
>>> if barcode='16187DD2007' then delete;
>>>
>>> if barcode='16187DD5016' then delete;
>>>
>>> if barcode='16187DD8007' then delete;
>>>
>>> if barcode='16187DD7010' then delete;
>>>
>>> if barcode='16187DD7007' then delete;
>>>
>>> if barcode='16187DD8005' then delete;
>>>
>>> if barcode='16187DD6004' then delete;
>>>
>>> if barcode='16187DD5008' then delete;
>>>
>>> if barcode='16187DD7012' then delete;
>>>
>>> if barcode='16187DD6010' then delete;
>>>
>>> run; quit;
>>>
>>>
>>>
>>> Title'2016 Asilomar Stress Relief champagin yield';
>>>
>>> proc mixed method=reml data=yield;
>>>
>>> class rep Management Foliar_Fungicide Chemical_Treatment;
>>>
>>> model Grain_Yield__Mg_h_
=Management|Foliar_Fungicide|Chemical_Treatment

>>> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>>>
>>> random rep rep*Management rep*Management*Foliar_Fungicide;
>>>
>>> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>>>
>>> ods output diffs=ppp lsmeans=means;
>>>
>>> ods listing exclude diffs lsmeans;
>>>
>>> run; quit;
>>>
>>> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>>>
>>> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>>>
>>> ods graphics off;
>>>
>>> run; quit;
>>>
>>> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
>>> pearsonresid; var resid;
>>> proc print data=resids (obs=3);run;
>>>
>>> Can someone please help me convert my code to R? Any help would be
much

>>> appreciated.
>>>
>>>
>>> Thanks,
>>>
>>>
>>> Andrew Harmon
>>>
>>>     [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>> ---
>>> This email has been checked for viruses by AVG.
>>> http://www.avg.com
>>>
>>>
>>>
>>
> --
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC)
> Li Ka Shing Knowledge Institute of St. Michael's Hospital
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: [hidden email]  Tel: 416.864.5776  Fax: 416.864.3016
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.

                 [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

jdnewmil-2
In reply to this post by Kevin E. Thorpe
All HTML emails have a plain text part along with the HTML part... but it is usually invisible to the author and is automatically generated by the email composing software and some software is better than others at that job (by a lot). However, without a doubt, sending the email in text form at least means the sender saw the plain text part before it was sent, which removes a potentially huge barrier to communication.  And GMail definitely can send plain text.
--
Sent from my phone. Please excuse my brevity.

On September 29, 2017 10:21:50 AM PDT, "Kevin E. Thorpe" <[hidden email]> wrote:

>Regarding point 3, as a moderator I have been helping Andrew get this
>post out to the list over the past week. His previous attempts were
>encoded in some way that the listserv rejected. He sent me the post via
>
>his gmail account and viewing the source I saw it had at least both
>plain test and HTML an I said it was worth a try to post it. Certainly
>on my mail client his post displays acceptably with the notice that the
>
>HTML alternative was removed.
>
>Kevin
>
>On 09/29/2017 09:51 AM, Michael Dewey wrote:
>> You might get better answers if you
>>
>> 1 - break this down into separate issues
>> 2 - tell us what you want to achieve in words rather than SAS, we all
>
>> read English but few of us speak SAS
>> 3 - post in plain text not HTML as HTML mangles your post
>>
>> On 29/09/2017 13:47, Andrew Harmon wrote:
>>> Hello all,
>>>
>>> My statistical analysis training up until this point has been
>>> entirely done
>>> in SAS. The code I frequently used was:
>>>
>>> *Yield Champagin;
>>>
>>> data yield;
>>>
>>> set stress;
>>>
>>> if field='YV' then delete;
>>>
>>> if field='HB' then delete;
>>>
>>> if barcode='16187DD4015' then delete;
>>>
>>> if barcode='16187DD6002' then delete;
>>>
>>> if barcode='16187DD2007' then delete;
>>>
>>> if barcode='16187DD5016' then delete;
>>>
>>> if barcode='16187DD8007' then delete;
>>>
>>> if barcode='16187DD7010' then delete;
>>>
>>> if barcode='16187DD7007' then delete;
>>>
>>> if barcode='16187DD8005' then delete;
>>>
>>> if barcode='16187DD6004' then delete;
>>>
>>> if barcode='16187DD5008' then delete;
>>>
>>> if barcode='16187DD7012' then delete;
>>>
>>> if barcode='16187DD6010' then delete;
>>>
>>> run; quit;
>>>
>>>
>>>
>>> Title'2016 Asilomar Stress Relief champagin yield';
>>>
>>> proc mixed method=reml data=yield;
>>>
>>> class rep Management Foliar_Fungicide Chemical_Treatment;
>>>
>>> model Grain_Yield__Mg_h_
>=Management|Foliar_Fungicide|Chemical_Treatment
>>> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>>>
>>> random rep rep*Management rep*Management*Foliar_Fungicide;
>>>
>>> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>>>
>>> ods output diffs=ppp lsmeans=means;
>>>
>>> ods listing exclude diffs lsmeans;
>>>
>>> run; quit;
>>>
>>> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>>>
>>> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>>>
>>> ods graphics off;
>>>
>>> run; quit;
>>>
>>> proc univariate data=resids normal plot; id Barcode
>Grain_Yield__Mg_h_
>>> pearsonresid; var resid;
>>> proc print data=resids (obs=3);run;
>>>
>>> Can someone please help me convert my code to R? Any help would be
>much
>>> appreciated.
>>>
>>>
>>> Thanks,
>>>
>>>
>>> Andrew Harmon
>>>
>>>     [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>> ---
>>> This email has been checked for viruses by AVG.
>>> http://www.avg.com
>>>
>>>
>>
>
>--
>Kevin E. Thorpe
>Head of Biostatistics,  Applied Health Research Centre (AHRC)
>Li Ka Shing Knowledge Institute of St. Michael's Hospital
>Assistant Professor, Dalla Lana School of Public Health
>University of Toronto
>email: [hidden email]  Tel: 416.864.5776  Fax: 416.864.3016
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Marc Schwartz-3
In reply to this post by Bert Gunter-2
Hi,

I would echo Bert's comments below.

The last thing that you want to try to do is to convert SAS code to R code on a "line for line" basis. The programming paradigm of R, which is built upon vectorized operations, takes a "whole object" approach for efficiency. SAS does not, since it is generally based upon 1970's era, main frame style, programming techniques using macros, etc.

If this is not a one off and something that you might find yourself doing with some frequency, you might consider investing in Bob Muenchen's book, R for SAS and SPSS Users:

  https://www.amazon.com/gp/product/1461406846/ <https://www.amazon.com/gp/product/1461406846/>

While it is now a few years old, it is still relevant in terms of pointing you in the direction of basic and conceptual linkages between the languages.

Regards,

Marc Schwartz


> On Sep 29, 2017, at 2:09 PM, Bert Gunter <[hidden email]> wrote:
>
> I will offer an opinion, with which others may fairly take issue.
>
> If you are coming from SAS and wish to learn R, you should forget about SAS
> entirely; it is ancient and convoluted. But more to the point, as others
> have already suggested, you will only confuse and hamstring yourself trying
> to convert the programming paradigms of one language into another. Better
> to consider the **tasks** you wish to accomplish and learn how to approach
> them in the new language. I would add that this especially includes
> learning about R's varied data structures for which there is no cognate in
> SAS I think (correction requested if I'm wrong about this).
>
> If this is a one-off, just finding a local resource to do the job for you
> might be the best approach.
>
> Cheers,
> Bert
>
>
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Fri, Sep 29, 2017 at 10:21 AM, Kevin E. Thorpe <[hidden email]>
> wrote:
>
>> Regarding point 3, as a moderator I have been helping Andrew get this post
>> out to the list over the past week. His previous attempts were encoded in
>> some way that the listserv rejected. He sent me the post via his gmail
>> account and viewing the source I saw it had at least both plain test and
>> HTML an I said it was worth a try to post it. Certainly on my mail client
>> his post displays acceptably with the notice that the HTML alternative was
>> removed.
>>
>> Kevin
>>
>> On 09/29/2017 09:51 AM, Michael Dewey wrote:
>>
>>> You might get better answers if you
>>>
>>> 1 - break this down into separate issues
>>> 2 - tell us what you want to achieve in words rather than SAS, we all
>>> read English but few of us speak SAS
>>> 3 - post in plain text not HTML as HTML mangles your post
>>>
>>> On 29/09/2017 13:47, Andrew Harmon wrote:
>>>
>>>> Hello all,
>>>>
>>>> My statistical analysis training up until this point has been entirely
>>>> done
>>>> in SAS. The code I frequently used was:
>>>>
>>>> *Yield Champagin;
>>>>
>>>> data yield;
>>>>
>>>> set stress;
>>>>
>>>> if field='YV' then delete;
>>>>
>>>> if field='HB' then delete;
>>>>
>>>> if barcode='16187DD4015' then delete;
>>>>
>>>> if barcode='16187DD6002' then delete;
>>>>
>>>> if barcode='16187DD2007' then delete;
>>>>
>>>> if barcode='16187DD5016' then delete;
>>>>
>>>> if barcode='16187DD8007' then delete;
>>>>
>>>> if barcode='16187DD7010' then delete;
>>>>
>>>> if barcode='16187DD7007' then delete;
>>>>
>>>> if barcode='16187DD8005' then delete;
>>>>
>>>> if barcode='16187DD6004' then delete;
>>>>
>>>> if barcode='16187DD5008' then delete;
>>>>
>>>> if barcode='16187DD7012' then delete;
>>>>
>>>> if barcode='16187DD6010' then delete;
>>>>
>>>> run; quit;
>>>>
>>>>
>>>>
>>>> Title'2016 Asilomar Stress Relief champagin yield';
>>>>
>>>> proc mixed method=reml data=yield;
>>>>
>>>> class rep Management Foliar_Fungicide Chemical_Treatment;
>>>>
>>>> model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
>>>> Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
>>>>
>>>> random rep rep*Management rep*Management*Foliar_Fungicide;
>>>>
>>>> lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
>>>>
>>>> ods output diffs=ppp lsmeans=means;
>>>>
>>>> ods listing exclude diffs lsmeans;
>>>>
>>>> run; quit;
>>>>
>>>> %include'C:\Users\harmon12\Desktop\pdmix800.sas';
>>>>
>>>> %pdmix800(ppp,means,alpha=0.10,sort=yes);
>>>>
>>>> ods graphics off;
>>>>
>>>> run; quit;
>>>>
>>>> proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
>>>> pearsonresid; var resid;
>>>> proc print data=resids (obs=3);run;
>>>>
>>>> Can someone please help me convert my code to R? Any help would be much
>>>> appreciated.
>>>>
>>>>
>>>> Thanks,
>>>>
>>>>
>>>> Andrew Harmon
>>>>
>>>>    [[alternative HTML version deleted]]


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Rolf Turner
In reply to this post by JLucke
On 30/09/17 07:45, [hidden email] wrote:

<SNIP>

>
> The conceptual paradigm for R is only marginally commensurate with that of
> standard statistical software.
> You must immerse yourself in R to become proficient.

Fortune nomination.

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

MacQueen, Don
In reply to this post by andrewharmon42
For the initial data step, assuming a data frame named stress already exists, and using base R, you can start with something like this:

barcodes.to.delete <- c('16187DD4015', '16187DD6002',   {complete the comma-delimited vector of barcodes you don't want}  )

yield <- subset(stress,  !(barcode %in% barcodes.to.delete) )
yield <- subset(yield , !(field %in% c('YY','HB') )

## the above three lines could be done in a single line, but it would be long, ugly, hard to read, and hard to validate.
## easier to split it into a few steps

## another way, still using base R, and with a different syntax for the subsetting
records.to.drop <- stress$barcode %in% barcodes.to.delete | stress$yield %in% c('YY', 'HB')
yield <- stress[ !records.to.drop , ]

I think these are examples of doing it "the R way", not thinking in terms of directly translating SAS code to R code.

I used to use SAS a lot, but I don't know what the line
  *Yield Champagin;
does.

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 9/29/17, 5:47 AM, "R-help on behalf of Andrew Harmon" <[hidden email] on behalf of [hidden email]> wrote:

    Hello all,
   
    My statistical analysis training up until this point has been entirely done
    in SAS. The code I frequently used was:
   
    *Yield Champagin;
   
    data yield;
   
    set stress;
   
    if field='YV' then delete;
   
    if field='HB' then delete;
   
    if barcode='16187DD4015' then delete;
   
    if barcode='16187DD6002' then delete;
   
    if barcode='16187DD2007' then delete;
   
    if barcode='16187DD5016' then delete;
   
    if barcode='16187DD8007' then delete;
   
    if barcode='16187DD7010' then delete;
   
    if barcode='16187DD7007' then delete;
   
    if barcode='16187DD8005' then delete;
   
    if barcode='16187DD6004' then delete;
   
    if barcode='16187DD5008' then delete;
   
    if barcode='16187DD7012' then delete;
   
    if barcode='16187DD6010' then delete;
   
    run; quit;
   
   
   
    Title'2016 Asilomar Stress Relief champagin yield';
   
    proc mixed method=reml data=yield;
   
    class rep Management Foliar_Fungicide Chemical_Treatment;
   
    model Grain_Yield__Mg_h_ =Management|Foliar_Fungicide|Chemical_Treatment
    Final_Stand__Plants_A_ / outpred=resids residual ddfm=kr;
   
    random rep rep*Management rep*Management*Foliar_Fungicide;
   
    lsmeans Management|Foliar_Fungicide|Chemical_Treatment / pdiff;
   
    ods output diffs=ppp lsmeans=means;
   
    ods listing exclude diffs lsmeans;
   
    run; quit;
   
    %include'C:\Users\harmon12\Desktop\pdmix800.sas';
   
    %pdmix800(ppp,means,alpha=0.10,sort=yes);
   
    ods graphics off;
   
    run; quit;
   
    proc univariate data=resids normal plot; id Barcode Grain_Yield__Mg_h_
    pearsonresid; var resid;
    proc print data=resids (obs=3);run;
   
    Can someone please help me convert my code to R? Any help would be much
    appreciated.
   
   
    Thanks,
   
   
    Andrew Harmon
   
    [[alternative HTML version deleted]]
   
    ______________________________________________
    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
   

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Peter Dalgaard-2

> On 29 Sep 2017, at 22:43 , MacQueen, Don <[hidden email]> wrote:
>
> I used to use SAS a lot, but I don't know what the line
>  *Yield Champagin;
> does.

Nothing. It's a comment...

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

plangfelder
On Fri, Sep 29, 2017 at 2:32 PM, peter dalgaard <[hidden email]> wrote:
>
>> On 29 Sep 2017, at 22:43 , MacQueen, Don <[hidden email]> wrote:
>>
>> I used to use SAS a lot, but I don't know what the line
>>  *Yield Champagin;
>> does.
>
> Nothing. It's a comment...

Fortune nomination!

Peter

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Robert Baer
In reply to this post by Rolf Turner


On 9/29/2017 3:37 PM, Rolf Turner wrote:

> On 30/09/17 07:45, [hidden email] wrote:
>
> <SNIP>
>
>>
>> The conceptual paradigm for R is only marginally commensurate with
>> that of
>> standard statistical software.
>> You must immerse yourself in R to become proficient.
>
> Fortune nomination.
For newer list members wondering what Rolf is talking about try:

library(fortunes) fortune() to get a flavor! There are many pearls of
wisdom.


>
> cheers,
>
> Rolf
>


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Peter Dalgaard-2

> On 30 Sep 2017, at 14:22 , Robert Baer <[hidden email]> wrote:
>
>
>
> On 9/29/2017 3:37 PM, Rolf Turner wrote:
>> On 30/09/17 07:45, [hidden email] wrote:
>>
>> <SNIP>
>>
>>>
>>> The conceptual paradigm for R is only marginally commensurate with
>>> that of
>>> standard statistical software.
>>> You must immerse yourself in R to become proficient.
>>
>> Fortune nomination.
> For newer list members wondering what Rolf is talking about try:
>
> library(fortunes) fortune() to get a flavor! There are many pearls of
> wisdom.
>

Also, to get roughly back on topic, try

fortune("SAS")

several times, or more quickly

fortune("reverse the procedure")
fortune("Poalis")

-pd

>
>>
>> cheers,
>>
>> Rolf
>>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Rolf Turner
In reply to this post by Robert Baer
On 01/10/17 01:22, Robert Baer wrote:

>
>
> On 9/29/2017 3:37 PM, Rolf Turner wrote:
>> On 30/09/17 07:45, [hidden email] wrote:
>>
>> <SNIP>
>>
>>>
>>> The conceptual paradigm for R is only marginally commensurate with
>>> that of
>>> standard statistical software.
>>> You must immerse yourself in R to become proficient.
>>
>> Fortune nomination.
> For newer list members wondering what Rolf is talking about try:
>
> library(fortunes) fortune() to get a flavor! There are many pearls of
> wisdom.

For the *really* new members, note that you may have to *install* the
fortunes package first:

 > install.packages("fortunes",lib=<wherever you keep added-on packages>)

Note that the package is "fortunes" (with an "s") but the function is
fortune() (no "s").

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

R help mailing list-2
And appropriatesly
> library(fortunes) > fortune()

SAS seems to be to statistical computing what Microsoft is to personal
computing.
   -- Bill Venables
      'Exegeses on Linear Models' paper (May 2000)

    On Saturday, September 30, 2017, 4:57:23 PM EDT, Rolf Turner <[hidden email]> wrote:  
 
 On 01/10/17 01:22, Robert Baer wrote:

>
>
> On 9/29/2017 3:37 PM, Rolf Turner wrote:
>> On 30/09/17 07:45, [hidden email] wrote:
>>
>> <SNIP>
>>
>>>
>>> The conceptual paradigm for R is only marginally commensurate with
>>> that of
>>> standard statistical software.
>>> You must immerse yourself in R to become proficient.
>>
>> Fortune nomination.
> For newer list members wondering what Rolf is talking about try:
>
> library(fortunes) fortune() to get a flavor! There are many pearls of
> wisdom.

For the *really* new members, note that you may have to *install* the
fortunes package first:

 > install.packages("fortunes",lib=<wherever you keep added-on packages>)

Note that the package is "fortunes" (with an "s") but the function is
fortune() (no "s").

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

andrewharmon42
In reply to this post by Peter Dalgaard-2
I have no problem setting up my mixed model, or performing anova or lsmeans
on my model’s outputs. However, performing lsd mean separation is giving me
fits.



So I do not have a problem when using two-way anova model. When using the
code:

fit.yield.add <- lm(data = ryzup, Yield ~ Rep + Nitrogen + Treatment)

LSD.test(fit.yield.add, trt = "Nitrogen", alpha = 0.1, console = TRUE)



It works beautifully. However when I run a mixed model:



yield.lmer <- lmer(data = ryzup, Yield ~ Nitrogen + Treatment +
(1|Rep/Nitrogen), REML = FALSE)

LSD.test(yield.lmer, trt = "Nitrogen", alpha = 0.1, console = TRUE)



It gives me fits. It produces errors like:



Error in as.data.frame.default(x[[i]], optional = TRUE) :

  cannot coerce class "structure("merModLmerTest", package = "lmerTest")"
to a data.frame


Do you have any suggestions for that?

Thanks

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Converting SAS Code

Mitchell Maltenfort
I believe the lmerTest package's "difflsmeans" is what you need.

On Wed, Oct 11, 2017 at 2:33 PM, Andrew Harmon <[hidden email]>
wrote:

> I have no problem setting up my mixed model, or performing anova or lsmeans
> on my model’s outputs. However, performing lsd mean separation is giving me
> fits.
>
>
>
> So I do not have a problem when using two-way anova model. When using the
> code:
>
> fit.yield.add <- lm(data = ryzup, Yield ~ Rep + Nitrogen + Treatment)
>
> LSD.test(fit.yield.add, trt = "Nitrogen", alpha = 0.1, console = TRUE)
>
>
>
> It works beautifully. However when I run a mixed model:
>
>
>
> yield.lmer <- lmer(data = ryzup, Yield ~ Nitrogen + Treatment +
> (1|Rep/Nitrogen), REML = FALSE)
>
> LSD.test(yield.lmer, trt = "Nitrogen", alpha = 0.1, console = TRUE)
>
>
>
> It gives me fits. It produces errors like:
>
>
>
> Error in as.data.frame.default(x[[i]], optional = TRUE) :
>
>   cannot coerce class "structure("merModLmerTest", package = "lmerTest")"
> to a data.frame
>
>
> Do you have any suggestions for that?
>
> Thanks
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.