Learn R Programming

psycho (version 0.4.91)

get_predicted.glm: Compute predicted values of lm models.

Description

Compute predicted from a lm model.

Usage

# S3 method for glm
get_predicted(fit, newdata = "model", prob = 0.95,
  odds_to_probs = TRUE, ...)

Arguments

fit

An lm model.

newdata

A data frame in which to look for variables with which to predict. If omitted, the model matrix is used. If "model", the model's data is used.

prob

Probability of confidence intervals (0.9 (default) will compute 2.5-97.5% CI). Can also be a list of probs (e.g., c(0.90, 0.95)).

odds_to_probs

Transform log odds ratios in logistic models to probabilies.

...

Arguments passed to or from other methods.

Value

dataframe with predicted values.

Examples

Run this code
# NOT RUN {
library(psycho)
library(ggplot2)

fit <- glm(Sex ~ Adjusting, data = affective, family = "binomial")

refgrid <- psycho::refdata(affective, "Adjusting")
predicted <- get_predicted(fit, newdata = refgrid)

ggplot(predicted, aes(x = Adjusting, y = Sex_Predicted)) +
  geom_line() +
  geom_ribbon(aes(
    ymin = Sex_CI_2.5,
    ymax = Sex_CI_97.5
  ),
  alpha = 0.1
  )
# }

Run the code above in your browser using DataLab