Displaying 20 results from an estimated 4000 matches similar to: "Margin annotation"
2009 Jul 25
4
graphs
Hello,
I am plotting two distributions and want to draw a vertical line at the
critical point 149.
How can I stop it from going further up than the norm(140,15) curve?
x<-seq(75,225,0.1)
plot(x,dnorm(x,mean=140, sd=15), type='l', col='navy')
abline(v = 149, col = "black")
curve(dnorm(x,mean=150, sd=15),from=75, to=225, col='orange', add=TRUE)
Thank you.
2012 Jul 24
4
Integrate(dnorm) with different mean and standard deviation help
I'm trying to provide different parameters to the integrate function for various probability functions. I'm using dnorm as the simplest example here. For instance integrate(dnorm, -1.96, 1.96) produces the correct answer for a normal distribution with mean 0 and standard deviation 1. I've tried two ways to use mean=2.0 and standard deviation 1, but with no luck. The examples follow.
2006 Apr 05
2
R2WinBUGS error
Dear R-help,
I'm using the R2WinBUGS package and getting an error message:
Error in file(file, "r") : unable to open connection
In addition: Warning message:
cannot open file 'codaIndex.txt', reason 'No such file or
directory'
I'm using R 2.2.1 and WinBUGS 1.4.1 on a windows machine (XP). My R code
and WinBUGS code is given below.
2003 Oct 31
4
dnorm() lead to a probability >1
Howdee,
One of my student spotted something I can't explain: a probability >1 vs a
normal probability density function.
> dnorm(x=1, mean=1, sd=0.4)
[1] 0.9973557
> dnorm(x=1, mean=1, sd=0.39)
[1] 1.022929
> dnorm(x=1, mean=1, sd=0.3)
[1] 1.329808
> dnorm(x=1, mean=1, sd=0.1)
[1] 3.989423
> dnorm(x=1, mean=1, sd=0.01)
[1] 39.89423
> dnorm(x=1, mean=1, sd=0.001)
[1]
2005 Feb 10
2
Curious Behavior with Curve() and dnorm()
I am attempting to wrap the histogram function in my own custom
function, so that I can quickly generate some standard plots.
A part of what I want to do is to draw a normal curve over the histogram:
> x <- rnorm(1000)
> hist(x, freq=F)
> curve(dnorm(x), lty=3, add=T)
(for normal use, x would be a vector of empirical values, but the
rnorm() function works for testing)
That
2009 Aug 24
1
problem with BRugs
Hello, I am sorry, I have this problem before and Uwe send me the answer but I misplaced it and can not find it.
writing a model for BRugs
> library(BRugs)
Loading required package: coda
Loading required package: lattice
Welcome to BRugs running on OpenBUGS version 3.0.3
> setwd("c:/tmp")
Error in setwd("c:/tmp") : cannot change working directory
> mo <-
2008 Mar 19
1
problem with optim and integrate
Dear all,
I want to min "integrate( (p1*dnorm+p2*dnorm+p3*dnorm)^(1.3))" for p, mu,
and sigma.
So, I have to estimate 8 parameters(p3=1-p1-p2).
I got this warning-"Error in integrate(numint, lower = -Inf, upper = Inf) :
non-finite function value."
My questions are
How could I fix it? I tried to divide into several intervals and sum up, but
I got same message.
My code is
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
2005 Dec 10
2
Problems with integrate
Hi,
Having a weird problem with the integrate function.
I have a function which calculates a loss density: I'd like to integrate
it to get the distribution.
The loss density function is:
lossdensity<-function(p,Beta,R=0.4){
# the second derivative of the PDF
# p is the default probability of the pool at which we are evaluating
the lossdensity
# Beta is the correlation with the market
2010 Sep 23
2
dnorm
Dear R-users
Idea:
Plot a dnorm line using specific mean/sd to complete a histogram (skewed). xs:range of y-values, ys: dnorm function
Problem:
I expected to multiply the ys function with the sample size (n=250-300). I was wondering about a factor between 12'000 and 30'000 to match the size of the dnorm line with the specific histogram.
Thanks
Sibylle
hist(Biotree[Ld,]$Height2008,
2006 Jan 20
2
big difference in estimate between dmvnorm and dnorm, how come?
Dear R community,
I was trying to estimate density at point zero of a multivariate
distribution (9 dimensions) and for this I was using a multinormal
approximation and the function dmvnorm , gtools package.
To have a sense of the error I tried to look the mismatch between a
unidimensional version of my distribution and estimate density at
point zero with function density, dmvnorm and dnorm.
At
2009 Dec 15
1
Help in R
Hello,
Can anyone give me some suggestion in term of calculating the sum below.
Is there a function in R that can help doing it faster?
x1, x2, ...xn where xi can be 0 or 1. I want to calculate the following:
sum{ beta[a+sum(xi), b+n-sum(xi) ]* [ (1-x1)dnorm(0,1)+x1dnorm(2,1) ]* [
(1-x2)dnorm(0,1)+x2dnorm(2,1) ]* ...* [ (1-xn)dnorm(0,1)+xndnorm(2,1) ] }
The sum in the beginning is over all
2007 Jan 12
1
incorrect result of deriv (PR#9449)
Full_Name: Joerg Polzehl
Version: 2.3.1
OS: x86_64, linux-gnu
Submission from: (NULL) (62.141.176.22)
I observed an incorrect behavior of function deriv when evaluating arguments of
dnorm
deriv(~dnorm(z,0,s),"z")
expression({
.value <- dnorm(z, 0, s)
.grad <- array(0, c(length(.value), 1), list(NULL, c("z")))
.grad[, "z"] <- -(z * dnorm(z))
2010 Nov 12
4
dnorm and qnorm
Hello all,
I have a question about basic statistics. Given a PDF value of 0.328161,
how can I find out the value of -0.625 in R? It is like reversing the dnorm
function but I do not know how to do it in R.
> pdf.xb <- dnorm(-0.625)
> pdf.xb
[1] 0.328161
> qnorm(pdf.xb)
[1] -0.444997
> pnorm(pdf.xb)
[1] 0.628605
Many thanks,
Edwin
--
View this message in context:
2011 Jun 25
1
integration function
Hi all,
Can anyone please take a look at the following two functions.
The answer does not seem to be right.
Thank you very much!
f1 <- function(x)
{integrand <- function (x, mu){
dnorm(x, mean=mu, sd=1)*dnorm(mu, mean=2, sd=1)
}
integrate(integrand, -Inf, Inf,x)$val
}
f2 <- function(x)
{integrand <- function (x, mu){
2003 Apr 10
1
how to estimate parameters of multimodal distribution
Dear all
Please, is there any function or package for dealing with multimodal distributions?
I try to fit multimodal distribution or more precisely to find out mixture of normal
distributions which can lead to my actual data.
I use optim to find (in that case) two parameters but what I want is to let the
function find out arbitrary number of normal distributions underlaying my actual
data
2010 Oct 29
2
plot pdf
I want to plot the unstadardized version of a normal plot. Can you explain why that is not working?
Dev.set(1)
xcrit=-1.645
cord.x <- c(-3,seq(-3,xcrit,0.01),xcrit)
cord.y <- c(0,dnorm(seq(-3,xcrit,0.01)),0) # what does final 0 do here?
curve(dnorm(x,0,1),xlim=c(-3,3),main='Normal PDF')
polygon(cord.x,cord.y,col='orange')
2011 Feb 17
1
Integration with an Indicator Function in R
Hi all,
I have some some problem with regard to finding the integral of a
function containing an indicator function.
please see the code below:
func1 <- function(x, mu){
(mu^2)*dnorm(x, mean = mu, sd = 1)*dgamma(x, shape=2)}
m1star <- function(x){
integrate(func1, lower = 0, upper = Inf,x)$val}
T <- function(x){
0.3*dnorm(x)/(0.3*dnorm(x)+0.7*m1star(x))}
func2 <-
2005 Nov 09
2
About: Error in FUN(X[[1]], ...) : symbol print-name too long
Hi,
I??m trying to use the Win2BUGS package from R and I have a similar problem
that reurns with the message:
Error in FUN(X[[1]], ...) : symbol print-name too long
But, there is no stray ` character in the file ( Sugestions given by: Duncan
Temple Lang <duncan>
Date: Mon, 26 Sep 2005 07:31:08 -0700 )
The progam in R is:
library(R2WinBUGS)
library(rbugs)
dat <-
2007 Apr 05
1
Plotting multiple curves with lattice graphs
Hi List,
I would like to plot multiple curves (parametric
density curves) in one plot.
For example:
# parameters for three normal density curves
parms =
data.frame(ID=c(1,2,3),mu=c(50,55,60),sigma=c(10,12,15))
# I can easily draw three normal density curves using
curve():
curve(dnorm(x,mean=parms$mu[1],sd=parms$sigma[1]),from=0,
to=150, ylab="density", col="red")