File: Chisq-class.Rd

package info (click to toggle)
r-cran-distr 2.9.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,344 kB
  • sloc: ansic: 199; sh: 13; makefile: 2
file content (122 lines) | stat: -rw-r--r-- 5,262 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
\name{Chisq-class}
\docType{class}
\alias{Chisq-class}
\alias{Chisq}
\alias{initialize,Chisq-method}
\title{Class "Chisq"}
\description{
  The chi-squared distribution with \code{df}\eqn{= n} degrees of
  freedom has density
  \deqn{f_n(x) = \frac{1}{{2}^{n/2} \Gamma (n/2)} {x}^{n/2-1} {e}^{-x/2}}{%
    f_n(x) = 1 / (2^(n/2) Gamma(n/2))  x^(n/2-1) e^(-x/2)}
  for \eqn{x > 0}.  The mean and variance are \eqn{n} and \eqn{2n}.

  The non-central chi-squared distribution with \code{df}\eqn{= n}
  degrees of freedom and non-centrality parameter \code{ncp}
  \eqn{= \lambda} has density
  \deqn{
    f(x) = e^{-\lambda / 2}
      \sum_{r=0}^\infty \frac{(\lambda/2)^r}{r!}\, f_{n + 2r}(x)}{%
    f(x) = exp(-lambda/2) SUM_{r=0}^infty ((lambda/2)^r / r!) dchisq(x, df + 2r)
  }
  for \eqn{x \ge 0}.  For integer \eqn{n}, this is the distribution of
  the sum of squares of \eqn{n} normals each with variance one,
  \eqn{\lambda} being the sum of squares of the normal means.
  
  C.f. \code{\link[stats:Chisquare]{rchisq}}
}
 

\section{Objects from the Class}{
  Objects can be created by calls of the form \code{Chisq(df, ncp)}.
  This object is a chi-squared distribution.
}
\section{Slots}{
  \describe{
    \item{\code{img}}{Object of class \code{"Reals"}:
      The space of the image of this distribution has got dimension 1 and the name "Real Space".}
    \item{\code{param}}{Object of class \code{"ChisqParameter"}:
      the parameter of this distribution (df and ncp), declared at its instantiation}
    \item{\code{r}}{Object of class \code{"function"}:
      generates random numbers (calls function rchisq)}
    \item{\code{d}}{Object of class \code{"function"}:
      density function (calls function dchisq)}
    \item{\code{p}}{Object of class \code{"function"}:
      cumulative function (calls function pchisq)}
    \item{\code{q}}{Object of class \code{"function"}:
      inverse of the cumulative function (calls function qchisq)}
    \item{\code{.withArith}}{logical: used internally to issue warnings as to 
            interpretation of arithmetics}
    \item{\code{.withSim}}{logical: used internally to issue warnings as to 
          accuracy}
    \item{\code{.logExact}}{logical: used internally to flag the case where 
    there are explicit formulae for the log version of density, cdf, and 
    quantile function}
    \item{\code{.lowerExact}}{logical: used internally to flag the case where 
    there are explicit formulae for the lower tail version of cdf and quantile 
    function}
    \item{\code{Symmetry}}{object of class \code{"DistributionSymmetry"};
     used internally to avoid unnecessary calculations.}
  }
}
\section{Extends}{
Class \code{"ExpOrGammaOrChisq"}, directly.\cr
Class \code{"AbscontDistribution"}, by class \code{"ExpOrGammaOrChisq"}.\cr
Class \code{"UnivariateDistribution"}, by class \code{"AbscontDistribution"}.\cr
Class \code{"Distribution"}, by class \code{"UnivariateDistribution"}.
}

\section{Is-Relations}{
By means of \code{setIs}, R ``knows'' that a distribution object \code{obj} of class \code{"Chisq"} with non-centrality 0 also is
a Gamma distribution with parameters \code{shape = df(obj)/2, scale = 2}. 
}

\section{Methods}{
  \describe{
    \item{initialize}{\code{signature(.Object = "Chisq")}: initialize method }
    \item{df}{\code{signature(object = "Chisq")}:
      returns the slot df of the parameter of the distribution }
    \item{df<-}{\code{signature(object = "Chisq")}:
      modifies the slot df of the parameter of the distribution }
    \item{ncp}{\code{signature(object = "Chisq")}:
      returns the slot ncp of the parameter of the distribution }
    \item{ncp<-}{\code{signature(object = "Chisq")}:
      modifies the slot ncp of the parameter of the distribution }
    \item{+}{\code{signature(e1 = "Chisq", e2 = "Chisq")}: 
    For the chi-squared distribution we use its closedness under convolutions.}
  }
}

\author{
  Thomas Stabla \email{statho3@web.de},\cr 
  Florian Camphausen \email{fcampi@gmx.de},\cr
  Peter Ruckdeschel \email{peter.ruckdeschel@uni-oldenburg.de},\cr
  Matthias Kohl \email{Matthias.Kohl@stamats.de}}
\note{
Warning: The code for pchisq and qchisq is unreliable for values of ncp above approximately 290. 
}
\seealso{
\code{\link{ChisqParameter-class}}
\code{\link{AbscontDistribution-class}}
\code{\link{Reals-class}}
\code{\link[stats:Chisquare]{rchisq}}
}
\examples{
C <- Chisq(df = 1, ncp = 1) # C is a chi-squared distribution with df=1 and ncp=1.
r(C)(1) # one random number generated from this distribution, e.g. 0.2557184
d(C)(1) # Density of this distribution is 0.2264666 for x = 1.
p(C)(1) # Probability that x < 1 is 0.4772499.
q(C)(.1) # Probability that x < 0.04270125 is 0.1.
## in RStudio or Jupyter IRKernel, use q.l(.)(.) instead of q(.)(.)
df(C) # df of this distribution is 1.
df(C) <- 2 # df of this distribution is now 2.
is(C, "Gammad") # no
C0 <- Chisq() # default: Chisq(df=1,ncp=0)
is(C0, "Gammad") # yes
as(C0,"Gammad")
}
\keyword{distribution}
\concept{absolutely continuous distribution}
\concept{Chi square distribution}
\concept{S4 distribution class}
\concept{generating function}