Description Usage Arguments Value Examples
View source: R/samplecensored.R
Function that, given a "gamlss" object, evaluates the
distribution-specific functions under predicted parameters of the provided dataframe
"predictdata".
The distribution-specific functions are density, cumulative distribution function, quantile
function and random generation for the given family of the gamlss object.
CAUTION: Exactly ONE of the arguments x, q, p, n MUST be specfied!
Also make sure that n is a multiple of nrow(predictdata)!
1 2 |
object |
gamlss fit object |
func |
character. "d", "p", "q", "r" for either density, distribution function, quantile or random data generation. |
fitdata |
dataframe. Data used as input. |
predictdata |
dataframe. Containing the observations for which the parameters are predicted. |
p |
scalar numeric. Probability value if quantile function used. |
x, q |
scalar numeric. Quantile value if density or probability function used respectively. |
n |
scalar numeric. Number of observations if random generator function used. |
... |
argumenst to be passed to the called distributional function. |
Depending on the choice of func, the respective vector of (d)density-, (p)probability- , (q)quantile- or (r)random values is returned.
1 2 3 4 5 6 7 8 9 10 11 12 | # Simulating a dataset
ld <- simulateData(n= 300,
param.formula = list(mu = ~exp(x1) + x2 + x3, sigma = ~sin(x2)),
name = 'x1', subset = ~ (x2 < 0.3 & x3 < 0.4), prob = 0.8,
damage =c(0.3, 0.9), family = 'NO',
correlation = NULL)$defected
# Fitting a gamlss model
lmodel <- gamlss(formula = y ~ . -indicator, data=ld)
nl <- length(ld$x1[ld$indicator==1])
lpredict.df <- data.frame(x1 = runif(n = nl), x2 = runif(n = nl), x3 = runif(n = nl), indicator = 1)
family_fun(lmodel, func = 'r',ld, lpredict.df, n = nrow(lpredict.df))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.