[R] Binomial

Marc Schwartz marc_schwartz at me.com
Fri Sep 25 14:50:01 CEST 2009


On Sep 25, 2009, at 6:29 AM, Ashta wrote:

> Dear R-users,
>
> Suppose I have the following sample of data,
>
> 0   1   2  4  3
> 1   2   1  3  1
> 1   3   3  4  1
> 0   1   2  1  2
> 1   4   1  4  2
>  1   2   2  1  1
>
> The first variable is the response variable where 0 is defective and 1
> normal. The other four factors( x1,x2,x3,x4) that influence the  
> outcome. I
> want to fit a binomial model . How do I do that? I am guessing the  
> response
> variable should be transformed  but not sure which family of  
> transformation
> to use.
> It is easy to do it  in SAS but I just want to learn using R
>
> Any help is highly appreciated
>
> Ashta

Presuming that your reference to SAS is to PROC LOGISTIC, then in R  
you would use glm() with 'family = binomial'.

Using:

   help.search("logistic regression")

would get you a lot of hints.

See ?glm for more information, or alternatively, the lrm() function in  
Frank's 'rms' package on CRAN.

I would however hope that your actual working data set is much larger,  
as you don't have enough data above to support a single covariate,  
much less 4.

HTH,

Marc Schwartz




More information about the R-help mailing list