[R] R: Confidence Intervals for logistic regression

2010-08-06 Thread Guazzetti Stefano
a closer look to the help on predict.glm will reveal that the function 
accepts a 'type' argument.
In you case 'type = response' will give you the results in probabilities
(that it seems to be what you are looking for).
There also is an example on use of the 'type' argument at the end of the
page.

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di Troy S
Inviato: Friday, August 06, 2010 6:31 PM
A: Michael Bedward
Cc: r-help@r-project.org
Oggetto: Re: [R] Confidence Intervals for logistic regression


Michael,

Thanks for the reply.  I believe Aline was sgiving me CI's on coefficients
as well.

So c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
pred$se.fit) gives me the CI on the logits if I understand correctly?  Maybe
the help on predict.glm can be updated.

Thanks!

On 6 August 2010 01:46, Michael Bedward michael.bedw...@gmail.com wrote:

 Sorry about earlier reply - didn't read your email properly (obviously :)

 You're suggestion was right, so as well as method for Aline below,
 another way of doing the same thing is:

 pred - predict(y.glm, newdata= something, se.fit=TRUE)
 ci - matrix( c(pred$fit + 1.96 * pred$se.fit, pred$fit - 1.96 *
 pred$se.fit), ncol=2 )

 lines( something, plogis( ci[,1] ) )
 lines( something, plogis( ci[,2] ) )



 On 6 August 2010 18:39, aline uwimana rwan...@gmail.com wrote:
  Dear Troy,
  use this commend, your will get IC95% and OR.
 
   logistic.model - glm(formula =y~ x1+x2, family = binomial)
  summary(logistic.model)
 
  sum.coef-summary(logistic.model)$coef
 
  est-exp(sum.coef[,1])
  upper.ci-exp(sum.coef[,1]+1.96*sum.coef[,2])
  lower.ci-exp(sum.coef[,1]-1.96*sum.coef[,2])
 
  cbind(est,upper.ci,lower.ci)
 
  regards.
 
  2010/8/6 Troy S troysocks-tw...@yahoo.com
 
  Dear UseRs,
 
  I have fitted a logistic regression using glm and want a 95% confidence
  interval on a response probability.  Can I use
 
  predict(model, newdata, se.fit=T)
 
  Will fit +/- 1.96se give me a 95% of the logit?  And then
  exp(fit +/- 1.96se) / (exp(fit +/- 1.96se) +1) to get the probabilities?
 
  Troy
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03).


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R: Function to check if a vector contains a given value?

2009-09-23 Thread Guazzetti Stefano
?any
any(x==2)

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di Dimitri Liakhovitski
Inviato: mercoledì 23 settembre 2009 17.38
A: R-Help List
Oggetto: [R] Function to check if a vector contains a given value?


Dear R'rs,

is there a function that checks if a given vector contains a certain value.
E.g., x-c(1,2,3,4).
How can I get a TRUE or FALSE for whether x contains a 2?

-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03).


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R: Deleting repeated rows

2009-06-26 Thread Guazzetti Stefano
?unique
as an example
 mat-matrix(c(1,2,3,1,1,2,1,2,3,4,7,5), ncol=3, byrow=T)
 mat #rows 1 and 3 are identical
 [,1] [,2] [,3]
[1,]123
[2,]112
[3,]123
[4,]475

 unique(mat)
 [,1] [,2] [,3]
[1,]123
[2,]112
[3,]475

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di dreamworx
Inviato: venerdì 26 giugno 2009 15.10
A: r-help@r-project.org
Oggetto: [R] Deleting repeated rows



Appologies if this is a simple problem. I have a matrix which is 86x3 and
each row contains three integers. The problem I have is that some of the
rows of integers are repeated in other rows and I only wish to have one copy
of these rows.

Is there a function that I can use which will identify these repeated rows
and delete them from the matrix? I have searched for help with this problem
but the only function I have found is 'grep' which I'm not sure is of any
use.
-- 
View this message in context: 
http://www.nabble.com/Deleting-repeated-rows-tp24219989p24219989.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03).


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R: Creating this vector, any suggetions?

2009-06-12 Thread Guazzetti Stefano
try this
 
  a-c(1, 6, 8, 9)
  1*(1:10 %in% a)
 [1] 1 0 0 0 0 1 0 1 1 0

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di njhuang86
Inviato: Friday, June 12, 2009 4:45 PM
A: r-help@r-project.org
Oggetto: [R] Creating this vector, any suggetions?



Suppose I have the first vector: c(1, 6, 8, 9)

I will like to create a second vector of size 10 composed of 0 and 1's. The
second vector will be composed of four 1's and six 0's. The position of the
1's will be specificed by the first vector. So essentially, I want a second
vector in the form:

c(1, 0, 0, 0, 0, 1, 0, 1, 1, 0)

Any help is greatly appreciated!
-- 
View this message in context: 
http://www.nabble.com/Creating-this-vector%2C-any-suggetions--tp24000348p24000348.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03).

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R: Replace values according to conditions

2008-04-09 Thread Guazzetti Stefano
A short way (not necessairly the best way), using the coercion from
logical to numeric, could be:

(mydata-as.data.frame(matrix(sample(1:9, 12, repl=T), ncol=4)))

 -1*(mydata =3) + (mydata =6)

For the second question start here:
 
help(Logic, package=base)  


Stefano

-Messaggio originale-
Da: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] conto di Suhaila Zainudin
Inviato: mercoledì 9 aprile 2008 9.32
A: r-help@r-project.org
Oggetto: [R] Replace values according to conditions


Greetings R-users,

I have the following data called mydata in a data.frame

Col1 Col2 Col3 Col4 Col5
1   2 46  7
8   8 73  5
4  4  56  7

I want to replace the data according to the following conditions

Condition 1   if data = 3, replace with -1
Condition 2   if data =6, replace with 1
Condition 3if data = 4 or data =5, replace with 0

So the expected output for the example, would be
Col1 Col2 Col3 Col4 Col5
-1  -1 0   1  1
1   1 1   -1 0
0   0 11 1

I have thought of using replace with each conditions, for example I tried
the following

myrep - replace(mydata, mydat = 3, -1 )   #Condition 1

I would have to repeat the function replace for each of the conditions to
get the expected output.

My questions are:

1. I would like to know if there are better ways to achieve the expected
output?
2. What are the symbols for OR and AND in R?

Thanks for any feedback


-- 
Suhaila Zainudin

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.