similar to: expm() within the Matrix package

Displaying 20 results from an estimated 2000 matches similar to: "expm() within the Matrix package"

2007 Mar 06
1
expm()
Can the expm function be used to calculate the exponential of a matrix where the matrix is multiplied by a vector in a data frame? For example for (i in 1:length(y)){ expmN<-expm(Q*y[i]) Q<-Matrix(c(1, 2, 3, 4), 2, 2) return(expmN) } Sorry I am new to R and I have been finding it difficult to get information on calculating Matrix exponentials in R. Many thanks in
2007 Mar 13
0
multiplying matrix by vector of times
On 8/3/07 22:12, "Gad Abraham" <g.abraham at ms.unimelb.edu.au> wrote: > Laura Hill wrote: >> >> >> On 7/3/07 00:15, "Gad Abraham" <g.abraham at ms.unimelb.edu.au> wrote: >> >>>> On 6 Mar 2007, at 08:54, Laura Hill wrote: >>>> >>>>> Hi, >>>>> >>>>> My name is
2007 Mar 06
2
Estimating parameters of 2 phase Coxian using optim
Hi, My name is Laura. I'm a PhD student at Queen's University Belfast and have just started learning R. I was wondering if somebody could help me to see where I am going wrong in my code for estimating the parameters [mu1, mu2, lambda1] of a 2-phase Coxian Distribution. cox2.lik<-function(theta, y){ mu1<-theta[1] mu2<-theta[2] lambda1<-theta[3]
2011 Aug 17
2
An example of very slow computation
This message is about a curious difference in timing between two ways of computing the same function. One uses expm, so is expected to be a bit slower, but "a bit" turned out to be a factor of >1000. The code is below. We would be grateful if anyone can point out any egregious bad practice in our code, or enlighten us on why one approach is so much slower than the other. The problem
2017 Feb 09
2
R CMD check error
Martyn, No, that didn't work. One other thing in the mix (which I don't think is the issue) is that I call one of the C-entry points of expm. So the DESCRIPTION file imports expm, the NAMESPACE file imports expm, and the init.c file is #include "R.h" #include "R_ext/Rdynload.h" /* Interface to expm package. */ typedef enum {Ward_2, Ward_1, Ward_buggy_octave}
2017 Feb 09
2
R CMD check error
Martin, I am aware of --vanilla; I use it myself for some testing. In this case R_LIBS_USER was set externally (part of my login) and does not involve any of the R scripts. That means it is inherited by any subprocess. For example: tmt1495% R --vanilla --no-environ R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 The R Foundation for Statistical Computing
2017 Feb 08
2
R CMD check error
I have a local library which depends on the expm library. The expm library is loaded into my personal space and I have the environment variable R_LIBS_USER set appropriately. The command "library(expm)" works just fine from the command line, and in fact the package works if I do the source() and dyn.load() commands by hand. The following sequence works: tmt% R CMD build
2017 May 09
2
registering Fortran routines in R packages
Dear list, I?m trying to register Fortran routines in randtoolbox (in srt/init.c file), see https://r-forge.r-project.org/scm/viewvc.php/pkg/randtoolbox/src/init.c?view=markup&root=rmetrics. Reading https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines and looking at what is done in stats package, I first thought that the following code will do the job:
2010 Dec 07
1
Using nlminb for maximum likelihood estimation
I'm trying to estimate the parameters for GARCH(1,1) process. Here's my code: loglikelihood <-function(theta) { h=((r[1]-theta[1])^2) p=0 for (t in 2:length(r)) { h=c(h,theta[2]+theta[3]*((r[t-1]-theta[1])^2)+theta[4]*h[t-1]) p=c(p,dnorm(r[t],theta[1],sqrt(h[t]),log=TRUE)) } -sum(p) } Then I use nlminb to minimize the function loglikelihood: nlminb(
2011 Apr 14
2
Krylov subspace computations of matrix exponentials
I use the very nice expm functions available from the expm and Matrix packages. My understanding is that for large sparse matrices the currently best methods available are Krylov subspace methods, but they are as far as I can tell not implemented in either of the packages mentioned, nor in any other R package I have found. Does anybody know if Krylov subspace methods are available from any R
2009 Nov 23
1
R: Re: chol( neg.def.matrix ) WAS: Re: Choleski and Choleski with pivoting of matrix fails
It works! But Once I have the square root of this matrix, how do I convert it to a real (not imaginary) matrix which has the same property? Is that possible? Best, Simon >----Messaggio originale---- >Da: p.dalgaard at biostat.ku.dk >Data: 21-nov-2009 18.56 >A: "Charles C. Berry"<cberry at tajo.ucsd.edu> >Cc: "simona.racioppi at
2011 Sep 22
1
Error in as.vector(data) optim() / fkf()
Dear R users, When running the program below I receive the following error message: fit <- optim(parm, objective, yt = tyield, hessian = TRUE) Error in as.vector(data) : no method for coercing this S4 class to a vector I can't figure out what the problem is exactly. I imagine that it has something to do with "tyield" being a matrix. Any help on explaining what's going on
2011 May 12
1
Maximization of a loglikelihood function with double sums
Dear R experts, Attached you can find the expression of a loglikelihood function which I would like to maximize in R. So far, I have done maximization with the combined use of the mathematical programming language AMPL (www.ampl.com) and the solver SNOPT (http://www.sbsi-sol-optimize.com/manuals/SNOPT%20Manual.pdf). With these tools, maximization is carried out in a few seconds. I wonder if that
2011 Jun 08
2
Results of CFA with Lavaan
I've just found the lavaan package, and I really appreciate it, as it seems to succeed with models that were failing in sem::sem. I need some clarification, however, in the output, and I was hoping the list could help me. I'll go with the standard example from the help documentation, as my problem is much larger but no more complicated than that. My question is, why is there one latent
2012 Nov 30
2
NA return to NLM routine
Hello, I am trying to understand a small quirk I came across in R. The following code results in an error: k <- c(2, 1, 1, 5, 5) f <- c(1, 1, 1, 3, 2) loglikelihood <- function(theta,k,f){ if( theta<1 && theta>0 ) return(-1*sum(log(choose(k,f))+f*log(theta)+(k-f)*log(1-theta))) return(NA) } nlm(loglikelihood ,0.5, k, f ) Running this code results in: Error
2007 May 24
3
Problem with numerical integration and optimization with BFGS
Hi R users, I have a couple of questions about some problems that I am facing with regard to numerical integration and optimization of likelihood functions. Let me provide a little background information: I am trying to do maximum likelihood estimation of an econometric model that I have developed recently. I estimate the parameters of the model using the monthly US unemployment rate series
2011 Apr 15
3
GLM output for deviance and loglikelihood
It has always been my understanding that deviance for GLMs is defined by; D = -2(loglikelihood(model) - loglikelihood(saturated model)) and this can be calculated by (or at least usually is); D = -2(loglikelihood(model)) As is done so in the code for 'polr' by Brian Ripley (in the package 'MASS') where the -loglikehood is minimised using optim; res <-
2020 Apr 17
1
Demo for linking native routines between R packages
Dear Davis and Dirk, Thank you very much for the suggestions, which are very valuable and helpful. I will add references to prior examples, document my project with the clear step-by-step-style document of Davis's project, and come back again to the mailing list. Best wishes, David On Fri, Apr 17, 2020 at 3:40 PM Dirk Eddelbuettel <edd at debian.org> wrote: > > Jitao, >
2008 Apr 18
2
rzinb (VGAM) and dnbinom in optim
Dear R-help gurus (and T.Yee, the VGAM maintainer) - I've been banging my head against the keyboard for too long now, hopefully someone can pick up on the errors of my ways... I am trying to use optim to fit a zero-inflated negative binomial distribution. No matter what I try I can't get optim to recognize my initial parameters. I think the problem is that dnbinom allows either
2001 Aug 01
1
glm() with non-integer responses
A question about the inner workings of glm() and dpois(): Suppose I call glm(y ~ x, family=poisson, weights = w) where y contains NON-INTEGER (but still nonnegative) values. (a) Does glm() still correctly maximise the weighted Poisson loglikelihood ? (i.e. the function given by the same formal expression as the weighted loglikelihood of independent Poisson variables Y_i except that the