[R] Questions about Probit Analysis

Allan Engelhardt allane at cybaea.com
Wed Nov 17 15:43:59 CET 2010


Sorry I am a bit late to this discussion, but I can't see if you ever 
got an answer.  Anyhow, on your first question:

On 31/10/10 19:14, Lorenzo Isella wrote:
> Dear All,
> I have some questions about probit regressions.
> I saw a nice introduction at
>
> http://bit.ly/bU9xL5
>
> and I mainly have two questions.
>
> (1) The first is almost about data manipulation. Consider the 
> following snippet
>
> [...]
> mydata <- read.csv(url("http://www.ats.ucla.edu/stat/r/dae/binary.csv"))
> names(mydata) <- c("outcome","x1","x2","x3")
>
> myprobit <- 
> glm(mydata$outcome~mydata$x1+mydata$x2+as.factor(mydata$x3), 
> family=binomial(link="probit"))
> [...]
> #Now assume I can make a regression only on x1
>
>
> myprobit2 <- glm(mydata$outcome~mydata$x1, 
> family=binomial(link="probit"))
> [...]
> Finally, I generate the data frame mydatanew (see some of its entries 
> below)
>
> > mydatanew
>     x1 successes failures
> 1  220         0        1
> 2  300         1        2
> 3  340         1        3
> 4  360         0        4
> 5  380         0        8
> [...................]
>
> where for every value of x1 I count the number of 0 and 1 outcomes 
> (namely number of failures and number of successes). [...] How can I 
> actually feed R with mydatanew to perform again a logistic regression 
> on x1 only?

myprobit3 <- glm(cbind(successes, failures) ~ x1, 
family=binomial(link="probit"), data = mydatanew )
all.equal(coef(myprobit2), coef(myprobit3), check.attributes = FALSE)
# [1] TRUE


Your second question we could discuss offline: it is not really an R 
question, but you might want to have a look at something like the MNP 
and perhaps survey packages.


Hope this helps a little.

Allan



More information about the R-help mailing list