Skip to contents

Non parametric confidence intervals

Description

The function calculates a non parametric confidence and predicted intervals using the function predFit from the package investr (version 1.4.2)

The function requires defining:

  • xseq: A vector with a sequence for independent variable.
  • eq: Summary of the equation fitted.

The function return a data frame df with the xseq (x1), the fitted values for dependent variable (fit), the low and upper confident (IC_L and IC_U) and predicted intervals (IP_L and IP_U).

seealso: predFit() from the package investr (version 1.4.2)

fn_intervals

The function is included in the Morefi package Morphological Relationships Fitted by Robust Regression.

The function is detailed below.


fn_intervals <- function(eq,xseq){
                    new.data <- as.data.frame(xseq)
                    str(predFit(eq, new.data, se.fit = TRUE))
                    CI95 <- predFit(eq, newdata = new.data,
                                    interval = "confidence",level=0.95)
                    PI95 <- predFit(eq, newdata = new.data,
                                    interval = "prediction",level=0.95)

                    df <- as.data.frame(cbind(xseq,CI95,PI95[,-1]))
                    colnames(df) <- c("x1", "fit","IC_L","IC_U", "IP_L","IP_U")
                    df
                    }

Examples

Do not execute, it’s just a syntax example.

IC <- fn_intervals(eq,xseq)