Predict method for the regress function

# S3 method for regress
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 regress

pred_data

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

pred_cmd

Command used to generate data for prediction

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 "prediction"). 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/regress.html for an example in Radiant

See also

regress to generate the result

summary.regress to summarize results

plot.regress to plot results

Examples

result <- regress(diamonds, "price", c("carat", "clarity")) predict(result, pred_cmd = "carat = 1:10")
#> Linear regression (OLS) #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity #> Interval : confidence #> Prediction command : carat = 1:10 #> #> clarity carat Prediction 2.5% 97.5% +/- #> SI1 1 5265.569 5174.776 5356.362 90.793 #> SI1 2 13703.599 13557.662 13849.536 145.937 #> SI1 3 22141.629 21908.326 22374.933 233.303 #> SI1 4 30579.660 30251.571 30907.748 328.088 #> SI1 5 39017.690 38592.329 39443.051 425.361 #> SI1 6 47455.720 46931.983 47979.458 523.738 #> SI1 7 55893.751 55271.056 56516.445 622.695 #> SI1 8 64331.781 63609.787 65053.775 721.994 #> SI1 9 72769.811 71948.301 73591.322 821.511 #> SI1 10 81207.842 80286.667 82129.017 921.175
predict(result, pred_cmd = "clarity = levels(clarity)")
#> Linear regression (OLS) #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity #> Interval : confidence #> Prediction command : clarity = levels(clarity) #> #> carat clarity Prediction 2.5% 97.5% +/- #> 0.794 I1 -78.806 -462.319 304.707 383.513 #> 0.794 SI2 2711.953 2603.644 2820.263 108.310 #> 0.794 SI1 3529.725 3440.015 3619.436 89.711 #> 0.794 VS2 4171.100 4077.495 4264.704 93.605 #> 0.794 VS1 4383.150 4268.576 4497.725 114.574 #> 0.794 VVS2 5030.670 4886.596 5174.743 144.074 #> 0.794 VVS1 4948.863 4785.838 5111.888 163.025 #> 0.794 IF 5186.364 4942.495 5430.234 243.869
result <- regress(diamonds, "price", c("carat", "clarity"), int = "carat:clarity") predict(result, pred_data = diamonds) %>% head()
#> Linear regression (OLS) #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity #> Interval : confidence #> Prediction dataset : diamonds #> #> carat clarity Prediction 2.5% 97.5% +/- #> 0.320 VS1 240.946 88.847 393.045 152.099 #> 0.340 SI1 -119.580 -249.112 9.952 129.532 #> 0.300 VS2 -1.681 -129.827 126.465 128.146 #> 0.350 VVS2 854.443 690.259 1018.626 164.184 #> 0.400 VS2 842.564 727.982 957.146 114.582 #> 0.600 VVS1 3450.421 3290.503 3610.339 159.918