Displaying 20 results from an estimated 60 matches for "shape2".
Did you mean:
shape
2012 Mar 15
2
Integrate inside function
Dear R users,
first I take this opportunity to greet all the R community for your
continuous efforts.
I wrote a function to calculate the pdf and cdf of a custom distribution
(mixed gamma model).
The function is the following:
pmixedgamma3 <- function(y, shape1, rate1, shape2, rate2, prev)
{
density.function<-function(x)
{
shape1=shape1
rate1=rate1
shape2=shape2
rate2=rate2
prev=prev
fun<-prev*((rate1^shape1)/gamma(shape1)*(x^(shape1-1))*exp(-rate1*x))
+ (1-prev)*((rate2^shape2)/gamma(shape2)*(x^(shape2-1))*exp(-rate2*x))
return(fun)
}
den<...
2011 Aug 01
3
Beta fit returns NaNs
...ortant to me and i
don't know whom should i ask.
So as noted before when I do a parameter fit to the beta distr i get:
fitdist(vectNorm,"beta");
Fitting of the distribution ' beta ' by maximum likelihood
Parameters:
estimate Std. Error
shape1 2.148779 0.1458042
shape2 810.067515 61.8608126
Warning messages:
1: In dbeta(x, shape1, shape2, log) : NaNs produced
2: In dbeta(x, shape1, shape2, log) : NaNs produced
3: In dbeta(x, shape1, shape2, log) : NaNs produced
4: In dbeta(x, shape1, shape2, log) : NaNs produced
5: In dbeta(x, shape1, shape2, log) : NaNs produced...
2018 Jul 12
2
Problemas con la funcion "apply"
...scribo para ver si me podeis ayudar con un asunto en el que me he quedado un poco encallado.
Lo que tengo que hacer es sacar los percentiles (0.001, 0.005, 0.95 y 0.999) de varias distribuciones beta, concretamente 418. Cada distribucion esta definida por los parametros "shape1" y "shape2". Por lo tanto tengo una base de datos de 418 filas y en cada una de ellas los parametros que me definen la distribucion beta, shape1 y shape2.
Tengo el siguiente codigo:
distrname="beta"
shape1= 0.2 #ejemplo
shape2= 0.3 #ejemplo
quantvector=c(0.001,0.005,0.95,0.999)
(paste("...
2020 Mar 26
4
unstable corner of parameter space for qbeta?
...I can work
around this, but I'm curious why it happens and whether there's a better
workaround -- it doesn't seem to be in a particularly extreme corner of
parameter space. It happens, e.g., for these parameters:
phi <- 1.1
i <- 0.01
t <- 0.001
shape1 = i/phi ## 0.009090909
shape2 = (1-i)/phi ## 0.9
qbeta(t,shape1,shape2) ## 5.562685e-309
## brute-force uniroot() version, see below
Qbeta0(t,shape1,shape2) ## 0.9262824
The qbeta code is pretty scary to read: the warning "full precision
may not have been achieved" is triggered here:
https://github.com/wch/r-...
2007 Nov 13
1
TRUNCATED error with data frame
...cript as shown below:
aov.R
------
data1<-c(49,47,46,47,48,47,41,46,43,47,46,45,48,46,47,45,49,44,44,45,42,45,45,40
,49,46,47,45,49,45,41,43,44,46,45,40,45,43,44,45,48,46,40,45,40,45,47,40)
matrix(data1, ncol= 4, dimnames = list(paste("subj", 1:12),
c("Shape1.Color1",
"Shape2.Color1", "Shape1.Color2", "Shape2.Color2")))
Hays.df<-data.frame(rt = data1,
subj=factor(rep(paste("subj", 1:12, sep=""), 4)),
shape=factor(rep(rep(c("shape1","shape2"), c(12, 12)), 2)),
color=factor(rep(c("color1","...
2012 Aug 27
3
How to generate a matrix of Beta or Binomial distribution
Hi folks,
I have a question about how to efficiently produce random numbers from Beta
and Binomial distributions.
For Beta distribution, suppose we have two shape vectors shape1 and shape2.
I hope to generate a 10000 x 2 matrix X whose i th rwo is a sample from
reta(2,shape1[i]mshape2[i]). Of course this can be done via loops:
for(i in 1:10000)
{
X[i,]=rbeta(2,shape1[i],shape2[i])
}
However, the above code is time consuming. It would be better to directly
generate X without any loo...
2011 Jul 29
1
How to interpret Kolmogorov-Smirnov stats
Hi,
Interpretation problem ! so what i did is by using the:
>fit1 <- fitdist(vectNorm,"beta")
Warning messages:
1: In dbeta(x, shape1, shape2, log) : NaNs produced
2: In dbeta(x, shape1, shape2, log) : NaNs produced
3: In dbeta(x, shape1, shape2, log) : NaNs produced
4: In dbeta(x, shape1, shape2, log) : NaNs produced
5: In dbeta(x, shape1, shape2, log) : NaNs produced
6: In dbeta(x, shape1, shape2, log) : NaNs produced
##Is this a real...
2009 Jul 01
1
Plot cumulative probability of beta-prime distribution
...d")
but what about beta-prime? In R it exists only pbeta which is intended only
for the beta distribution (not beta-prime)
This is what I used for the estimation of the parameters:
mleBetaprime <- function(x,start=c(1,1)) {
mle.Estim <- function(par) {
shape1 <- par[1]
shape2 <- par[2]
BetaprimeDensity <- NULL
for(i in 1:length(posT))
BetaprimeDensity[i] <- posT[i]^(shape1-1) *
(1+posT[i])^(-shape1-shape2) / beta(shape1,shape2)
return(-sum(log(BetaprimeDensity)))
}
est <- optim(fn=mle.Estim,par=start,method="Nelder-Mead"...
2013 May 14
2
invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ with Rcpp.
...to binary ‘operator/’
make: *** [file74d8254b96d4.o] Error 1
Below is a mock function that can reproduce this error. I wonder if anyone
can tell me what is the problem here. Thank you in advance!!
foo<-cppFunction('
NumericVector foo(NumericVector q, NumericVector shape1, NumericVector
shape2, Function pbeta, Function sequence){
NumericVector output(q.size());
output=pbeta(sequence(q.size())/q.size(), shape1, shape2);
return output;
}
')
Best,
Xiao
[[alternative HTML version deleted]]
2006 Jul 04
1
problem getting R 2.3.1 svn r38481 to pass make check-all
...scale = 2)
logis(location = 4, scale = 2) PASSED
[1] TRUE
>
> dkwtest("t",df = 1)
t(df = 1) PASSED
[1] TRUE
> dkwtest("t",df = 10)
t(df = 10) PASSED
[1] TRUE
> dkwtest("t",df = 40)
t(df = 40) PASSED
[1] TRUE
>
> dkwtest("beta",shape1 = 1, shape2 = 1)
beta(shape1 = 1, shape2 = 1) PASSED
[1] TRUE
> dkwtest("beta",shape1 = 2, shape2 = 1)
beta(shape1 = 2, shape2 = 1) PASSED
[1] TRUE
> dkwtest("beta",shape1 = 1, shape2 = 2)
beta(shape1 = 1, shape2 = 2) PASSED
[1] TRUE
> dkwtest("beta",shape1 = 2, shape2 =...
2011 Apr 07
2
Two functions as parametrs of a function.
...fun2)
force(n)
p1<-unlist(par1)
p2<-unlist(par2)
force(p1)
force(p2)
localfun1 <- function() fun1(n, p1)
localfun2 <- function() fun2(n, p2)
vp<-replicate(nsim,t.test(localfun1(), localfun2())$p.value)
return(vp)
}
f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2))
Thank you for your help.
Kenneth
2020 Mar 26
0
unstable corner of parameter space for qbeta?
...whether there's a better
> workaround -- it doesn't seem to be in a particularly extreme corner of
> parameter space. It happens, e.g., for these parameters:
> phi <- 1.1
> i <- 0.01
> t <- 0.001
> shape1 = i/phi ## 0.009090909
> shape2 = (1-i)/phi ## 0.9
> qbeta(t,shape1,shape2) ## 5.562685e-309
> ## brute-force uniroot() version, see below
> Qbeta0(t,shape1,shape2) ## 0.9262824
> The qbeta code is pretty scary to read: the warning "full precision
> may not have been achieved" is...
2007 Mar 03
3
How to convert List object to function arguments?
......" to CDF function (for instance, see
ks.test above) in the "right form". The "..." is passed (to "goftests")
as a list object and it should be converted to an "argument list".
For instance:
##### BEGIN CODE SNIP #####
parms <- list( shape1 = 2, shape2 = 5 );
goftests( x, "beta", parms[["shape1"]], parms[["shape2"]] ); # Works!
goftests( x, "beta", parms ) # Don't Works!
parms <- list( aNum = 5, aVector = c(1,2,3), aMatrix =
matrix(c(4,5,6,7,8,9),nrow=2,byrow=T) );
goftests( x, "my-special-dis...
2013 Sep 18
1
dbeta may hang R session for very large values of the shape parameters
...rning: this will hang the R session
dbeta(0.9, 1e+308, 10)
Furthermore, through a trial and error investigation using the following code
## Warning: this will hang the R session
x <- 0.9
for (i in 0:100) {
a <- 1e+280*2^i
b <- 10
cat("shape1 =", a, "\n")
cat("shape2 =", b, "\n")
cat("Beta density", dbeta(x, shape1 = a, shape2 = b), "\n")
cat("===\n")
}
I noticed that:
* this seems to happen when shape1 is about 1e+308, seemingly irrespective of the value of shape2 (run the above with another value of b), and as i...
2013 Jan 22
2
Assistant
Good-day Sir,
I am R.Language users but am try to? estimate parameter of beta distribution particular dataset but give this error, which is not clear to me: (Initial value in "vmmin" is not finite)
beta.fit <- fitdistr(data,densfun=dbeta,shape1=value , shape2=value)
kindly assist.
expecting your reply:
2007 May 03
1
Bayesian logistic regression with a beta prior (MCMClogit)
...oda) and I want to put a beta prior on the parameters, but it's
giving me error message (please see output below) no matter what shape 1 or
2 I use. It works perfect with the cauchy or normal priors. Do you know if
there is a catch there somewhere? Thanks
logpriorfun <- function(beta,shape1,shape2){
sum(dbeta(beta,shape1,shape2, log=T)) }
posterior <- MCMClogit(nausea~nsaid*diuretic, data=w,
verbose=2000,burnin = 1000, mcmc = 10000,
user.prior.density=logpriorfun,shape1=1,shape2=1)
user.prior.density(beta.start) == -Inf.
Error in MCMClogit(nausea ~ nsaid * diuretic, data = w, verbose...
2003 Jul 04
1
Problem with fitdistr for beta
...<=1 ) with
a U-shaped histogram and try to fit a beta
distribution using fitdistr. In fact,
hist(rbeta(100,0.1,0.1)) looks a lot like
my data.
The equivalent to
the example in the manual
sometimes work:
> a <- rbeta(100,0.1,0.1)
> fitdistr(x=a, "beta", start=list(shape1=0.1,shape2=0.1))1)
> shape1 shape2
0.09444627 0.12048753
(0.01120670) (0.01550129)
but sometimes does not:
> a <- rbeta(100,0.1,0.1)
> fitdistr(x=a, "beta", start=list(shape1=0.1,shape2=0.1))1)
> Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) :
Fun...
2020 Oct 24
0
Fitting Mixed Distributions in the fitdistrplus package
...s correctly. By the way, the Feller-Pareto distribution (see actual) is among the best distributions for the Danish dataset. You may also consider composite distributions, see https://CRAN.R-project.org/view=Distributions
Kind regards, Christophe
dmixgam <- function(x, prob, shape1, scale1, shape2, scale2)
prob*dgamma(x, shape1, scale=scale1)+ (1-prob)*dpareto(x, shape2, scale=scale2)
pmixgam <- function(q, prob, shape1, scale1, shape2, scale2)
prob*pgamma(q, shape1, scale=scale1)+ (1-prob)*ppareto(q, shape2, scale=scale2)
library(actuar)
library(fitdistrplus)
data("danishuni&q...
2012 Mar 09
2
qbeta function in R
...o that the mean nausea rate is alpha/(alpha+beta)
> min<-10
> max<-60
> n<-as.integer(runif(3,min,max))
> for(i in 1:k)
+ x<-cbind(x,rbinom(5,n[i],p[i]))
>
> # Exact Confidence Interval
>
> l_cl_exact<-qbeta(.025, x, n-x+1)
Warning message:
In qbeta(p, shape1, shape2, lower.tail, log.p) : NaNs produced
> u_cl_exact<-qbeta(.975, x+1, n-x)
Warning message:
In qbeta(p, shape1, shape2, lower.tail, log.p) : NaNs produced
> x
[,1] [,2] [,3]
[1,] 8 12 14
[2,] 5 15 13
[3,] 5 12 12
[4,] 8 21 12
[5,] 8 14 12
> n
[1] 10...
2011 May 03
3
fitting distributions using fitdistr (MASS)
...a") : 'start' must be a named list
Yes, I do understand that sometime for the distribution to converge to the
given set of data, it requires initial parameters of the distribution, to
start off with. Hence, i tried this
>x1fitbeta<-fitdistr(x1,densfun=dbeta, start=list(shape1=2,shape2=3))
Error in optim(x = c(1.89074018737135, 1.52649293971978, 2.19950245230280,
:
initial value in 'vmmin' is not finite
I tried with "f" and "chi-square" what i did with "t". Please find below
the output.
> x1fitt<-fitdistr(x1,"t")
Error...