similar to: Function environments serialize to a lot of data until they don't

Displaying 20 results from an estimated 6000 matches similar to: "Function environments serialize to a lot of data until they don't"

2009 Mar 03
4
Writing R package and do.call
Dear R-Help, I have written a function, which in simplified format can be represented as: temp.fn <- function(my.mean,my.sd){ Parameters <- list(mean = my.mean, sd = my.sd) curve(do.call(dnorm,c(list(x), Parameters)), from = my.mean-my.sd, to = my.mean+my.sd) } This works as I want it do. Wishing to immortalise this function into my very own package however, results in the following
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
2010 Sep 09
5
Help on simple problem with optim
Dear all, I ran into problems with the function "optim" when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if anybody would help. The code is in the following and the data is in the attachment. da <-
2008 Jul 25
1
serialize() to via temporary file is heaps faster than doing it directly (on Windows)
Hi, FYI, I just notice that on Windows (but not Linux) it is orders of magnitude (below it's 50x) faster to serialize() and object to a temporary file and then read it back, than to serialize to an object directly. This has for instance impact on how fast digest::digest() can provide a checksum. Example: x <- 1:1e7; t1 <- system.time(raw1 <- serialize(x, connection=NULL));
2000 Nov 07
3
infinity in integrate function in R
sorry the integration was from -Inf to 1.96 The integrate function in R is not taking Inf (infinity). How do you use infinity in R. I was doing: integrate(dnorm,- Inf, 1.96) and I was getting Error: NA/NaN/Inf in foreign function call (arg 2). Obviously this should be equal to pnorm(1.96)= 0.9750021. How do you get around the infinity problem in R?
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.
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]
2010 Dec 02
4
Integral of PDF
The integral of any probability density from -Inf to Inf should equal 1, correct? I don't understand last result below. > integrate(function(x) dnorm(x, 0,1), -Inf, Inf) 1 with absolute error < 9.4e-05 > integrate(function(x) dnorm(x, 100,10), -Inf, Inf) 1 with absolute error < 0.00012 > integrate(function(x) dnorm(x, 500,50), -Inf, Inf) 8.410947e-11 with absolute error <
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:
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
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.
2006 Jan 25
4
D(dnorm...)?
Can someone help me understand the following: > D(expression(dnorm(x, mean)), "mean") [1] 0 > sessionInfo() R version 2.2.1, 2005-12-20, i386-pc-mingw32 attached base packages: [1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" [7] "base" By my computations, this should be
2007 Jan 21
5
Integration + Normal Distribution + Directory Browsing Processing Questions
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.
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 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.
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,
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 <-
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
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
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