[R] Proc Nnpar1way with D option - equivalent in R

Daniel Nordlund djnordlund at frontier.com
Tue Nov 13 08:13:45 CET 2012


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of SASandRlearn
> Sent: Monday, November 12, 2012 5:55 PM
> To: r-help at r-project.org
> Subject: [R] Proc Nnpar1way with D option - equivalent in R
> 
> I am trying to match SAS output with R.
> 
> I am using Proc Npar1way with D option to get KS test statistic.
>> Here X is a binary dependent variable and Y is the predicted
> probabilities;
> proc npar1way data = mydata D; class x; var y; run;
> 
> When i try this in R
> 
> 
> ks.test(x, fitted(y),alternative = c("two.sided"),exact = NULL) I get very
> different result compared to SAS.
> 
> I am new to R. Any help is appreciated. I think i am missing a datastep
> maybe ?
> 
> Thank you.
> 
> 
> 

To reproduce the SAS results in R, you need to specify the ks.test something like:

ks.test(y[x==1], y[x==0],alternative = c("two.sided"),exact = NULL)

I say something "like", because I don't know what the binary values for x are, so I just used 1 and 0.  If this doesn't help, then you need to provide some data and your actual results so that you have an actual reproducible example (see the posting guide).


Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA
 




More information about the R-help mailing list