Predict method for the logistic function

# S3 method for logistic
predict(
  object,
  pred_data = NULL,
  pred_cmd = "",
  conf_lev = 0.95,
  se = TRUE,
  interval = "confidence",
  dec = 3,
  envir = parent.frame(),
  ...
)

Arguments

object

Return value from logistic

pred_data

Provide the dataframe to generate predictions (e.g., titanic). The dataset must contain all columns used in the estimation

pred_cmd

Generate predictions using a command. For example, `pclass = levels(pclass)` would produce predictions for the different levels of factor `pclass`. To add another variable, create a vector of prediction strings, (e.g., c('pclass = levels(pclass)', 'age = seq(0,100,20)')

conf_lev

Confidence level used to estimate confidence intervals (.95 is the default)

se

Logical that indicates if prediction standard errors should be calculated (default = FALSE)

interval

Type of interval calculation ("confidence" or "none"). Set to "none" if se is FALSE

dec

Number of decimals to show

envir

Environment to extract data from

...

further arguments passed to or from other methods

Details

See https://radiant-rstats.github.io/docs/model/logistic.html for an example in Radiant

See also

logistic to generate the result

summary.logistic to summarize results

plot.logistic to plot results

plot.model.predict to plot prediction output

Examples

result <- logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)")
#> Logistic regression (GLM) #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass, sex #> Interval : confidence #> Prediction command : pclass = levels(pclass) #> #> sex pclass Prediction 2.5% 97.5% #> male 1st 0.408 0.340 0.480 #> male 2nd 0.220 0.170 0.280 #> male 3rd 0.111 0.086 0.142
logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% predict(pred_cmd = "sex = c('male','female')")
#> Logistic regression (GLM) #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass, sex #> Interval : confidence #> Prediction command : sex = c('male', 'female') #> #> pclass sex Prediction 2.5% 97.5% #> 3rd male 0.111 0.086 0.142 #> 3rd female 0.608 0.540 0.673
logistic(titanic, "survived", c("pclass", "sex"), lev = "Yes") %>% predict(pred_data = titanic)
#> Logistic regression (GLM) #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass, sex #> Interval : confidence #> Prediction dataset : titanic #> Rows shown : 10 of 1,043 #> #> pclass sex Prediction 2.5% 97.5% #> 1st female 0.896 0.856 0.926 #> 1st male 0.408 0.340 0.480 #> 1st female 0.896 0.856 0.926 #> 1st male 0.408 0.340 0.480 #> 1st female 0.896 0.856 0.926 #> 1st male 0.408 0.340 0.480 #> 1st female 0.896 0.856 0.926 #> 1st male 0.408 0.340 0.480 #> 1st female 0.896 0.856 0.926 #> 1st male 0.408 0.340 0.480