Learn R Programming

spaMM (version 3.2.0)

get_inits_from_fit: Initiate a fit from another fit

Description

get_inits_from_fit is an extractor of some fitted values from a fit in a convenient format to initiate a next fit. This function is work in progress, and may not extract all values that can be used to initiate a fit (see Value).

Usage

get_inits_from_fit(from, template = NULL, to_fn = NULL)

Arguments

from

Fit object (inheriting from class "HLfit") from which fitted values are taken.

template

Another fit object. Usage with a template fit object is suitable for refitting this object using fitted values from the from object as starting values.

to_fn

NULL or character: the name of the function to be used the next fit. If NULL, taken from template (if available), else from from. It is meaningful to provide a to_fn distinct from the function used to fit a template.

Value

A list with elements

init, init.corrHLfit

(depending on the fitting function) giving initial values for outer-optimization;

init.HLfit

giving initial values for the iterative algorithms in HLfit. It is itself a list with possible elements:

fixef

for the coefficients of the linear predictor, adjusted to the format of the coefficients of the linear predictor of the template object, if available;

ranCoefs

random-coefficients parameters (if not outer-optimized).

Examples

Run this code
# NOT RUN {
data("blackcap")
(corrhlfit <- corrHLfit(migStatus ~ means+ Matern(1|latitude+longitude),data=blackcap,
                    HLmethod="ML")) 
inits <- get_inits_from_fit(corrhlfit, to_fn = "fitme")                    
(fitfit <- fitme(migStatus ~ means+ Matern(1|latitude+longitude),data=blackcap, 
                  init=inits$init)) 
inits <- get_inits_from_fit(corrhlfit, template = fitfit)                    
fitme(migStatus ~ means+ Matern(1|latitude+longitude),data=blackcap, 
      init=inits$init)
# In these examples, inits$init.HLfit is useless 
# as it is ignored by when LMMs are fitted.
# }

Run the code above in your browser using DataLab