search for: pnorm

Displaying 20 results from an estimated 469 matches for "pnorm".

Did you mean: rnorm
2004 Aug 06
3
Bug in qnorm or pnorm?
I found the following strange behavior using qnorm() and pnorm(): > x<-8.21;x-qnorm(pnorm(x)) [1] 0.0004638484 > x<-8.22;x-qnorm(pnorm(x)) [1] 0.01046385 > x<-8.23;x-qnorm(pnorm(x)) [1] 0.02046385 > x<-8.24;x-qnorm(pnorm(x)) [1] 0.03046385 > x<-8.25;x-qnorm(pnorm(x)) [1] 0.04046385 > x<-8.26;x-qnorm(pnorm(x)) [1] 0.05046385...
2011 Feb 21
1
question about solving equation using bisection method
Hi all, I have the following two function f1 and f2. f1 <- function(lambda,z,p1){ lambda*(p1*exp(-3*z-9/2)+(0.2-p1)*exp(4*z-8))-(1-lambda)*0.8} f2 <- function(p1,cl, cu){ 0.8*(pnorm(cl)+(1-pnorm(cu)))/(0.8*(pnorm(cl)+(1-pnorm(cu)))+p1*(pnorm(cl+3)+(1-pnorm(cu+3)))+(0.2-p1)*(pnorm(cl-4)+(1-pnorm(cu-4))))}-0.05 First fix p1 to be 0.15. (i) choose a lambda value, say lamda=0.6, (ii) there should be two solutions for the equation f1(z, p1=0.15, lambda=1)=0, say cl and cu, (iii) e...
2009 Dec 08
4
lower.tail option in pnorm
Hi, I would have thought that these two constructions would produce the same result but they do not. Resp <- rbinom(10, 1, 0.5) Stim <- rep(0:1, 5) mm <- model.matrix(~ Stim) Xb <- mm %*% c(0, 1) ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb))) pnorm(as.vector(Xb), lower.tail = Resp, log.p = TRUE) > ifelse(Resp, log(pnorm(Xb)), log(1 - pnorm(Xb))) [1] -0.6931472 -1.8410216 -0.6931472 -0.1727538 -0.6931472 [6] -0.1727538 -0.6931472 -1.8410216 -0.6931472 -1.8410216 > pnorm(as.vector(Xb), lower.tail = Res...
2009 Jul 17
2
how to evaluate character vector within pnorm()
Hi, I'm trying to evaluate a character vector within pnorm. I have a vector with values and names x = c(2,3) names(x) = c("mean", "sd") so that i tried the following temp = paste(names(x), x, sep = "=") #gives #> temp #[1] "mean=2" "sd=3" #Problem is that both values 2 and 3 are taken as values for...
2004 Jun 16
2
erf function documentation
Hi all. I may be wrong, (and often am), but in trying to determine how to calculate the erf function, the documentation for 'pnorm' states: ## if you want the so-called 'error function' erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 ## and the so-called 'complementary error function' erfc <- function(x) 2 * pnorm(x * sqrt(2), lower=FALSE) Should, instead, it read: ## if you want the so-called 'er...
2011 Sep 11
3
(no subject)
...this program does not seem to match the answer I have. Can some one give me some hint? Thank you very much. Hannah u1 <- -3 u2 <- 4 f1 <- function(lambda,z,p1){ lambda*(p1*exp(u1*z-u1^2/2)+(0.2-p1)*exp(u2*z-u2^2/2))-(1-lambda)*0.8} f2 <- function(p1,cl, cu){ 0.8*(pnorm(cl)+(1-pnorm(cu)))/(0.8*(pnorm(cl)+(1-pnorm(cu)))+p1*(pnorm(cl- u1)+(1-pnorm(cu-u1)))+(0.2-p1)*(pnorm(cl-u2)+(1-pnorm(cu-u2))))} p1 <- 0.15 lam <- seq(0.01,0.99, by=0.001) x1 <- numeric(length(lam)) for (i in 1:length(lam)){ cl <- uniroot(f1, lower =-10, upper = 0,...
2009 Mar 10
6
Pseudo-random numbers between two numbers
I would like to generate pseudo-random numbers between two numbers using R, up to a given distribution, for instance, rnorm. That is something like rnorm(HowMany,Min,Max,mean,sd) over rnorm(HowMany,mean,sd). I am wondering if dnorm(runif(HowMany, Min, Max), mean, sd) is good. Any idea? Thanks. -james
2008 Feb 07
5
pnorm
Dear R list, I calculated a two-sided p values according to 2*(1-pnorm(8.104474)), which gives 4.440892e-16. However, it appears to be 5.30E-16 by a colleague and 5.2974E-16 from SAS. I tried to get around with mvtnorm package but it turns out to be using pnorm for univariate case. I should have missed some earlier discussions, but for the moment is there any short...
2010 May 13
1
results of pnorm as either NaN or Inf
I stumbled across this and I am wondering if this is unexpected behavior or if I am missing something. > pnorm(-1.0e+307, log.p=TRUE) [1] -Inf > pnorm(-1.0e+308, log.p=TRUE) [1] NaN Warning message: In pnorm(q, mean, sd, lower.tail, log.p) : NaNs produced > pnorm(-1.0e+309, log.p=TRUE) [1] -Inf I don't know C and am not that skilled with R, so it would be hard for me to look into the code for pno...
2002 Feb 13
3
pnorm, relative accuracy in the tails
Dear R people The function below should be decreasing, convex, and tend to zero when x tends to infinity. curve((1-pnorm(x))/dnorm(x),from=0, to=9) >From the plot we see that for x between 8.0 and 8.3 the function is fluctuating. As far as I understand, this is due to the function pnorm() not being sufficiently accurate in the tails. I am using pnorm() in a way that has probably not been intended. So I guess t...
2008 Mar 06
3
1-pnorm values in a table
...534.83 4001.74 157.16 3736.93 484.60 59.25 HAI2 13272.48 1519.88 36.35 33.64 46.68 82.11 HAI3 12587.71 5686.94 656.62 572.29 351.60 136.91 HAI4 15240.81 10031.57 426.73 275.29 561.30 302.38 HAI5 15878.32 10517.14 18.93 22.00 16.91 21.17 I would like to find a way of finding the 1-pnorm of each value in the table based on the mean and sd of the data only in the column in which the value lies. I can do it using a for loop, but would like to know if it can be done using e.g. apply or something similar, so that the whole table is printed out with the 1-pnorm values. 1-pnorm(test[,1...
2005 Aug 30
2
about "pnorm"
As to the function"pnorm",the default degree of freedom(df) is infinite. I wanna know how to set the df as I want. Help on pnorm doesn't have df setting.The only choice are:"mean, sd, lower.tail, log.p",but no df. For instance: sample size=6 df=6-1=5 t value=9.143 I wanna to the corresponding p value...
2010 Jun 13
2
help with R
Hi all, I want to solve the following equation for x with rho <- 0.5 pnorm(-x)*pnorm((rho*dnorm(x)/pnorm(x)-x)/sqrt(1-rho^2))==0.05 Is there a function in R to do this? Thank you very much! Hannah [[alternative HTML version deleted]]
2012 Apr 24
2
Some Help Needed
...say greater than 25. The error message is "Error in integrate(temp, lower = 0, upper = 1, k, x, rho, m) : the integral is probably divergent". Can anyone give some help on resolving this. Thanks. Hannah m <- 100 alpha <- 0.05 rho <- 0.1 F0 <- function(y,x,rho){ pnorm((qnorm(x, lower.tail = F)-sqrt(rho)*qnorm(y, lower.tail = F))/sqrt(1- rho), lower.tail = F) } temp <- function(y,k,x,rho,m) { t <- F0(y=y, x=x, rho=rho) pbinom(q=k, size=m, prob=t, lower.tail = F, log.p = FALSE) } est <- function(k,x,rho,m) { integrate(temp, lower =...
2009 Feb 12
1
Optim
...arameter(p3) stayed as the initial value. below is the code: ## data da=c(418,401,416,360,411,425,537,379,484,388,486,380,394,363,405,383,392,363,398,526) ### initial values pars=c(392.25, 507.25, 0.80) p1=pars[1];p2=pars[2];p3=pars[3] ### Objective function mix.obj = function(p,x) { e =p[3]*(pnorm((x+1/2-p[1])/sqrt(p[1]))-pnorm((x-1/2-p[1])/sqrt(p[1]))) + (1-p[3])*(pnorm((x-1/2-p[2])/sqrt(p[2]))-pnorm((x-3/2-p[2])/sqrt(p[2]))) if (any(e<=0)) Inf else -sum(log(e)) } ### Calculate the first derivatives of the objective function. lmix2a = deriv(~ -log(p3*pnorm((x+1/2-p1)/sqrt(p1))-pnorm...
2004 May 15
2
questions about optim
Hi, I am trying to do parameter estimation with optim, but I can't get it to work quite right-- I have an equation X = Y where X is a gaussian, Y is a multinomial distribution, and I am trying to estimate the probabilities of Y( the mean and sd of X are known ), Theta1, Theta2, Theta3, and Theta4; I do not know how I can specify the constraint that Theta1 + Theta2 + Theta3 + Theta4 = 1 in
2006 Jul 02
1
workaround for numeric problems
Dear R-people, I have to compute C - -(pnorm(B)*dnorm(B)*B + dnorm(B)^2)/pnorm(B)^2 This expression seems to be converging to -1 if B approaches to -Inf (although I am unable to prove it). R has no problems until B equals around -28 or less, where both numerator and denominator go to 0 and you get NaN. A simple workaround I did was C <-...
2007 Sep 13
2
Reciprocal Mill's Ratio
I believe that this may be more appropriate here in r-devel than in r-help. The normal hazard function, or reciprocal Mill's Ratio, may be obtained in R as dnorm(z)/(1 - pnorm(z)) or, better, as dnorm(z)/pnorm(-z) for small values of z. The latter formula breaks dowm numerically for me (running R 2.4.1 under Windows XP 5.1 SP 2) for values of z near 37.4 or greater. Looking at the pnorm documentation I see that it is based on Cody (1993) and thence, going one step furth...
2007 Jun 08
2
pnorm how to decide lower-tail true or false
Hi to all, maybe the last question was not clear enough. I did not found any hints how to decide whether it should use lower.tail or not. As it is an extra R-feature ( written in http://finzi.psych.upenn.edu/R/Rhelp02a/archive/66250.html ) I do not find anything about it in any statistical books of me. Regards Carmen
2013 Oct 16
7
Is there something wrong with R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"?
Hi, pnorm(-1.53,0,1) under version 3.0.2 gives 0.05155075. I am pretty sure it should be 0.063. Is there something wrong with this version of R? I am using: R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (...