Learn R Programming

varian (version 0.2.2)

res_gamma: Estimates the parameters of a Gamma distribution from SDs

Description

This function calcualtes the parameters of a Gamma distribution from the residuals from an individuals' own mean. That is, the distribution of (standard) deviations from individuals' own mean are calculated and then an estimate of the parameters of a Gamma distribution are calculated.

Usage

res_gamma(x, ID)

Arguments

x
A data vector to operate on
ID
an ID variable of the same length as x

Value

a list of the shape (alpha) and rate (beta) parameters and the mean and variance

Examples

Run this code
set.seed(1234)
y <- rgamma(100, 3, 2)
x <- rnorm(100 * 10, mean = 0, sd = rep(y, each = 10))
ID <- rep(1:100, each = 10)
res_gamma(x, ID)

Run the code above in your browser using DataLab