Displaying 20 results from an estimated 800 matches similar to: "maximum likelihood, 1st and 2nd derivative"
2007 Jan 05
2
maximum likelihood estimation of 5 parameters
Hi Guys, it would be great if you could help me with a MLE problem in R.
I am trying to evaluate the maximum likelihood estimates of theta = (a1,
b1, a2, b2, P) which defines a mixture of a Poisson distribution and two
gamma prior distributions (where the Poisson means have a gamma
distribution, actually 2 gammas and P is the mixing factor). The likelihood
function for theta is L(theta) = Pi,j{P
2005 May 20
1
using src/Makevars file
Hi all,
Thanks to all who offered advice on using F95 in R.
Now I'm trying to compile a test package using gfortran, Linux 2.4.21 and
R 2.1.0.
I was able to successfully compile and use a test F95 routine by setting my
environment variables as follows in bash:
export PATH=~/bin/:$PATH
export F77=gfortran
export LD_LIBRARY_PATH=~/bin/irun/lib
export GFORTRAN_STDIN_UNIT=-1
Now I'm
2007 Oct 29
1
How to test combined effects?
Suppose I have a mixed-effects model where yij is the jth sample for
the ith subject:
yij= beta0 + beta1(age) + beta2(age^2) + beta3(age^3) + beta4(IQ) +
beta5(IQ^2) + beta6(age*IQ) + beta7(age^2*IQ) + beta8(age^3 *IQ)
+random intercepti + eij
In R how can I get an F test against the null hypothesis of
beta6=beta7=beta8=0? In SAS I can run something like contrast age*IQ
1,
2009 May 08
1
creation of a matrix
Hi all,
I have a relative large amount (several thousand rows, but a small
amount of unique objects) of data in a format like this:
1 text_string
1 text_string
1 text_string
2 text_string
2 text_string
3 text_string
3 text_string
3 text_string
3 text_string
3 text_string
.
.
.
n text_string
I want to create an n x p matrix, n objects (=40) and p unique text
strings. Nij is number of occurrences
2007 Jun 15
0
Question with nlm
Hi,
I would really appreciate if I could get some help here. I'm using nlm to minimize my negative log likelihood function. What I did is as follows:
My log likelihood function (it returns negative log likelihood) with 'gradient' attribute defined inside as follows:
# ==========Method definition======================
logLikFunc3 <- function(sigma, object, totalTime) {
y <-
2007 Jul 30
2
deriv, loop
Hi, 2 questions:
Question 1: example of what I currently do:
for(i in 1:6){sink("temp.txt",append=TRUE)
dput(i+0)
sink()}
x=scan(file="temp.txt")
print(prod(x))
file.remove("C:/R-2.5.0/temp.txt")
But how to convert the output of the loop to a vector that I can manipulate
(by prod or sum etc), without having to write and append to a file?
Question 2:
>
2011 May 12
2
DCC-GARCH model and AR(1)-GARCH(1,1) regression model
Hello,
I have a rather complex problem... I will have to explain everything in
detail because I cannot solve it by myself...i just ran out of ideas. So
here is what I want to do:
I take quotes of two indices - S&P500 and DJ. And my first aim is to
estimate coefficients of the DCC-GARCH model for them. This is how I do it:
library(tseries)
p1 = get.hist.quote(instrument =
2007 Jun 13
1
specify constraints in maximum likelihood
Hi,I know only mle function but it seems that in mle one can only specify the bound of the unknowns forming the likelihood function. But I would like to specify something like, a = 2b or a <= 2b where 'a' and 'b' could be my parameters in the likelihood function. Any help would be really appreciated. Thank you!- adschai
[[alternative HTML version deleted]]
2012 Sep 07
2
metafor package: study level variation
Hello. A quick question about incorporating variation due to study in the metafor package. I'm working with a particular data set for meta-analysis where some studies have multiple measurements. Others do not. So, let's say the effect I'm looking at is response to two different kinds of drug treatment - let's call their effect sizes T1 and T2. Some studies have multiple
2008 May 22
4
Binning groups
Hi, this is probably quite simple but I can't seem to do it correctly. I have
a data frame of counts of infections in different ages; something like:
count=c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 7, 8, 8, 9, 9,
10, 11, 15, 17, 17, 17, 17, 19, 19, 19, 19, 20, 20, 20, 21, 21,
21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 25, 27, 31, 33
)
age=c(3, 8, 9, 7, 56, 58, 10, 13, 53, 55, 11,
2008 Apr 18
3
Permanent change to the working directory
Dear helpers,
I've looked in the help files (maybe not very thoroughly but I looked) and I
couldn't find a straightforward way to permanently set the working directory
(where I save and read files). Each time I startup R the working dir is
automatically "C:/R/bin" [using:getwd()], and I know I can change it using
setwd [for example setwd("C:/R/DATA"), but it's only
2003 Oct 01
3
fitting Markov chains
I need to find a computationally simple process for the movement of
interest rates. In this simplified model, an interest rate can have
3--5 possible values, and its movement is characterized by a matrix of
transition probabilities (ie, it is a Markov process).
I would like to estimate this process from a given set of data.
For example, let the interest rate time series be:
7 3 8 2 5 9 6
2007 Nov 16
2
expand.grid overflows?
>cbn<-as.matrix(expand.grid( rep( list(0:1), 50)))
Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
invalid 'times' value
In addition: Warning message:
In rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
NAs introduced by coercion
But I'm only interested in cbn matrix rows where:
cbn<- cbn[rowSums(cbn)==5,]
Is there a way to evaluate it
2007 Apr 25
4
How to solve difficult equations?
This below is not solvable with uniroot to find "a":
fn=function(a){
b=(0.7/a)-a
(1/(a+b+1))-0.0025
}
uniroot(fn,c(-500,500)) gives
"Error in uniroot(fn, c(-500, 500)) : f() values at end points not of
opposite sign"
I read R-help posts and someone wrote a function:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/92407.html
but it is not very precise. Is there any
2007 Apr 19
3
A structured output from for(i...)?
Hello I am using the "for (i...)" and a sink() into a file. But the output I
am having is not arranged in either a vector or any other good structure. I
would like to have the output in a file directly as a vector so that I do
not have to edit the [1] and [6] etc and that the values are comma
separated. Is there a way? Thanks.
Example data:
x=read.table(file="pw.power.txt")
2008 Apr 21
1
Symbolic Integration in R
This may be a question to R-development but I'm not sure. Symbolic
differentiation is implemented in R (maybe not for extremely complex
expressions), but it proves that it can be done. I know that in C++ it can
be done (symbolic c++), do you think in R it can be programmed just using
the R language without resorting to external sources? Does anyone know or
can estimate the amount of resources
2007 May 14
1
Hierarchical models in R
Is there a way to do hierarchical (bayesian) logistic regression in R, the
way we do it in BUGS? For example in BUGS we can have this model:
model
{for(i in 1:N) {
y[i] ~ dbin(p[i],n[i])
logit(p[i]) <- beta0+beta1*x1[i]+beta2*x2[i]+beta3*x3[i]
}
sd ~ dunif(0,10)
tau <- pow(sd, -2)
beta0 ~ dnorm(0,0.1)
beta1 ~ dnorm(0,tau)
beta2 ~ dnorm(0,tau)
beta3 ~
2007 May 03
1
Bayesian logistic regression with a beta prior (MCMClogit)
Dear all,
I am trying to use the logistic regression with MCMClogit (package:
MCMCpack/Coda) 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){
2009 Jan 02
2
Where to find old R packages?
What happens to old R packages? Is there a place where they are stored like
an archive? I'm looking for a package called ScanoR that doesn't exist
anymore on CRAN, the author doesn't exist anymore... I had made copies of
all packages (fearing that some might be "taken off the air" but
unfortuantely the ScanoR package was removed before I started making copies
in 2007). Any
2011 Oct 06
2
KS test and theoretical distribution
> x <- runif(100)
> y <- runif(100)
> ks.test(x,y)
Two-sample Kolmogorov-Smirnov test
data: x and y
D = 0.11, p-value = 0.5806
alternative hypothesis: two-sided
ok I expected that, but:
> ks.test(runif(100), "runif")
One-sample Kolmogorov-Smirnov test
data: runif(100)
D = 0.9106, p-value < 2.2e-16
alternative hypothesis: two-sided
How