Re: [R] Integration + Normal Distribution + Directory Browsing Processing Questions

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Mon 22 Jan 2007 - 08:16:55 GMT

the reason is that is more natural to use pnorm(), which also should a more efficient approximation of the Normal integral than intgrate(), you may even use

diff(pnorm(0:1, mean = 0.5, sd = 1.2))

however, the point I meant to make was to use the '...' argument that can found in many R functions.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


> Thank you,
>
> both work fine. Why is pnorm to prefer?
>
> Nils
>
>
> Matthias Kohl schrieb:
>> Hi,
>>
>> why don't you use pnorm?
>> E.g.,
>>
>> pnorm(1, mean = 0.1, sd = 1.2) - pnorm(0, mean = 0.1, sd = 1.2)
>>
>> Matthias
>>
>> ----- original message --------
>>
>> Subject: Re: [R] Integration + Normal Distribution + Directory
>> Browsing Processing Questions
>> Sent: Sun, 21 Jan 2007
>> From: Dimitris Rizopoulos<Dimitris.Rizopoulos@med.kuleuven.be>
>>
>>
>>> you can use the `...' argument of integrate, e.g.,
>>>
>>> integrate(dnorm, 0, 1)
>>> integrate(dnorm, 0, 1, mean = 0.1)
>>> integrate(dnorm, 0, 1, mean = 0.1, sd = 1.2)
>>>
>>> look at ?integrate for more info.
>>>
>>> I hope it helps.
>>>
>>> Best,
>>> Dimitris
>>>
>>> ----
>>> Dimitris Rizopoulos
>>> Ph.D. Student
>>> Biostatistical Centre
>>> School of Public Health
>>> Catholic University of Leuven
>>>
>>> Address: Kapucijnenvoer 35, Leuven, Belgium
>>> Tel: +32/(0)16/336899
>>> Fax: +32/(0)16/337015
>>> Web: http://med.kuleuven.be/biostat/
>>> http://www.student.kuleuven.be/~m0390867/dimitris.htm
>>>
>>>
>>> Quoting Nils Hoeller <mail@nhoeller.de>:
>>>
>>>
>>>> Hi everyone,
>>>>
>>>> I am new to R, but it's really great and helped me a lot!
>>>>
>>>> But now I have 2 questions. It would be great, if someone can
>>>> help me:
>>>>
>>>> 1. I want to integrate a normal distribution, given a median and
>>>> sd.
>>>> The integrate function works great BUT the first argument has to
>>>> be a
>>>> function
>>>>
>>>> so I do integrate(dnorm,0,1) and it works with standard m. and
>>>> sd.
>>>>
>>>> But I have the m and sd given.
>>>>
>>>> So for fixed m and sd I work around with a new function mynorm
>>>>
>>>> mynorm <- function(n) {
>>>> ret <- dnorm(n,0.6,0.15)
>>>> ret
>>>> }
>>>>
>>>> for example.
>>>>
>>>> BUT what can I do for dynamic m and sd?
>>>> I want something like integrate(dnorm(,0.6,0.15),0,1), with the
>>>> first
>>>> dnorm parameter open for the
>>>> integration but fixed m and sd.
>>>>

>>>> I hope you can help me.
>>>>
>>>> 2. I am working with textfiles with rows of measure data.
>>>> read.table("file") works fine.
>>>>
>>>> Now I want R to read.table all files within a given directory and
>>>> process them one by the other.
>>>>
>>>> for(all files in dir xy) {
>>>> x <- read.table(nextfile)
>>>> process x
>>>> }
>>>>
>>>> Is that possible with R? I hope so. Can anyone give me a link to
>>>>
>>> examples.
>>>
>>>> Thanks for your help
>>>>
>>>> Nils
>>>>
>>>> ______________________________________________
>>>> 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
>>>
>>>> and provide commented, minimal, self-contained, reproducible
>>>> code.
>>>>
>>>>
>>>>
>>>
>>> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>>>
>>> ______________________________________________
>>> 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
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>
>> --- original message end ----
>>
>>
>> --
>> Dr. rer. nat. Matthias Kohl
>> Matthias.Kohl@stamats.de
>> www.stamats.de
>>
>>
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



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 and provide commented, minimal, self-contained, reproducible code. Received on Mon Jan 22 19:26:49 2007

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 Mon 22 Jan 2007 - 09:30:32 GMT.

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