Learn R Programming

SpatioTemporal (version 0.9.2)

drop.observations: Drop Observations from mesa.data.model

Description

Drops observations from mesa.data.model, removing marked observations along with the corresponding locations and recomputes a number of relevant elements. Used by the cross-validation functions estimateCV and predictCV.

Usage

drop.observations(mesa.data.model, Ind.cv)

Arguments

mesa.data.model
Data structure holding observations, and information regarding the observation locations. See create.data.model and mesa.data.model
Ind.cv
A logical vector with one element per observation in mesa.data.model$obs. Observations marked with the TRUE will be dropped from the data structure. Use createCV to crea

Value

  • Returns the mesa.data.model without the observations marked by Ind.cv. Any locations that lack observations as a result of this removal are also excluded from the returned structure.

encoding

latin1

See Also

See also createCV, estimateCV, and predictCV.

Examples

Run this code
##load data
data(mesa.data.model)

##Mark 30\% of observations
I <- runif(dim(mesa.data.model$obs)[1])<.3
##drop these observations
mesa.data.new <- drop.observations(mesa.data.model, I)

##This reduces the remaining number of observations
printMesaDataNbrObs(mesa.data.model)
printMesaDataNbrObs(mesa.data.new)
if( (length(mesa.data.model$obs$obs)<=length(mesa.data.new$obs$obs)) ||
    (length(mesa.data.new$obs$obs)!=sum(!I)) ){
  stop("drop.observations 1: Observations not dropped")
}
##create cross validation structure
Icv <- createCV(mesa.data.model, groups = 10)

##drop observations from the second CV group
mesa.data.new <- drop.observations(mesa.data.model, Icv[,2])

##This reduces the remaining number of observations (and locations)
printMesaDataNbrObs(mesa.data.model)
printMesaDataNbrObs(mesa.data.new)
if( (length(mesa.data.model$obs$obs)<=length(mesa.data.new$obs$obs)) ||
    (length(mesa.data.new$obs$obs)!=sum(!Icv[,2])) ||
    (dim(mesa.data.model$location)[1] <=
     dim(mesa.data.new$location)[1]) ){
  stop("drop.observations 2: Observations not dropped")
}

Run the code above in your browser using DataLab