Displaying 20 results from an estimated 2000 matches similar to: "Brand new To R"
2005 Jan 30
1
t-test or conf interval with known variance?
Hello,
Is there a built-in test in R for hypothesis testing with samples of
known variance?
For example, I've got a set of data, a mean to compare against, and a
known variance, and I want to determine the p-value for which I can
reject the null hypothesis (mu_1 = mu_0) and accept the alternative
(mu_1 > mu_0). I've found that JMP and Minitab can both do this (in
JMP, it's a
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
> x<-8.27;x-qnorm(pnorm(x))
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
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)
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
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:
2011 Sep 11
3
(no subject)
Dear all,
Can anyone take a look at my program below?
There are two functions: f1 (lambda,z,p1) and f2(p1,cl, cu).
I fixed p1=0.15 for both functions. For any fixed value of lambda (between
0.01 and 0.99),
I solve f1(p1=0.15, lambda=lambda, z)=0 for the corresponding cl and cu
values.
Then I plug the calculated cl and cu back into the function f2.
Eventually, I want to find the lambda value
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 answer for a higher
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 the mean
argument in pnorm
pnorm(0,
2012 Apr 24
2
Some Help Needed
Dear all,
I need to do some calculation where the code used are below. I get
error message when I choose k to be large, 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
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
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]]
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
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
2008 Mar 06
3
1-pnorm values in a table
Hi,
I've read in a csv file (test.csv) which gives me the following table:
Hin1 Hin2 Hin3 Hin4 Hin5 Hin6
HAI1 9534.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
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 (32-bit)
--
Tom
[[alternative HTML version deleted]]
1998 Jan 06
1
IEEE 754 Style Arithmetic
I have been looking at the R mathematical library with a view to
making changes so that it will handle IEEE 754 entities like NaN and
+/- Inf. This appears to be not too hard and I am fairly well down
the path to converting the existing code (and simultaneously
converting some of the more suspect algorithms to something more
solid).
Q1:
I have looked at the Splus implementation and I have a bit
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 by using function "pnorm".
How can I do it?
Thanks a lot
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
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 <- ifelse(B > -25,
-(pnorm(B)*dnorm(B)*B