pheno.ddm: Dense design matrix for phenological data

View source: R/pheno.ddm.R

pheno.ddmR Documentation

Dense design matrix for phenological data

Description

Creation of dense two-way classification design matrix. The sum of the second factor is constrained to be zero. No general mean.

Usage

pheno.ddm(D,na.omit=TRUE)

Arguments

D

Data frame with three columns: (observations, factor 1, factor 2).

na.omit

Determined whether missing values should be omitted or not. Default is TRUE.

Details

In phenological applications observations should be the julian day of observation of a certain phase, factor 1 should be the observation year and factor 2 should be a station-id. Usually this is much easier created by: y <- factor(f1), s <- factor(f2), ddm <- as.matrix.csr(model.matrix(~ y + s -1, contrasts=list(s=("contr.sum")))). However, this procedure can be quite memory demanding and might exceed storage capacity for large problems. This procedure here is much less memory comsuming. Moreover, in order to get direct estimates for all coefficients, an additional row is appended to the matrix, where the columns for the second factor are set to 1. Therefore, dimensions of ddm are (nlevels(factor1)+1)x(nlevels(factor2)).

Value

ddm

Dense roworder matrix, matrix.csr format (see matrix.csr in package SparseM)

D

Data frame D sorted first by f2 then by f1 and with rows containing NA's removed.

na.rows

Rows in D that were omitted due to missing values.

Author(s)

Joerg Schaber

See Also

model.matrix matrix.csr

Examples

	data(DWD)
	ddm1 <- pheno.ddm(DWD)
	attach(DWD)
	y <- factor(DWD[[2]])
	s <- factor(DWD[[3]])
	ddm2 <- as.matrix.csr(model.matrix(~ y + s -1, contrasts=list(s=("contr.sum"))))
	identical(ddm1$ddm,ddm2)

pheno documentation built on May 13, 2022, 1:05 a.m.

Related to pheno.ddm in pheno...