観測表の周辺度数と期待値表を作る

  • 予定パッケージ名
  • 関数名
    • tableExpAndMarginals
  • タイトル
tableExpAndMarginals
  • 説明
2次元分割表の周辺度数と期待値表を計算する
  • 使用例
tableExpAndMarginals(O)
  • ソース
tableExpAndMarginals<-
function (O = matrix(round(runif(N * M) * 100, 0), N, M)) 
{
    mrow <- apply(O, 1, sum)
    mcol <- apply(O, 2, sum)
    total <- sum(mrow)
    etable <- outer(mrow, mcol, FUN = "*")/total
    list(mrow = mrow, mcol = mcol, total = total, etable = etable, 
        dtable = O - etable, df = (length(mrow) - 1) * (length(mcol) - 
            1))
}
  • Rdファイル
\name{tableExpAndMarginals}
\alias{tableExpAndMarginals}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
tableExpAndMarginals
}
\description{
2次元分割表の周辺度数と期待値表を計算する
}
\usage{
tableExpAndMarginals(O)
}
%- maybe also 'usage' for other objects documented here.
\details{
%%  ~~ If necessary, more details than the description above ~~
}
\value{
\item{mrow}{行の周辺度数}
\item{mcol}{列の周辺度数}
\item{total}{全標本数}
\item{etable}{期待値表}
\item{dtable}{観測値と期待値の差分表}
\item{df}{自由度}
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%%  ~~who you are~~
}
\note{
%%  ~~further notes~~
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

\seealso{
}
\examples{
N<-3
M<-4
O<-matrix(sample(10:50,N*M,replace=TRUE),N,M)
tableExpAndMarginals(O)
}