Re: [R] logistic regression enquiry

From: John Fox <jfox_at_mcmaster.ca>
Date: Sun 04 Jun 2006 - 20:59:33 EST


Dear Bob,

If I follow this properly, this is just a binomial logistic regression, where, for each of your 26 observations, you have a certain number of "successes" (positive instances) and "failures" (negative ones).

Fitting a binomial logit model is easily accommodated by the glm() function. Probably the simplest approach is to prepare one observation for each study which has the number of successes and failures for that study, and put these together as the columns of a two-column matrix on the left-hand side of the model; on the right-hand-side you'd have the usual specification for a model formula. Thus, something like

model <- glm(cbind(successes, failures) ~ ..., family=binomial, data=Dataset)

(where the ... represents the RHS of your model) should do the trick.

I hope this helps,
 John

On Sun, 04 Jun 2006 20:39:29 +1000
 Bob Green <bgreen@dyson.brisnet.org.au> wrote:
> I am hoping for some advie regarding the following scenario.
>
> I have data from 26 studies that I wanted to analyse using logistic
> regression. Given the data was from studies and not individuals I was
>
> unsure how I would perform this in R. When analysed in SPSS,
> weighting was
> used so that each study was included twice. Where "use" occurred, a
> value
> of 1 was assigned and was weighted by the value for the variable
> "positive". In the second instance, where use did not occur a value
> of 0
> was assigned and was weighted by the variable "negative". Taking the
> first
> study below, use = 1 would be weighted by 28 and use =0, it would be
> weighted by 117 (the total study N =145). If this data is scrambled
> in
> transmission I can send a csv version.
>
> My questions:
>
> 1. is change required to the data format or is modification of the
> usual
> code required?
> 2. what is the best R package for performing logistic regression?
>
>
> Any assistance is much appreciated
>
> regards
>
> Bob Green
>
>
>
>
> In SPSS, each study was included I weighted the , though am unsure
> how I
> would format the data
>
>
> medyear where who dxbroad firstep standard age sex positive negative
> 89 3 2 1 0 0 31.5 71 28 117.00
> 98 2 2 1 0 1 48.0 62 15 72.00
> 98 4 1 1 0 0 45.2 61 42 57.00
> 89 3 0 1 0 1 28.7 63 19 48.00
> 99 2 2 1 0 1 34.7 73 27 73.00
> 88 3 0 1 0 1 30.6 58 26 57.00
> 94 1 1 1 0 1 36.3 81 70 124.00
> 96 3 1 1 0 1 40.0 57 27 40.00
> 96 2 2 1 0 1 33.1 64 9 41.00
> 88 2 0 1 1 0 29.5 47 30 202.00
> 98 1 2 0 0 1 39.3 60 246 734.00
> 97 4 0 0 0 1 38.4 67 17 85.00
> 92 3 0 1 0 1 34.3 67 15 127.00
> 88 2 0 1 0 1 46 9 90.00
> 85 3 0 1 0 1 30.3 64 58 87.00
> 94 3 0 1 0 1 38.8 47 47 126.00
> 88 3 0 1 0 1 33.8 54 25 134.00
> 92 3 0 1 1 1 67 157.00
> 90 3 0 1 1 1 26.0 52 17 101.00
> 90 3 0 1 0 0 39 32.00
> 90 2 0 1 0 1 36.1 38 10 173.00
> 90 2 0 1 0 1 38.9 53 64 383.00
> 97 2 0 1 0 1 31.5 61 12 52.00
> 99 1 1 1 0 1 25 56.00
> 100 4 1 1 0 1 45.0 62 46 270.00
> 101 2 0 1 0 1 32.4 100 33 92.00
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html



John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jun 04 21:06:46 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 04 Jun 2006 - 22:10:28 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.