sessionInfo()

#R version 3.5.2 (2018-12-20)

#Platform: x86_64-w64-mingw32/x64 (64-bit)

#Running under: Windows >= 8 x64 (build 9200)

Hello Ashim. I am not familiar with the MARSS pkg, however, I am always interested in following many of these R-Help questions and often run them for my own edification.

I ran your script and it appears to have run successfully, however, when I (naively) use the suggested "# Use MARSSparamCIs to compute CIs and bias estimates." below as you did I get a different error.

# I GET THIS ERROR

#Error in MARSSparamsCIs(fit) : could not find function "MARSSparamsCIs"

After further googling I find that I was (as suspected) incorrect in using " MARSSparamsCIs" as a function on fit or maybe not, take a look at this URL

https://rdrr.io/cran/MARSS/man/MARSSparamCIs.htmlI'm not sure how to proceed but this is interesting to follow, thank you.

WHP

x1 <- rnorm(1000)

View(x1)#----------------------Just curious

plot(x1)#----------------------Just curious

b <- cumsum(rnorm(1000, sd = sqrt(.6)))

plot(b)#----------------------Just curious

y <- 1 + b*x1 + rnorm(1000)

plot(y)#----------------------Just curious

Z = array(NA,c(1,2,1000))

Z[1,1,] = rep(1,1000)

Z[1,2,] = x1

mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T),

U = matrix(0,2,1),

Q = matrix(list(0,0,0,"s2b"),2,2),

Z= Z, A = matrix(0), R = matrix("r"))

View(mod2.list)

#print(mod2.list)

str(mod2.list)#---------------------------------KNOW THY DATA

#List of 6

# $ B: num [1:2, 1:2] 1 0 0 1

# $ U: num [1:2, 1] 0 0

# $ Q:List of 4

# ..$ : num 0

# ..$ : num 0

# ..$ : num 0

# ..$ : chr "s2b"

# ..- attr(*, "dim")= int [1:2] 2 2

# $ Z: num [1, 1:2, 1:1000] 1 1.2 1 1.04 1 ...

# $ A: num [1, 1] 0

# $ R: chr [1, 1] "r"

fit = MARSS(as.vector(y), model = mod2.list,inits = list(x0=matrix(0,nrow=2,ncol=1)))

#Success! abstol and log-log tests passed at 27 iterations.

# Alert: conv.test.slope.tol is 0.5.

# Test with smaller values (<0.1) to ensure convergence.

#

# MARSS fit is

# Estimation method: kem

# Convergence test: conv.test.slope.tol = 0.5, abstol = 0.001

# Estimation converged in 27 iterations.

# Log-likelihood: -1758.409

# AIC: 3524.818 AICc: 3524.858

#

# Estimate

# R.r 1.026

# Q.s2b 0.606

# x0.X1 0.999

# x0.X2 -1.025

# Initial states (x0) defined at t=0

#

# Standard errors have not been calculated.

# Use MARSSparamCIs to compute CIs and bias estimates.

MARSSparamsCIs(fit)

#I GET THIS ERROR

#Error in MARSSparamsCIs(fit) : could not find function "MARSSparamsCIs"

#NOT THIS ERROR

# The above will give this error :

#Error in MARSSharveyobsFI(MLEobj) : replacement has length zero

WHP

From: R-help <

[hidden email]> On Behalf Of Ashim Kapoor

Sent: Wednesday, January 23, 2019 1:38 AM

To:

[hidden email]
Subject: [R] Unable to compute Confidence Intervals from output from MARSS package

Dear All,

I am trying to use this package --->

https://cran.r-project.org/web/packages/MARSS/index.htmlI am reading this book which shows some examples based on the above package

--->

https://nwfsc-timeseries.github.io/atsa-labs/In a few words, the incantation MARSS(...) estimates the parameters and

MARSSparamCIs should return the confidence intervals. My problem is that

MARSSparamCIs returns this error :-

> MARSSparamCIs(fit)

Error in MARSSharveyobsFI(MLEobj) : replacement has length zero

>

### This page and the next page, explains the jargon used :

https://nwfsc-timeseries.github.io/atsa-labs/sec-dlm-example-of-a-univariate-dlm.html### Here is a MWE to recreate the error :-

# This is a Time Varying Parameters regression

# Here a is fixed and b is doing a RW.

x1 <- rnorm(1000)

b <- cumsum(rnorm(1000, sd = sqrt(.6)))

y <- 1 + b*x1 + rnorm(1000)

Z = array(NA,c(1,2,1000))

Z[1,1,] = rep(1,1000)

Z[1,2,] = x1

mod2.list = list ( B = matrix(c(1,0,0,1),nrow = 2 , byrow = T), U =

matrix(0,2,1),

Q = matrix(list(0,0,0,"s2b"),2,2), Z= Z, A = matrix(0), R = matrix("r"))

fit = MARSS(as.vector(y), model = mod2.list,inits =

list(x0=matrix(0,nrow=2,ncol=1)))

MARSSparamsCIs(fit)

# The above will give this error :

Error in MARSSharveyobsFI(MLEobj) : replacement has length zero

Best Regards,

Ashim

[[alternative HTML version deleted]]

______________________________________________

mailto:

[hidden email] mailing list -- To UNSUBSCRIBE and more, see

https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.

Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}

______________________________________________

[hidden email] mailing list -- To UNSUBSCRIBE and more, see

https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.