Skip to content

Commit

Permalink
Add predict to list of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
eeholmes committed Feb 25, 2020
1 parent 0873b3f commit 3418ba9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vignettes/Quick_Start.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ model.list <- list(B=B1,U=U1,C=C1,c=temp,Q=Q1,Z=Z1,A=A1,R=R1,x0=pi1,V0=V1,tinitx
If you want a factor effect, then you'll need to recode your factor as a matrix with $T$ columns and a row for each factor. Then you have 0 or 1 if that factor applies in time period $t$. $\CC$ then has a column for each estimated factor effect. See the Covariate chapter in the user guide.
\section*{Showing the model fits and getting the parameters}
There are \verb@plot@, \verb@autoplot@, \verb@print@, \verb@coef@, \verb@fitted@ and \verb@residuals@ functions for marssMLE objects. However, a good place to start is to use the broom package and the \verb@tidy@ function. Look at \verb@?tidy.marssMLE@ and the examples there. \verb@?print.MARSS@will show you how to get standard output from your fitted model objects and where that output is stored in the marssMLE object. Type \verb@?coef.MARSS@ to see the different formats for displaying the estimated parameters. To see plots of your states and fits plus diagnostic plots, use \verb@plot(fit)@ or \verb@ggplot2::autoplot(fit)@. For summaries of the residuals (model and state), you can use the \verb@augment@ function. See \verb@?augment.marssMLE@.
There are \verb@plot@, \verb@autoplot@, \verb@print@, \verb@coef@, \verb@fitted@, \verb@residuals@ and \verb@predict@ functions for marssMLE objects. However, a good place to start is to use the broom package and the \verb@tidy@ function. Look at \verb@?tidy.marssMLE@ and the examples there. \verb@?print.MARSS@ will show you how to get standard output from your fitted model objects and where that output is stored in the marssMLE object. Type \verb@?coef.MARSS@ to see the different formats for displaying the estimated parameters. To see plots of your states and fits plus diagnostic plots, use \verb@plot(fit)@ or \verb@ggplot2::autoplot(fit)@. For summaries of the residuals (model and state), you can use the \verb@augment@ function. See \verb@?augment.marssMLE@. To produce predictions and forecasts from a MARSS model, see \verb@?predict.marssMLE@.
\section*{Tips and Tricks}
Use \verb@plot(fit)@ (or \verb@autoplot(fit)@) to see a series of plots and diagnostics for your model. Try \verb@MARSSinfo()@ if you get errors you don't understand or fitting is taking a long time to converge. When fitting a model with \verb@MARSS()@, pass in \verb@silent=2@ to see what \verb@MARSS()@ is doing. This puts it in verbose mode. Use \verb@fit=FALSE@ to set up a model without fitting. Let's say you do \verb@fit <- MARSS(..., fit=FALSE)@. Now you can do \verb@summary(fit$model)@ to see what \verb@MARSS()@ thinks you are trying to fit. You can also try \verb@toLatex(fit$model)@ to make a LaTeX file and pdf version of your model (saved in the working directory). This loads the Hmisc package (and all its dependencies) and requires that you are able to process LaTeX files. Let's say you specified your model with some text short-cuts, like \verb@Q="unconstrained"@, but you want the list matrix form for a next step. \verb@a <- summary(fit$model)@ returns that list (invisibly). Because the model argument of \verb@MARSS()@ will understand a list of list matrices, you can pass in \verb@model=a@ to specify the model. \verb@MARSSkfas(fit, return.kfas.model=TRUE)@ will return your model in KFAS form (class SSModel), thus you can use all the functions available in the KFAS package on your model.
Expand Down

0 comments on commit 3418ba9

Please sign in to comment.