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
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/n_obs.R
\name{n_obs}
\alias{n_obs}
\alias{n_obs.glm}
\alias{n_obs.svyolr}
\alias{n_obs.afex_aov}
\alias{n_obs.stanmvreg}
\title{Get number of observations from a model}
\usage{
n_obs(x, ...)
\method{n_obs}{glm}(x, disaggregate = FALSE, ...)
\method{n_obs}{svyolr}(x, weighted = FALSE, ...)
\method{n_obs}{afex_aov}(x, shape = c("long", "wide"), ...)
\method{n_obs}{stanmvreg}(x, select = NULL, ...)
}
\arguments{
\item{x}{A fitted model.}
\item{...}{Currently not used.}
\item{disaggregate}{For binomial models with aggregated data, \code{n_obs()}
returns the number of data rows by default. If \code{disaggregate = TRUE},
the total number of trials is returned instead (determined by summing the
results of \code{weights()} for aggregated data, which will be either the
weights input for proportion success response or the row sums of the
response matrix if matrix response, see 'Examples').}
\item{weighted}{For survey designs, returns the weighted sample size.}
\item{shape}{Return long or wide data? Only applicable in repeated measures
designs.}
\item{select}{Optional name(s) of response variables for which to extract values.
Can be used in case of regression models with multiple response variables.}
}
\value{
The number of observations used to fit the model, or \code{NULL} if
this information is not available.
}
\description{
This method returns the number of observation that were used
to fit the model, as numeric value.
}
\examples{
data(mtcars)
m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
n_obs(m)
if (require("lme4")) {
data(cbpp, package = "lme4")
m <- glm(
cbind(incidence, size - incidence) ~ period,
data = cbpp,
family = binomial(link = "logit")
)
n_obs(m)
n_obs(m, disaggregate = TRUE)
}
}
|