attachVarPrep

Share:

Description

Attach partial derivative and residual variance functions to the nonlinear fitted object

Usage

1
2
3
4
attachVarPrep(object, form = formula(object), fDerivFixef = NULL, 


    fDerivRanef = NULL, fVarResidual = NULL, fAddDummies = NULL)

Arguments

object

the fitted nlme object

form

the formula used to fit the object, either formula or string used for automated derivation

fDerivFixef

function(nfit,newdata,pred) of derivatives in respect to fixed effects at newdata

fDerivRanef

function(nfit,newdata,pred) of derivatives in respect to random effects at newdata

fVarResidual

function(nfit,newdata,pred) to calculate var(residual) at newdata

fAddDummies

function(newdata) see "Handling categorial variables"

Details

For usage with varPredictNlmeGnls, this function attaches to the fitted object

  • derivative functions

  • residual variance function

  • Variance-Covariance methods

Automatic derivation

If proper basic formula is given, fDerivFixef and fDerivRanef will be automatically derived from the model.

Up until now, only single level random effects models are supported for automatic derivation.

Handling of categorial variables

item fAddDummies=function(newdata) of restult entry varPrep adds columns for dummy variables

of categorial variables to newdata.

Default implementation supports only (and assumes) contr.treatment coding.

For other codings user must provide the function with argument fAddDummies.

Variance of Residuals

Providing no argument fResidual assumes iid residuals, i.e. weights=NULL.

For other residual variance models. See e.g. varResidPower corresponding to weights=varPower(form=~fitted(.))

Value

nfit with additional entry varPrep, which is a list of

varFix

variance-covariance matrix of fixed effects

varRan

variance-covariance matrix of random effects

coefFix

names of the fixed coefficients in gradiant function

coefRan

names of the random coefficients in gradiant function

gradFix

derivative function for fixed effects

gradRan

derivative function for random effects

fAddDummies

function to add dummy columns for categorial variables to predictor data frame

fVarResidual

function to calculate residual variance

fullFormula

the extended formula as a string

Author(s)

Thomas Wutzler

See Also

twNlme-package

Examples

 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
data(modExampleStem)


#mtrace(.covarMap)


nfit <- attachVarPrep( modExampleStem, form = "b0*dbh^b1*height^b2")





data(Wutzler08BeechStem)


newdata=data.frame(dbh=18.8, height=16.9, age=40, si=30, alt=470)


(uNew <- nfit$varPrep$gradFix(newdata=newdata))


(wNew <- nfit$varPrep$gradRan(newdata=newdata))





newdata=head(Wutzler08BeechStem)


(uNew <- nfit$varPrep$gradFix(newdata=newdata))


(wNew <- nfit$varPrep$gradRan(newdata=newdata))