similar to: why isn't integrate function working in a likelihood

Displaying 20 results from an estimated 500 matches similar to: "why isn't integrate function working in a likelihood"

2012 Oct 20
4
Error in integrate(integrand, 0, Inf) : non-finite function value
Dear R users, When I run the code below, I get the error "Error in integrate(integrand, 0, Inf) : non-finite function value". The code works if the function returns only "sum(integ)". However, I want to add "cmh" to it. When I add "cmh" I get that error. I can't figure out why this is happening because my integrate function has nothing to do with
2012 Oct 17
1
for loop output
Dear R users, In the code below, I am trying to print the result of my loop function. The output first gives me the result for k=1, and then for k=1 and k=2. I only want the last output which is [,1] [,2] [1,] 0.1700065 0.5002659 [2,] 0.3080273 0.4954731 [3,] 0.4844886 0.4544306 [4,] 0.5062987 0.1868154 [5,] 0.5846982 0.4353522 [6,] 0.4332621 0.2202922 [7,] 0.4391985
2013 Apr 01
2
Timing of SET_VECTOR_ELT
Assume a C program invoked by .Call, that returns a list. Near the top of the program we allocate space for all the list elements. (It is my habit to use "xyz2" for the name of the R object and "xyz" for the pointer to its contents.) PROTECT(means2 = allocVector(REALSXP, nvar)); means = REAL(means2); PROTECT(u2 = allocVector(REALSXP, nvar)); u =
2012 May 13
1
how to write data using xlsReadWrite
Hai I'm Dee. I'm trying to write var data from these codes inside excel file. My directory to store the data is *D:\FYP\image* . these are my codes, can you help give an advice or idea with my problem: l*ibrary("biOps") library("waveslim") library("xlsReadWrite") x <- readTiff("D:\\FYP\\image\\SignatureImage\\user186g1.tif") y <-
2012 May 13
4
write data using xlsReadWrite
Hai, I'm trying to write these var output data from these codes inside excel file. My directory to store the data is /D:\FYP\image / but receive an error message : /Error in write.xls(mydata, "D:\\FYP\\image.mydata.xls") : object 'mydata' not found/ these are my codes, can you help give an advice or idea with my problem: /library("biOps")
2012 Oct 26
3
how to make simulation faster
Dear R users, I need to run 1000 simulations to find maximum likelihood estimates. I print my output as a vector. However, it is taking too long. I am running 50 simulations at a time and it is taking me 30 minutes. Once I tried to run 200 simulations at once, after 2 hours I stopped it and saw that only about 40 of them are simulated in those 2 hours. Is there any way to make my simulations
2006 Jan 25
0
Log-Likelihood 3d-plot and contourplot / optim() starting values
Hello, i have coded the following loglikelihood-function # Log-Likelihood-Funktion loglik_jm<-function(N,phi,t) { n<-length(t) i<-seq(along=t) s1<-sum(log(N-(i-1))) s2<-phi*sum((N-(i-1))*t[i]) n*log(phi)+s1-s2 } # the data t<-c(7,11,8,10,15,22,20,25,28,35) # now i want to do a 3d-plot and a contourplot in order to see at which values of N and phi the loglikelihood
2006 Feb 15
1
Multiple comparison for circular data
Hi All, Does anyone know how to compare the means of several circular-data samplings? Any related websites, references and softwares? Thanks Xiaohua -- Xiaohua Dai, Dr. [[alternative HTML version deleted]]
2006 Jan 14
1
Different length of objects
Hello, i got an warning message in the following code: f<-1:100 t<-1:100 b<-100 ll2 <- function(b,f,t) { t<-cumsum(t) tn<-t[length(t)] i<-seq(along=f) s1<-(tn*exp(-b*tn)*sum(f[i]))/(1-exp(-b*tn)) s2<-sum((f[i]*(t[i]*exp(-b*t[i])-t[i-1]*exp(b*t[i-1])))/(exp(-b*t[i-1])-exp(-b*t[i]))) s1-s2 } ll2(b,f,t) i think, the problem here is, that t[0] doesn't
2012 Oct 19
2
likelihood function involving integration, error in nlm
Dear R users, I am trying to find the mle that involves integration. I am using the following code and get an error when I use the nlm function d<-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2) h<-matrix(runif(20,0,1),10) integ<-matrix(c(0),nrow=10, ncol=2) ll<-function(p){ for (k in 1:2){ for(s in 1:10){ integrand<-function(x)
2002 Apr 22
3
glm() function not finding the maximum
Hello, I have found a problem with using the glm function with a gamma family. I have a vector of data, assumed to be generated by a gamma distribution. The parameters of this gamma distribution are estimated in two ways (i) using the glm() function, (ii) "by hand", using the optim() function. I find that the -2*likelihood at the maximum found by (i) is substantially larger than that
2017 Dec 21
0
Fitting Beta Distribution
I answer my own question: I had overlooked the fact that the normalization factor is also a function of the parameters I want to optimise, hence I should write dbeta2 <- function(x, shape){ res <- x^(shape-1)*(1-x)^(shape-1)/beta(shape, shape) return(res) } after which the results are consistent. ---------- Forwarded message ---------- From: Lorenzo Isella <lorenzo.isella
2017 Dec 21
1
Fitting Beta Distribution
Dear All, I need to fit a custom probability density (based on the symmetric beta distribution B(shape, shape), where the two parameters shape1 and shape2 are identical) to my data. The trouble is that I experience some problems also when dealing with the plain vanilla symmetric beta distribution. Please consider the code at the end of the email. In the code, dbeta1 is the density of the beta
2011 Jan 06
4
Different LLRs on multinomial logit models in R and SPSS
Hello, after calculating a multinomial logit regression on my data, I compared the output to an output retrieved with SPSS 18 (Mac). The coefficients appear to be the same, but the logLik (and therefore fit) values differ widely. Why? The regression in R: set.seed(1234) df <- data.frame( "y"=factor(sample(LETTERS[1:3], 143, repl=T, prob=c(4, 1, 10))), "a"=sample(1:5,
2008 Feb 15
0
Behaviour of integrate (was 'Poisson-lognormal probability calcul ations')
Hi again, Adding further information to my own query, this function gets to the core of the problem, which I think lies in the behaviour of 'integrate'. ------------------------------------- function (x, meanlog = 0, sdlog = 1, ...) { require(stats) integrand <- function(t, x, meanlog, sdlog) dpois(x,t)*dlnorm(t, meanlog, sdlog) mapply(function(x, meanlog, sdlog, ...) #
2008 Feb 18
0
Solved (??) Behaviour of integrate (was 'Poisson-lognormal probab ility calculations')
Hi Again, I think I've solved my problem, but please tell me if you think I'm wrong, or you can see a better way! A plot of the integrand showed a very sharp peak, so I was running into the integrand "feature" mentioned in the note. I resolved it by limiting the range of integration as shown here: -------------------------------------------------- function (x, meanlog = 0,
2008 Feb 15
0
Poisson-lognormal probability calculations
Hi, just for the record, although I don't think it's relevant (!) ------------------------------------- > sessionInfo() R version 2.6.0 (2007-10-03) i386-pc-mingw32 locale: LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats4 splines
2011 Nov 10
2
performance of adaptIntegrate vs. integrate
Dear list, [cross-posting from Stack Overflow where this question has remained unanswered for two weeks] I'd like to perform a numerical integration in one dimension, I = int_a^b f(x) dx where the integrand f: x in IR -> f(x) in IR^p is vector-valued. integrate() only allows scalar integrands, thus I would need to call it many (p=200 typically) times, which sounds suboptimal. The
2012 May 23
0
Error from using adaptIntegrate within a function that is then integrated
I want to measure the error in the estimation of a 2 dimensional density function that is calculated using an integral but run into problems trying to integrate with adaptIntegrate because the integrand also calls the function adaptIntegrate. In particular I want \int \hat{f}(x,y) - f(x,y) dx dy where \hat{f}(x,y) = \int K(a,b, x, y) da db and in this simulation study I know what the true value
2008 Aug 26
2
Problem with Integrate for NEF-HS distribution
I need to calcuate the cumulative probability for the Natural Exponential Family - Hyperbolic secant distribution with a parameter theta between -pi/2 and pi/2. The integration should be between 0 and 1 as it is a probability. The function "integrate" works fine when the absolute value of theta is not too large. That is, the NEF-HS distribution is not too skewed. However, once the