Learn R Programming

SpatioTemporal (version 1.1.9.1)

createDataMatrix: Create a Data Matrix

Description

Creates a data matrix from a STdata/STmodel object. Missing observations are marked as NA.

Usage

createDataMatrix(STdata = NULL, obs = STdata$obs$obs,
  date = STdata$obs$date, ID = STdata$obs$ID, subset = NULL)

Arguments

STdata

A STdata/STmodel object containing observations. Use either this or the obs, date, and ID inputs.

obs

A vector of observations.

date

A vector of observation times.

ID

A vector of observation locations.

subset

A subset of locations to extract the data matrix for. A warning is given for each name not found in ID.

Value

Returns a matrix with dimensions (number of timepoints)-by-(number of locations). Row and column names of the matrix are taken as ID and sort(unique(date)) respectively.

See Also

Other data matrix: SVDmiss, SVDsmooth, estimateBetaFields, mesa.data.raw

Other STdata functions: c.STmodel, createSTdata, createSTmodel, detrendSTdata, estimateBetaFields, removeSTcovarMean, updateTrend.STdata

Other STmodel functions: createCV, createSTmodel, dropObservations, estimateBetaFields, loglikeSTdim, loglikeST, predictNaive, processLUR, processLocation, updateCovf, updateTrend.STdata

Examples

Run this code
# NOT RUN {
##load the data
data(mesa.model)

##create a data matrix
M1 <- createDataMatrix(mesa.model)
dim(M1)
head(M1)

##create data matrix for only a few locations
M2 <- createDataMatrix(mesa.model, subset =
                         c("60370002","60370016","60370113","60371002",
                           "60371103","60371201","L001","L002"))
dim(M2)
head(M2)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab