predict.bamlss {bamlss} | R Documentation |

Takes a fitted `bamlss`

object and computes predictions. Predictions can be based on
estimated parameters of optimizer functions or on samples returned from sampler functions.
It is possible to compute predictions on multiple cores using the
`parallel`

and to chunk predictions to save computation time and memory
storage. Predictions can be computed for full distributional parameters or specific model
terms. If a `link{bamlss}`

model was fitted on multiple cores, i.e., the samples
are provided as `link{mcmc.list}`

where each list entry represents samples from one
core, function `predict.bamlss()`

computes combined predictions based on samples of all
cores.

## S3 method for class 'bamlss' predict(object, newdata, model = NULL, term = NULL, match.names = TRUE, intercept = TRUE, type = c("link", "parameter"), FUN = function(x) { mean(x, na.rm = TRUE) }, trans = NULL, what = c("samples", "parameters"), nsamps = NULL, verbose = FALSE, drop = TRUE, cores = NULL, chunks = 1, ...)

`object` |
An object of class |

`newdata` |
A data frame or list containing the values of the model
covariates at which predictions are required. Note that depending
on argument |

`model` |
Character or integer, specifies the model for which predictions should be computed. |

`term` |
Character or integer, specifies the model terms for which predictions are required.
Note that, e.g., |

`match.names` |
Should partial string matching be used to select the |

`intercept` |
Should the intercept be included? |

`type` |
If |

`FUN` |
A function that should be applied on the samples of predictors or
parameters, depending on argument |

`trans` |
A transformer function or named list of transformer functions that computes
transformed predictions. If |

`what` |
Predictions can be computed from samples or estimated parameters of optimizer functions. If no samples are available the default is to use estimated parameters. |

`nsamps` |
If the fitted |

`verbose` |
If predictions are chunked, information on the prediction process can be printed. |

`drop` |
If predictions for only one |

`cores` |
Specifies the number of cores that should be used for prediction. Note that
this functionality is based on the |

`chunks` |
Should computations be split into |

`...` |
Arguments passed to prediction functions that are part of a |

Depending on arguments `model`

, `FUN`

and the structure of the `bamlss`

model, a list of predictions or simple vectors or matrices of predictions.

`link{bamlss}`

, `fitted.bamlss`

.

## Not run: ## Generate some data. d <- GAMart() ## Model formula. f <- list( num ~ s(x1) + s(x2) + s(x3) + te(lon,lat), sigma ~ s(x1) + s(x2) + s(x3) + te(lon,lat) ) ## Estimate model. b <- bamlss(f, data = d) ## Predictions. p <- predict(b) str(b) ## Prediction for "mu" model and term "s(x2)". p <- predict(b, model = "mu", term = "s(x2)") ## Plot effect plot2d(p ~ x2, data = d) ## Same for "sigma" model. p <- predict(b, model = "sigma", term = "s(x2)") plot2d(p ~ x2, data = d) ## Prediction for "mu" model and term "s(x1)" + "s(x2)" ## without intercept. p <- predict(b, model = "mu", term = c("s(x1)", "s(x2)"), intercept = FALSE) ## Prediction based on quantiles. p <- predict(b, model = "mu", term = "s(x2)", FUN = c95) plot2d(p ~ x2, data = d) ## Extract samples of predictor for "s(x2)". p <- predict(b, model = "mu", term = "s(x2)", intercept = FALSE, FUN = function(x) { x }) print(dim(p)) plot2d(p ~ x2, data = d, col.lines = rgb(0.1, 0.1, 0.1, alpha = 0.1)) ## Or using specific combinations of terms. p <- predict(b, model = "mu", term = c("s(x2)", "te(lon,lat)"), intercept = FALSE, FUN = function(x) { x }) head(p) ## Prediction using new data. ## Only need x3 data when predicting ## for s(x3). nd <- data.frame("x3" = seq(0, 1, length = 100)) nd <- cbind(nd, predict(b, newdata = nd, term = "s(x3)")) print(head(nd)) plot2d(mu ~ x3, data = nd) plot2d(sigma ~ x3, data = nd) ## End(Not run)

[Package *bamlss* version 1.1-4 Index]