Re: [R] State space model

2011-11-14 Thread Kristian Lind
f the available packages please let me know. Kristian 2011/11/12 Kristian Lind > Hi, > > I'm trying to estimate the parameters of a state space model of the > following form > > measurement eq: > > z_t = a + b*y_t + eps_t > > transition eq > > y_t+h = (I -ex

[R] State space model

2011-11-12 Thread Kristian Lind
Hi, I'm trying to estimate the parameters of a state space model of the following form measurement eq: z_t = a + b*y_t + eps_t transition eq y_t+h = (I -exp(-hL))theta + exp(-hL)y_t+ eta_{t+h}. The problem is that the distribution of the innovations of the transition equation depend on the pr

[R] Error in eigen(a$hessian) : infinite or missing values in 'x'

2011-11-05 Thread Kristian Lind
Dear R-users, I'm estimating a two- dimensional state-space model using the FKF package. The resulting log likelihood function is maximized using auglag from the Alabama package. The procedure works well for a subset of my data, but if I try to use the entire data set I get the following error mes

Re: [R] Linear Regression with Linear Equality Constraint

2011-10-31 Thread Kristian Lind
I believe the package systemfit can help you with that. Haven't tried it myself, but give it a go. Regards, Kristian 2011/10/31 JW > Please advice on the package I should use to run a linear regression model > (weighted least squared) with linear equality constraint. I initially > tried > "co

Re: [R] Imposing Feller condition using project constraint in spg

2011-10-23 Thread Kristian Lind
Hi Ravi, Thank you for your reply and please excuse my late response. Plugging w2’ = k/w1’ from (A) into (B) yields (C) f(w1') = (w1-w1’)^2 + (w2-k/w1’)^2 The partial derivative wrt w1' is (D) df(w1')/ dw1' = -2(w1-w1’) + 2(w2-k/w1’)*k/(w1')^2 in order for this to be a minimum the f.o.c. df(w

Re: [R] write.csv naming file after function argument

2011-10-16 Thread Kristian Lind
Thank you for your help. It works now. 2011/10/13 Jean V Adams > > Kristian Lind wrote on 10/13/2011 04:52:16 AM: > > > > > Dear R-users, > > > > I'm writing a program that constructs a dataset. I wish to save the > dataset > > to a file. > >

[R] write.csv naming file after function argument

2011-10-13 Thread Kristian Lind
Dear R-users, I'm writing a program that constructs a dataset. I wish to save the dataset to a file. Here's a very simple example of what I'm trying to do function(x=peter){ y <- x/2 write.csv(y, file = "...\x") } The problem is that I want to name the dataset as whatever the name of the input

Re: [R] Error in as.vector(data) optim() / fkf()

2011-09-23 Thread Kristian Lind
Problem solved. It had something to do with calling expm(-array(c(K_1, 0, 0, K_2), c(2,2))*h). 2011/9/22 Kristian Lind > Dear R users, > > When running the program below I receive the following error message: > fit <- optim(parm, objective, yt = tyield, hessian = TRUE) >

[R] Error in as.vector(data) optim() / fkf()

2011-09-22 Thread Kristian Lind
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 someth

Re: [R] Selecting from matrix and then stacking in array.

2011-09-20 Thread Kristian Lind
nd(z,array(0,c(9,3))) > z.out <- array(0, c(3,3,9)) > > for(i in 1:9){ > z.out[,,i] <- cbind(z.ext[c(i,i+3,i+6),]) > } > print(z.out) > > Hope this helps, > > Michael Weylandt > > > On Wed, Sep 14, 2011 at 3:42 PM, Kristian Lind < > kristian.langgaard.l

[R] Selecting from matrix and then stacking in array.

2011-09-14 Thread Kristian Lind
Hi, I'm solve a problem where I want to select every 3rd row from a matrix. I do this for all rows in a loop. This gives me "i" matrices with different number of rows I want to stack these matrices in an array and fill the blanks with zero. Does anyone have any suggestions on how to go about thi

[R] Imposing Feller condition using project constraint in spg

2011-09-07 Thread Kristian Lind
ormulate a function that takes care of this, but I can't really make it work so any suggestions would be much appreciated. Thank you. Kristian Lind [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/m

Re: [R] Using capture.output within a function

2011-09-02 Thread Kristian Lind
Yes, that's true. It works as it's supposed to now. Thank you. Kristian Lind 2011/9/2 Duncan Murdoch > On 11-09-02 5:24 AM, Kristian Lind wrote: > >> Dear R-users >> >> I'm running a maximum likelihood procedure using the spg package. I'd like >&

[R] Using capture.output within a function

2011-09-02 Thread Kristian Lind
and not only at completion. Any suggestions on how to get this done would be much appreciated. Kristian Lind *Below an example of what I'm trying to do...* loglik <- function(w){ state <- c(b_1 = 0, b_2 = 0, a = 0) #declaring ODEs Kr

[R] DLSODA error

2011-04-28 Thread Kristian Lind
Dear R-users, I'm running an MLE procedure where some ODEs are solved for each iteration in the maximization process. I use mle2 for the Maximum likelihood and deSolve for the ODEs. The problem is that somewhere along the way the ODE solver crashes and I get the following error message: DLSODA-

Re: [R] MLE where loglikelihood function is a function of numerical solutions

2011-04-14 Thread Kristian Lind
HI Berend, Thank you for your reply. 2011/4/13 Berend Hasselman > Questions: > > 1. why are you defining Bo within a loop? > 2. Why are you doing library(nleqslv) within the loop? > > Yes, I see what you mean. There's no reason for defining that within the loop. Doing both those statements out

Re: [R] MLE where loglikelihood function is a function of numerical solutions

2011-04-13 Thread Kristian Lind
is done as often as necessary for the optimizer you >> are using: eg a call to optim(psi,LL,...) where LL(psi) evaluates the log >> likelihood at psi. There may be computational shortcuts that would work if >> you knew that LL(psi+eps) were well approximated by LL(psi), for the va

[R] MLE where loglikelihood function is a function of numerical solutions

2011-04-10 Thread Kristian Lind
Hi there, I'm trying to solve a ML problem where the likelihood function is a function of two numerical procedures and I'm having some problems figuring out how to do this. The log-likelihood function is of the form L(c,psi) = 1/T sum [log (f(c, psi)) - log(g(c,psi))], where c is a 2xT matrix of

[R] dfsane arguments

2011-03-31 Thread Kristian Lind
tmat[19,4]-outmat[19,3]*x[1]-outmat[19,2]*x[2]) + exp(-outmat[20,4]-outmat[20,3]*x[1]-outmat[20,2]*x[2])) -s[2] f s <- c(0.03, 0.045) p<-c(0.5, 0.5) ans <- dfsane(par=p, fn=Bo, s=s) ans$par Any help will be much appreciated! Thank you, Kristian Lind [[alternative HTML version delet