Title: | Multivariate Autoregressive Modeling for Analysis of Community Time-Series Data |
---|---|
Description: | The MAR1 package provides basic tools for preparing ecological community time-series data for MAR modeling, building MAR-1 models via model selection and bootstrapping, and visualizing and exporting model results. It is intended to make MAR analysis sensu Ives et al. (2003) Analysis of community stability and ecological interactions from time-series data) a more accessible tool for anyone studying community dynamics. The user need not necessarily be familiar with time-series modeling or command-based statistics programs such as R. |
Authors: | Elizabeth Eli Holmes [cre, ctb] , Lindsay P. Scheef [aut, cph] |
Maintainer: | Elizabeth Eli Holmes <[email protected]> |
License: | GPL-2 |
Version: | 2.3 |
Built: | 2024-11-25 17:29:00 UTC |
Source: | https://github.com/atsa-es/MAR1 |
Ives et al. (2003) describe the model framework implemented in this package:
X(t) = A + BX(t-1) + CU(t-1) + E(t)
The first order multivariate autoregressive model may include both variates (factors expected to affect their own dynamics and the dynamics of other variates) and covariates (factors that may affect the dynamics of variates but are unlikely to be correspondingly influenced by them). The model estimates the value of each variate at time t as a linear function of the values of all variates and covariates at time t-1. The coefficients estimated in the MAR model represent the relative interaction strengths between each variate and covariate included in the analysis.
The MAR1 package includes the following basic functions:
prepare.data
Formats a dataset into evenly-spaced time-steps and marks continuous blocks of time-steps in preparation for MAR analysis. The data can also be log-transformed or z-scored with this function.
run.mar
Searches for and estimates a MAR model for a given dataset. The random best-fit model search and conditional least squares calculation components of this function are derived from Matlab scripts originally written by AR Ives and subsequently refined by SR Carpenter, KL Cottingham, and MD Scheuerell. Returns a list object of class MAR for which there are print
, summary
, and plot
methods.
export.MAR
Creates a new directory and exports all components of a MAR object into that directory as csv files.
Lindsay P. Scheef <[email protected]>
Maintainer: Eli Holmes <[email protected]>
Ives AR, Dennis B, Cottingham KL, and Carpenter SR (2003) Estimating community stability and ecological interactions from time-series data. Ecological Monographs 73:301-330
Creates a new directory and writes all elements of an object of class MAR
to that directory as csv files.
export.MAR(model.out,export=TRUE)
export.MAR(model.out,export=TRUE)
model.out |
Object of class |
export |
Optionally allows the name of the new directory to be set equal to a character string. Otherwise, the name of the new directory will be "MAR.results Sys.time" |
All elements of the given MAR class object are converted to csv format and written to a new directory created within the current working directory. The name of the new directory can be chosen by setting the export
argument equal to a character string. If the name of the new directory matches one already present in the working directory, the name will be amended with Sys.time()
to avoid overwriting the previous folder
Writes to a directory.
LP Scheef
Plots a histogram of the AIC values of the best-fit models contained in the $top.bestfit
component of an object of class MAR
## S3 method for class 'MARtop' hist(x, ...)
## S3 method for class 'MARtop' hist(x, ...)
x |
The |
... |
Further arguments passed to or from other methods |
The AIC values of the top best-fit models are plotted as a frequency histogram. A blue asterisk indicates the AIC value of the selected best-fit model.
A graphics device containing the histogram of top best-fit model AIC values
LP Scheef
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) hist(run1$top.bestfit)
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) hist(run1$top.bestfit)
This dataset is a plankton abundance time-series collected at the Western Channel Observatory L4 station. It contains zooplankton abundances in #/m^3, phytoplankton abundances in #/ml, and sea surface temperature in degrees C. Sampling dates for zooplankton, phytoplankton, and surface temperature values are not always aligned, resulting in NA values within the time-series.
data(L4.AllDates)
data(L4.AllDates)
A data frame with 1123 observations on the following 20 variables.
date |
sampling dates; often read into R as a factor variable | |
cnidarian |
e.g., hydromedusae and siphonophores | |
amphipod |
e.g., gammarids | |
chaetognath |
Sagitta spp. | |
krill |
Euphausiids (all stages) | |
pteropod |
Clione and Limacina | |
tunicate |
larvaceans | |
cladoceran |
Evadne spp. and Podon spp. | |
calanoid.lg |
large calanoid copepods (>2 mm) | |
calanoid.sm |
small calanoid copepods (<2 mm) | |
cyclopoid |
cyclopoid copepods | |
poecilostom |
poecilostomatoid copepods | |
harpact |
harpacticoid copepods | |
diatom |
phytoplankton: diatoms | |
dino |
phytoplankton: dinoflagellates | |
other.algae |
phytoplankton: e.g., coccolithophores, green | |
cirripedia |
meroplankton: barnacle nauplii and cyprids | |
mero.grazers |
meroplankton: other grazers, e.g., gastropod and bivalve larvae | |
decapod |
meroplankton: e.g., crab and shrimp larvae | |
surface.temp |
sea surface temperature (degrees C) | |
http://www.westernchannelobservatory.org.uk/data.php
Eloire D, Somerfield PJ, Conway DVP, Halsband-Lenk C, Harris R, and Bonnet D (2010) Temporal variability and community composition of zooplankton at station L4 in the Western Channel: 20 years of sampling. Journal of Plankton Research 32:657-679 [doi:10.1093/plankt/fbq009]
Southward AJ, Langmead O, Hardman-Mountford NJ, Aiken J, Boalch GT, Dando PR, Genner MJ, Joint I, Kendall MA, Halliday NC, Harris RP, Leaper R, Mieszkowska N, Pingree RD, Richardson AJ, Sims DW, Smith T, Walne AW, and Hawkins SJ (2005) Long-term oceanographic and ecological research in the western English Channel. Advances in Marine Biology 47:1-105 [doi:10.1016/S0065-2881(04)47001-1]
Scheef, LP, DE Pendleton, SE Hampton, SL Katz, EE Holmes, ME Scheuerell, and DG Johns (2012) Assessing marine plankton community structure from long-term monitoring data with multivariate autoregressive (MAR) models: a comparison of fixed station vs. spatially distributed sampling data. Limnology & Oceanography: Methods 10:54-64.
data(L4.AllDates) summary(L4.AllDates)
data(L4.AllDates) summary(L4.AllDates)
Plankton abundance data collected at the Western Channel Observatory L4 station, formatted for use in run.mar
. The dataset was prepared for MAR analysis with a call to prepare.data(data=L4.AllDates, increment="month", fill.gap=0, replace.0s="rand.half",
log=T, z.method="deseason")
data(L4.mar)
data(L4.mar)
A data frame with 179 observations on the following 21 variables.
contin |
a numeric vector where matching values indicate blocks of continuous sampling dates | |
date |
dates | |
cnidarian |
e.g., hydromedusae and siphonophores | |
amphipod |
e.g., gammarids | |
chaetognath |
Sagitta spp. | |
krill |
Euphausiids (all stages) | |
pteropod |
Clione and Limacina | |
tunicate |
larvaceans | |
cladoceran |
Evadne spp. and Podon spp. | |
calanoid.lg |
large calanoid copepods (>2 mm) | |
calanoid.sm |
small calanoid copepods (<2 mm) | |
cyclopoid |
cyclopoid copepods | |
poecilostom |
poecilostomatoid copepods | |
harpact |
harpacticoid copepods | |
diatom |
phytoplankton: diatoms | |
dino |
phytoplankton: dinoflagellates | |
other.algae |
phytoplankton: e.g., coccolithophores, green | |
cirripedia |
meroplankton: barnacle nauplii and cyprids | |
mero.grazers |
meroplankton: other grazers, e.g., gastropod and bivalve larvae | |
decapod |
meroplankton: e.g., crab and shrimp larvae | |
surface.temp |
sea surface temperature | |
http://www.westernchannelobservatory.org.uk/data.php
data(L4.mar) summary(L4.mar)
data(L4.mar) summary(L4.mar)
Plots the coefficients contained in an object of class MAR
resulting from a call to run.mar
## S3 method for class 'MAR' plot(x, y=NULL, ..., legend=FALSE)
## S3 method for class 'MAR' plot(x, y=NULL, ..., legend=FALSE)
x |
Object of class |
y |
Optional additional object of class |
... |
Not used. |
legend |
Should a legend be generated? If set to TRUE, an additional graphics device containing the legend will be generated |
The B- and C-matrix coefficients of the best-fit model are plotted as a grid of bar graphs. If bootstrapping was performed, discarded best-fit coefficients are faded. If any restrictions were set on interactions, red and green points at the base of bars are indicative of exclusion and inclusion, respectively.
A graphics device containing the coefficient plot, and, if legend=TRUE
, an additional device containing the corresponding legend
LP Scheef
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) plot(run1)
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) plot(run1)
Plots the coefficients of the best-fit models contained in the $top.bestfit
component of an object of class MAR
.
## S3 method for class 'MARtop' plot(x, ...)
## S3 method for class 'MARtop' plot(x, ...)
x |
The |
... |
Further arguments passed to or from other methods |
The B- and C-matrix coefficients of the top best-fit models are plotted as a grid of bar graphs, with the selected best-fit model represented by the top-most set of bars.
A graphics device containing the coefficient plot
LP Scheef
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) plot(run1$top.bestfit)
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) plot(run1$top.bestfit)
Formats a data frame of variable time-series for use in run.mar
prepare.data(data, increment = c("month", "year", "week", "day"), fill.gap = 0, replace.0s = c(FALSE, "rand.half", "add.ones"), log = FALSE, z.method = c(FALSE, "standard", "deseason"), order = NULL )
prepare.data(data, increment = c("month", "year", "week", "day"), fill.gap = 0, replace.0s = c(FALSE, "rand.half", "add.ones"), log = FALSE, z.method = c(FALSE, "standard", "deseason"), order = NULL )
data |
Data frame to be transformed: first column dates, following columns variable time-series |
||||||||||||||||
increment |
Time-step increment data are to be averaged into: "month", "year", "week", or "day" |
||||||||||||||||
fill.gap |
Maximum length of gap between time-steps to be filled by linear interpolation |
||||||||||||||||
replace.0s |
How zeros in the time-series should be dealt with:
|
||||||||||||||||
log |
Should the data be log-transformed? |
||||||||||||||||
z.method |
Standardize the data so all variables have equal means and standard deviations:
|
||||||||||||||||
order |
The order in which year, month, and day are recorded in the date format in the first column of |
The run.mar
function requires a data frame consisting of a continuous time-block indicator variable in the first column, dates/time-steps in the second column, and variable time-series with evenly spaced time-step increments in the remaining columns. This function automatically creates the continuous time-block variable column and aggregates the time-series into evenly spaced increments as indicated by the increment
argument. Although it automatically tries to assess the format of the dates in data
, the order
argument may have to be provided if this fails (for example, in the case where all dates in the dataset fall before the 12th of each month).
Other transformations that are commonly applied to ecological data prior to MAR modeling (e.g., Hampton et al. 2006, Ives et al. 2003) can optionally be performed, but are skipped by default with their respective arguments set to FALSE.
A data frame with a continuous time-block indicator variable in the first column, dates/time-steps in the second column, and variable time-series with evenly spaced time-step increments in the remaining columns
LP Scheef
Hampton SE, Scheuerell MD, and Schindler DE (2006) Coalescence in the Lake Washington story: Interaction strengths in a planktonic food web. Limnology and Oceanography 51:2042-2051
Ives AR, Dennis B, Cottingham KL, and Carpenter SR (2003) Estimating community stability and ecological interactions from time-series data. Ecological Monographs 73:301-330
## Not run: data(L4.AllDates) L4.mar <- prepare.data( data = L4.AllDates, increment = "month", fill.gap = 0, replace.0s = "rand.half", log = TRUE, z.method = "deseason" ) ## End(Not run)
## Not run: data(L4.AllDates) L4.mar <- prepare.data( data = L4.AllDates, increment = "month", fill.gap = 0, replace.0s = "rand.half", log = TRUE, z.method = "deseason" ) ## End(Not run)
Method for printing components of an object of class MAR
that provide a concise overview of the model
## S3 method for class 'MAR' print(x,...)
## S3 method for class 'MAR' print(x,...)
x |
Object of class |
... |
Further arguments passed to or from other methods |
Formats and prints the following components of a MAR
object when the object's name is called: the time-series variables that were selected to be included in the model; any restrictions that were set on variable interactions; the search type used to select the best-fit model; and the coefficients, AIC values, and R^2 values of the best-fit and bootstrapped models. Other components of a MAR
object can be viewed by specifying their name according to str(object)
.
Prints a selection of components of a MAR object.
LP Scheef
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) print(run1)
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) print(run1)
Formats and prints the result of applying summary
to a MAR
object.
## S3 method for class 'MARsummary' print(x,...)
## S3 method for class 'MARsummary' print(x,...)
x |
Object of class |
... |
Further arguments passed to or from other methods |
Prints a summary of a MAR object.
LP Scheef
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) summary(run1)
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) summary(run1)
Allows the user to select variables and restrict interactions, finds best-fit MAR model, and applies a bootstrap to the best-fit model
run.mar(data, variables=NULL, restrictions=NULL, search=c("random","exhaustive", "fwdstep","exhaustive.true"), boot=500, ntop=10, export=FALSE)
run.mar(data, variables=NULL, restrictions=NULL, search=c("random","exhaustive", "fwdstep","exhaustive.true"), boot=500, ntop=10, export=FALSE)
data |
Data frame with continuous time-block variable in first column, ordered by dates in second column, followed by columns of taxa abundance time-series |
variables |
A vector as long as the number of columns in
Alternatively, an object of class |
restrictions |
A matrix with n variate rows and n variate + n covariate columns of values indicating the potential of a direct effect of each column variable on each row variable:
Alternatively, on object of class |
search |
A character string indicating the type of search that should be used to find the best-fit model; either "random" (default), "exhaustive", "fwdstep", or "exhaustive.true"; see "Details" section below for descriptions of search types |
boot |
Either an integer indicating the number of iterations that should be performed in the model bootstrap
or |
ntop |
If |
export |
If set to TRUE, a call to |
Variables and Constraints:
If the variables
or restrictions
arguments are not provided, the function creates
windows that allow the user to pick which column variables in data
should be included in the MAR model as variates or covariates and to set restrictions on potential interactions between model variables. Unless the variables
argument is provided in the function call, the restrictions
argument must be NULL
.
Search Types:
If search="random"
, which is the default, a random search is performed to find the best-fit model (as determined by AIC) for the included variate time-series. For each variate, 100 random models are constructed according to the restrictions that were set, and the model with the lowest AIC of these models is retained. This process is repeated 100 times, resulting in 100 "best-of-100" models. If any variable occurs in less than 15 of the 100 "best-of-100" models, that variable is discarded (i.e., the probability of that variable occurring in the random search is set to 0) and the search is repeated until the number of variables in successive searches remains constant (resulting in at least 2 search iterations per variate unless all variables are retained in the first iteration). The model with the lowest AIC of the final 100 "best-of-100" models is retained.
If search="exhaustive"
, a search through possible models for each variate with respect to restrictions
is performed using a leap and bound algorithm (Furnival and Wilson,1974) to find the "best-fit" (lowest AIC) model of all potential variable combinations without explicitly examining all possible subsets.
If search="fwdstep"
, the best-fit model for each variate is built up from the NULL intercept model by sequentially adding whichever variable most improves the model AIC from the pool of potential variables. The model from the series with the lowest AIC is retained.
If search="exhaustive.true"
, a true exhaustive search through all potential variable combinations with respect to restrictions
is performed.
Statistics:
The coefficients of the final "best-fit" MAR model for all variates are attained using least-squares estimation. The coefficients of the B- and C-matrices represent interaction strengths of the column variables on the row variables. If the data were z-scored prior to analysis (see prepare.data
), the A intercept values will not be significantly different from 0. Estimates of the stationary distribution mean and covariance for each variate, of the process errors, and of community stability (resilience and reactivity) are calculated following Ives (2003). If bootstrap
is not set to FALSE, these statistics are also calculated for the bootstrapped model.
Returns a list of class MAR
containing:
variables.selected |
corresponds to |
restrictions.set |
corresponds to |
search.type |
corresponds to |
search.time.s |
time (in seconds) the best-fit model search took |
And for each of $bestfit
and $bootstrap
:
A |
each row is the a-value for the variate |
B |
B-matrix interaction coefficients of columns on rows |
C |
C-matrix interaction coefficients of columns on rows |
log.likelihood |
log.likelihood value for model |
AIC |
AIC value for model |
BIC |
BIC value for model |
R2.values |
R^2 and conditional R^2 values for each variate |
stationary.distribution |
|
process.errors |
|
stability |
|
resilience |
|
reactivity |
|
If bootstrapping is not performed, $bootstrap
will be NULL. Otherwise, in addition to the statistics above, $bootstrap
will also contain a $limits
list with the upper and lower 95% confidence limits of the best-fit model elements.
If search="random"
, "exhaustive"
, or "exhaustive.true"
, the result will also contain $top.bestfit
, an array of the top best-fit models tested during the model search (the first of which is the best-fit model that was selected). The number of top models returned may be less than the value set for the ntop
argument if ntop
exceeds the potential number of model configurations that can be tested for the selected variables and search method. The dimension of the array in which each top best-fit model is stored is named by its respective AIC value.
The "random" model search may select different best-fit models when run multiple times on the same data, particularly for searches including a large number of variables.
The "exhaustive.true" search can become very time-consuming for models with more than 12 variables.
LP Scheef
Furnival GM, Wilson Jr RW (1974) Regressions by leaps and bounds. Technometrics 16:499-511
Ives AR, Dennis B, Cottingham KL, and Carpenter SR (2003) Estimating community stability and ecological interactions from time-series data. Ecological Monographs 73:301-330
prepare.data
, plot.MAR
, export.MAR
Packages used for exhaustive search methods:leaps
, bestglm
## Not run: ## These examples take 1-2 minutes to run ## construct a MAR model using 'run.mar' arguments to set variables and restrictions data(L4.mar) myvar <- c(0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2) # 8 variates, 3 covariates myres <- matrix(0.5, nrow = length(which(myvar == 1)), ncol = length(which(myvar != 0)) ) # no restrictions (all 0.5) run1 <- run.mar(L4.mar, variables = myvar, restrictions = myres, search = "exhaustive") run1 # only some elements of the object are printed str(run1) # to see all elements summary(run1) # some summary statistics for the model plot(run1) # set a few restrictions on taxa interactions myres[1, c(1, 6, 9)] <- c(1, 0, 0) # included, not included, not included # re-run the analysis with same variates as 'run1' and new restrictions run1b <- run.mar(L4.mar, run1, myres, "exhaustive") plot(run1, run1b) # 'run1' variables and restrictions with a different search method run1c <- run.mar(L4.mar, run1, run1, "fwdstep") plot(run1, run1c, legend = TRUE) # plot with legend ## construct a MAR model using windows to select variables and restrictions ## run2 <- run.mar(L4.mar, search = "exhaustive") run2 summary(run2) plot(run2) ## End(Not run)
## Not run: ## These examples take 1-2 minutes to run ## construct a MAR model using 'run.mar' arguments to set variables and restrictions data(L4.mar) myvar <- c(0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2) # 8 variates, 3 covariates myres <- matrix(0.5, nrow = length(which(myvar == 1)), ncol = length(which(myvar != 0)) ) # no restrictions (all 0.5) run1 <- run.mar(L4.mar, variables = myvar, restrictions = myres, search = "exhaustive") run1 # only some elements of the object are printed str(run1) # to see all elements summary(run1) # some summary statistics for the model plot(run1) # set a few restrictions on taxa interactions myres[1, c(1, 6, 9)] <- c(1, 0, 0) # included, not included, not included # re-run the analysis with same variates as 'run1' and new restrictions run1b <- run.mar(L4.mar, run1, myres, "exhaustive") plot(run1, run1b) # 'run1' variables and restrictions with a different search method run1c <- run.mar(L4.mar, run1, run1, "fwdstep") plot(run1, run1c, legend = TRUE) # plot with legend ## construct a MAR model using windows to select variables and restrictions ## run2 <- run.mar(L4.mar, search = "exhaustive") run2 summary(run2) plot(run2) ## End(Not run)
An example MAR1 model prepared with the code in the example.
data(run1)
data(run1)
A sample MAR1 model fit to the L4.mar data. Object of class MAR.
data(run1) ## Not run: # run1 created with data(L4.mar) myvar <- c(0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2) # 8 variates, 3 covariates myres <- matrix(0.5, nrow = length(which(myvar == 1)), ncol = length(which(myvar != 0)) ) # no restrictions (all 0.5) run1 <- run.mar(L4.mar, variables = myvar, restrictions = myres, search = "exhaustive") ## End(Not run)
data(run1) ## Not run: # run1 created with data(L4.mar) myvar <- c(0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2) # 8 variates, 3 covariates myres <- matrix(0.5, nrow = length(which(myvar == 1)), ncol = length(which(myvar != 0)) ) # no restrictions (all 0.5) run1 <- run.mar(L4.mar, variables = myvar, restrictions = myres, search = "exhaustive") ## End(Not run)
Uses a fitted MAR object from the function run.mar
and an aggregated data.frame from the function transform.data
to fit a state-space MAR model. The bestfit model in the MAR object is used to determine where the 0s are in the B and C matrices. Users can specify the form of the observation error variance-covariance matrix (R) and process error variance-covariance matrix (Q).
ss.mar1(aggregated.data, MAR.obj=NULL, model=list(), control=list(), silent=FALSE)
ss.mar1(aggregated.data, MAR.obj=NULL, model=list(), control=list(), silent=FALSE)
aggregated.data |
Data frame with continuous time-block variable in first column, ordered by dates in second column, followed by columns of taxa abundance time-series. This type of data frame is output by the function |
MAR.obj |
A fitted MAR.obj as output by the function |
model |
An optional list with elements B, C, Q, or R that specify the form of those matrices. For Q and R, a numeric matrix can be used in which case Q or R will be fixed to those values. The text string “unconstrained” can be used for Q to specify that all elements are estimated (the default). The text string “diagonal and equal” can be used for Q or R to specify that the variance-covariance matrix is diagonal with one variance on the diagonal. The text string “diagonal and unequal” can be used for Q or R to specify that the variance-covariance matrix is diagonal but the variances on the diagonal are unconstrained. The text strings “zero” and “identity” can also be used for R or Q to specify those matrix forms. B and Q can be passed into the model list in order to use a B or C matrix other than the bestfit B and C in |
control |
A list of control elements for the MARSS package functions. The most useful may be |
silent |
If FALSE, the output from the MARSS fitting function is suppressed. |
The functions fits a simple observation model where each species in the B matrix is assumed to be observed with independent observation error. The covariates are assumed to be observed with no error. Missing variates and covariates are allowed.
The B and C matrices are constrained by default by the bestfit model in the MLE.obj
. ss.mar1 will use the 0 locations in the bestfit model and constrain those B and C elements to be 0. Other B or C matrices can be passed in via the model argument and will override this behavior.
A list with the elements
ssfit |
A marssMLE object output from |
A |
The estimated A matrix |
B |
The estimated B matrix |
C |
The estimated C matrix |
process.errors |
The process errors |
observation.errors |
The observation errors |
AIC |
AIC |
AIC |
AICc |
log.likelihood |
log likelihood |
Eli Holmes
The MARSS User Guide: Holmes, E. E., E. J. Ward, and M. D. Scheuerell (2012) Analysis of multivariate time-series using the MARSS package. NOAA Fisheries, Northwest Fisheries Science Center, 2725 Montlake Blvd E., Seattle, WA 98112. Available at https://CRAN.R-project.org/package=MARSS.
## Not run: ## These examples take 1-2 minutes to run ## construct a MAR model using 'run.mar' arguments to set variables and restrictions ## data(L4.mar) myvar <- c(0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2) # 8 variates, 3 covariates myres <- matrix(0.5, nrow = length(which(myvar == 1)), ncol = length(which(myvar != 0)) ) # no restrictions (all 0.5) run1 <- run.mar(L4.mar, variables = myvar, restrictions = myres, search = "exhaustive") # control can be passed in to limit the number of iterations run. ss.fit <- ss.mar1(L4.mar, run1, control = list(maxit = 50)) # compare to best fit model ss.fit$B run1$bestfit$B # Use a known observation error R <- diag(0.2, 8) ss.fit <- ss.mar1(L4.mar, run1, model = list(R = R), control = list(maxit = 50)) ## End(Not run)
## Not run: ## These examples take 1-2 minutes to run ## construct a MAR model using 'run.mar' arguments to set variables and restrictions ## data(L4.mar) myvar <- c(0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2) # 8 variates, 3 covariates myres <- matrix(0.5, nrow = length(which(myvar == 1)), ncol = length(which(myvar != 0)) ) # no restrictions (all 0.5) run1 <- run.mar(L4.mar, variables = myvar, restrictions = myres, search = "exhaustive") # control can be passed in to limit the number of iterations run. ss.fit <- ss.mar1(L4.mar, run1, control = list(maxit = 50)) # compare to best fit model ss.fit$B run1$bestfit$B # Use a known observation error R <- diag(0.2, 8) ss.fit <- ss.mar1(L4.mar, run1, model = list(R = R), control = list(maxit = 50)) ## End(Not run)
Method for producing a summary of an object of class MAR
. Calculates the number of zero, non-zero, positive, and negative coefficients in the best-fit and bootstrapped models, gives the AIC, BIC, and summary of the R^2 values for the models, and lists the calculated stability statistics associated with the models.
## S3 method for class 'MAR' summary(object,...)
## S3 method for class 'MAR' summary(object,...)
object |
Object of class |
... |
Further arguments passed to or from other methods |
Prints a summary of a MAR object.
LP Scheef
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) summary(run1)
# load a sample MAR model fit. See \code{\link{run1}}. data(run1) summary(run1)