Skip to content

Convert SAS codes into R

2 messages · Muhammad Yaseen, Andrew Robinson

#
Hi Dear,

I'd highly appreciate if someone can help me to convert these SAS
codes into R. Thanks



?/*-------------------------------------------------------*/
?/*---Data Set 11.5, Uniformity Trial ? ? ? ? ? ? ? ? ?---*/
data spatvar;
?? input rep bloc row col yield;
?? datalines;
1 ? ?4 ? 1 ? 1 ? ? 10.5411
1 ? ?4 ? 1 ? 2 ? ? ?8.5806
1 ? ?2 ? 1 ? 3 ? ? 11.2790
..........................
..........................
..........................
4 ? 15 ? 7 ? 8 ? ? 10.4298
4 ? 14 ? 8 ? 5 ? ? ?7.3220
4 ? 14 ? 8 ? 6 ? ? 10.5104
4 ? 15 ? 8 ? 7 ? ? 12.6808
4 ? 15 ? 8 ? 8 ? ? 10.4482
;
?/*-------------------------------------------------------*/

?/*-------------------------------------------------------*/
?/*---Output 11.1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?---*/
title 'no nugget - spherical covariance model';
proc mixed data=spatvar;
?? model yield = ;
?? repeated / subject = intercept
?? ? ? ? ? ? ?type ? ?= sp(sph)(row col);
?? parms (0 to 10 by 2.5)
?? ? ? ? (1 to 10 by 3 ?);
?? ods select ParmSearch CovParms IterHistory
?? ? ? ? ? ? ?ConvergenceStatus FitStatistics LRT;
run;
?/*-------------------------------------------------------*/
?/*-------------------------------------------------------*/
?/*---Output 11.2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?---*/
title 'no nugget - exponential covariance model';
proc mixed data=spatvar;
?? model yield = ;
?? repeated / subject = intercept
?? ? ? ? ? ? ?type ? ?= sp(exp)(row col);
?? parms (0 to 10 by 2.5)
?? ? ? ? (1 to 10 by 3 ?);
?? ods select CovParms FitStatistics;
run;
proc mixed data=spatvar;
?? model yield = ;
?? repeated / subject = intercept
?? ? ? ? ? ? ?type ? ?= sp(gau)(row col);
?? parms (0 to 10 by 2.5)
?? ? ? ? (1 to 10 by 3 ?);
?? ods select CovParms FitStatistics;
run;
?/*-------------------------------------------------------*/
?/*-------------------------------------------------------*/
?/*---Output 11.3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?---*/
title 'rcb error model';
proc mixed data=spatvar;
?? class rep;
?? model yield = ;
?? random rep;
?? ods select CovParms FitStatistics;
run;

title 'incomplete block error model';
proc mixed data=spatvar;
?? class bloc;
?? model yield = ;
?? random bloc;
?? ods select CovParms FitStatistics;
run;
?/*-------------------------------------------------------*/
?/*-------------------------------------------------------*/
?/*---Outpuyt 11.4 a ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ---*/
title 'nugget effect - exponential covariance model';
proc mixed data=spatvar;
?? model yield = ;
?? repeated / subject = intercept
?? ? ? ? ? ? ?type ? ?= sp(exp)(row col)
?? ? ? ? ? ? ?local;
?? parms (0 ? ?to 10 ? ?by 2.5 )
?? ? ? ? (1 ? ?to 10 ? ?by 3 ? )
?? ? ? ? (0.05 to ?1.05 by 0.25);
?? ods select IterHistory ConvergenceStatus CovParms;
run;
?/*-------------------------------------------------------*/
?/*-------------------------------------------------------*/
?/*---Outpuyt 11.4 b ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ---*/
title 'nugget effect - exponential covariance model';
proc mixed data=spatvar convg=1e-7;
?? model yield = ;
?? repeated / subject = intercept
?? ? ? ? ? ? ?type ? ?= sp(exp)(row col)
?? ? ? ? ? ? ?local;
?? parms (0 ? ?to 10 ? ?by 2.5 )
?? ? ? ? (1 ? ?to 10 ? ?by 3 ? )
?? ? ? ? (0.05 to ?1.05 by 0.25);
?? ods select IterHistory ConvergenceStatus CovParms;
run;
?/*-------------------------------------------------------*/
?/*-------------------------------------------------------*/
?/*---Output 11.5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?---*/
data spatvar; set spatvar;
??obs = _n_;
run;
proc mixed data=spatvar convg=1e-7;
?? class obs;
?? model yield = ;
?? random obs / type=sp(exp)(row col);
?? parms (0 ? ?to 10 ? by 2.5 )
?? ? ? ? (1 ? ?to 10 ? by 3 ? )
?? ? ? ? (0.05 to 1.05 by 0.25);
?? ods select Dimensions IterHistory ConvergenceStatus
?? ? ? ? ? ? ?FitStatistics CovParms;
run;
?/*-------------------------------------------------------*/

--

Muhammad Yaseen
1 day later
#
Honestly, I don't think that this is a reasonable request.  That was
my initial reaction, but I wondered if I might just be being grumpy.
The long intervening silence implies that others think the same ... at
least some others ... 

So, Muhummad, apologies, but this is not a reasoanble request.  Good
luck finding a resolution elsewhere.

Andrew
On Fri, Oct 22, 2010 at 08:36:39PM -0700, Muhammad Yaseen wrote: