當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


R balancedGrouped 從矩陣創建 groupedData 對象

R語言 balancedGrouped 位於 nlme 包(package)。

說明

從數據矩陣創建 groupedData 對象。此函數隻能用於平衡數據。相反的轉換,即從 groupedData 對象到 matrix ,是通過 asTable 完成的。

用法

balancedGrouped(form, data, labels=NULL, units=NULL)

參數

form

y ~ x | g 形式的公式,給出響應名稱、主要協變量和分組因子。

data

矩陣或 DataFrame ,包含根據分組因子級別(行)和主協變量不同級別(列)分組的響應值。矩陣的 dimnames 用於構造分組因子和主協變量的級別。

labels

一個可選的字符串列表,為響應和主要協變量提供標簽。主協變量的標簽名為 x ,響應的標簽名為 y 。任一標簽都可以省略。

units

給出響應和主要協變量單位的可選字符串列表。主協變量的單位字符串名為 x ,響應的單位字符串名為 y 。任一單位字符串都可以省略。

平衡的 groupedData 對象。

例子

OrthoMat <- asTable( Orthodont )
Orth2 <- balancedGrouped(distance ~ age | Subject, data = OrthoMat,
    labels = list(x = "Age",
                  y = "Distance from pituitary to pterygomaxillary fissure"),
    units = list(x = "(yr)", y = "(mm)"))
Orth2[ 1:10, ]        ## check the first few entries

# Pinheiro and Bates, p. 109
ergoStool.mat <- asTable(ergoStool)
balancedGrouped(effort~Type|Subject,
                data=ergoStool.mat)

作者

José Pinheiro and Douglas Bates bates@stat.wisc.edu

參考

Pinheiro, J. C. and Bates, D. M. (2000), Mixed-Effects Models in S and S-PLUS, Springer, New York.

也可以看看

groupedData , isBalanced , asTable

相關用法


注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Create a groupedData object from a matrix。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。